Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/market-currency
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro authored Jul 3, 2024
2 parents 27a1563 + eb0eee5 commit 5c9d091
Show file tree
Hide file tree
Showing 17 changed files with 297 additions and 184 deletions.
4 changes: 2 additions & 2 deletions firefly.diff
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
delete mode 100644 packages/desktop/electron/electronApi.js
delete mode 100644 packages/desktop/electron/ledgerApi.js
delete mode 100644 packages/desktop/electron/lib/aboutPreload.js
delete mode 100644 packages/desktop/electron/lib/analytics.js
delete mode 100644 packages/desktop/electron/lib/appUpdater.js
delete mode 100644 packages/desktop/electron/lib/deepLinkManager.js
delete mode 100644 packages/desktop/electron/lib/diagnostics.js
Expand All @@ -175,7 +176,6 @@
rename packages/desktop/lib/auxiliary/popup/{helpers => actions}/modifyPopupState.ts (67%)
delete mode 100644 packages/desktop/lib/auxiliary/popup/helpers/index.ts
rename packages/desktop/lib/{electron.ts => electron/index.ts} (54%)
rename packages/desktop/{electron/lib/analytics.js => lib/electron/utils/analytics.utils.ts} (82%)
rename packages/desktop/{electron/lib/errorHandling.js => lib/electron/utils/error.utils.ts} (69%)
delete mode 100644 packages/desktop/lib/routers/actions/openSettings.ts
delete mode 100644 packages/desktop/lib/routers/enums/index.ts
Expand Down Expand Up @@ -1903,7 +1903,7 @@
rename packages/shared/{ => src}/lib/core/market/constants/index.ts (100%)
rename packages/shared/{ => src}/lib/core/market/constants/market-poll-interval.constant.ts (100%)
rename packages/shared/{ => src}/lib/core/market/constants/market-simple-price-endpoint.constant.ts (100%)
rename packages/shared/{ => src}/lib/core/market/enums/market-coin-id.enum.ts (73%)
rename packages/shared/{ => src}/lib/core/market/enums/market-coin-id.enum.ts (54%)
rename packages/shared/{ => src}/lib/core/market/enums/market-currency.enum.ts (94%)
rename packages/shared/{lib/auxiliary/icon => src/lib/core/market}/index.ts (77%)
rename packages/shared/{ => src}/lib/core/market/interfaces/simple-prices-query-parameters.interface.ts (100%)
Expand Down
39 changes: 23 additions & 16 deletions packages/desktop/components/popup/popups/SignTypedDataPopup.svelte
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<script lang="ts">
import { localize } from '@core/i18n'
import { PopupId, closePopup, openPopup } from '@desktop/auxiliary/popup'
import { IConnectedDapp } from '@auxiliary/wallet-connect/interface'
import { CallbackParameters } from '@auxiliary/wallet-connect/types'
import { WCRequestInfo } from '@auxiliary/wallet-connect/types'
import { Alert, JsonTree, Table, Text } from '@bloomwalletio/ui'
import { IAccountState } from '@core/account'
import { IEvmNetwork } from '@core/network'
import { AccountLabel, DappInfo } from '@ui'
import { checkActiveProfileAuth } from '@core/profile/actions'
import { LedgerAppName } from '@core/ledger'
import PopupTemplate from '../PopupTemplate.svelte'
import { SignTypedDataVersion } from '@metamask/eth-sig-util'
import { signEip712Message } from '@core/wallet/actions/signEip712Message'
import { DappVerification } from '@auxiliary/wallet-connect/enums'
import { handleError } from '@core/error/handlers'
import { MILLISECONDS_PER_SECOND } from '@core/utils'
import { time } from '@core/app/stores'
import { RequestExpirationAlert } from '@views/dashboard/drawers/dapp-config/components'
export let data: string
export let version: SignTypedDataVersion.V3 | SignTypedDataVersion.V4
export let account: IAccountState
export let evmNetwork: IEvmNetwork
export let dapp: IConnectedDapp
export let verifiedState: DappVerification
export let callback: (params: CallbackParameters) => void
export let requestInfo: WCRequestInfo
const { dapp, responseCallback, verifiedState, evmNetwork, expiryTimestamp } = requestInfo
$: hasExpired =
expiryTimestamp === undefined ? false : expiryTimestamp * MILLISECONDS_PER_SECOND - $time.getTime() <= 0
let isBusy = false
Expand All @@ -37,7 +38,7 @@
const result = await signEip712Message(data, version, evmNetwork.coinType, account)
closePopup({ forceClose: true })
callback({ result })
responseCallback({ result })
openPopup({
id: PopupId.SuccessfulDappInteraction,
props: {
Expand Down Expand Up @@ -66,16 +67,22 @@
continueButton={{
text: localize('popups.signMessage.action'),
onClick: onConfirmClick,
disabled: hasExpired,
}}
busy={isBusy}
>
<DappInfo
slot="banner"
metadata={dapp.metadata}
{verifiedState}
showLink={false}
classes="bg-surface-1 dark:bg-surface-1-dark pb-4"
/>
<svelte:fragment slot="banner">
{#if dapp}
<DappInfo
slot="banner"
metadata={dapp.metadata}
{verifiedState}
showLink={false}
classes="bg-surface-1 dark:bg-surface-1-dark pb-4"
/>
<RequestExpirationAlert {expiryTimestamp} />
{/if}
</svelte:fragment>

<div class="space-y-5">
<div>
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@amplitude/analytics-node": "1.3.6",
"@ledgerhq/hw-app-eth": "6.36.1",
"@ledgerhq/hw-app-eth": "6.37.1",
"@ledgerhq/hw-transport-node-hid": "6.28.6",
"@ledgerhq/logs": "6.12.0",
"@types/webpack-dev-server": "4.7.2",
Expand All @@ -51,7 +51,7 @@
"autoprefixer": "10.4.16",
"copy-webpack-plugin": "12.0.2",
"cross-env": "7.0.3",
"css-loader": "7.1.1",
"css-loader": "7.1.2",
"electron": "30.0.9",
"electron-builder": "24.13.3",
"@electron/notarize": "2.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { CollectiblesDetailsView, CollectiblesGalleryView, CollectionsGalleryView } from './views'
import { selectedCollectiblesTab } from '@core/nfts/stores'
$: $selectedAccountIndex !== undefined && $collectiblesRouter.reset()
$: $selectedAccountIndex !== undefined && $collectiblesRouter?.reset()
$: if (features.analytics.dashboardRoute.collectibles.enabled && $collectiblesRoute) {
Platform.trackEvent('collectibles-route', { route: $collectiblesRoute })
Expand All @@ -15,9 +15,9 @@

<div class="w-full h-full flex flex-col flex-nowrap p-8 relative flex-1">
{#if $collectiblesRoute === CollectiblesRoute.Gallery}
{#if $selectedCollectiblesTab?.key === 'collectibles'}
{#if $selectedCollectiblesTab === 0}
<CollectiblesGalleryView />
{:else if $selectedCollectiblesTab?.key === 'collections'}
{:else if $selectedCollectiblesTab === 1}
<CollectionsGalleryView />
{/if}
{/if}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
<script lang="ts">
import { Tabs } from '@bloomwalletio/ui'
import { COLLECTIBLES_TABS } from '@core/nfts'
import { selectedCollectiblesTab } from '@core/nfts/stores'
import { KeyValue } from '@ui'
import features from '@features/features'
import { localize } from '@core/i18n'
const selectedIndex = COLLECTIBLES_TABS.findIndex((tab) => tab.key === $selectedCollectiblesTab?.key)
const COLLECTIBLES_TABS: KeyValue<string>[] = [
{ key: 'collectibles', value: localize('views.collectibles.gallery.title') },
...(features.collectibles?.collections.enabled
? [{ key: 'collections', value: localize('views.collectibles.collectionsGallery.title') }]
: []),
]
</script>

{#if COLLECTIBLES_TABS.length > 1}
<div class="w-64">
<Tabs {selectedIndex} bind:selectedTab={$selectedCollectiblesTab} tabs={COLLECTIBLES_TABS} />
<Tabs
bind:selectedIndex={$selectedCollectiblesTab}
selectedTab={COLLECTIBLES_TABS[$selectedCollectiblesTab]}
tabs={COLLECTIBLES_TABS}
/>
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { activeProfileId } from '@core/profile/stores'
export let dapp: IConnectedDapp
export let disabled: boolean = false
export let onClick: (() => unknown) | undefined = undefined
$: networkIds = Object.values(
Expand All @@ -22,7 +21,6 @@

<ClickableTile
classes="bg-surface-0 dark:bg-surface-0-dark border border-solid border-stroke dark:border-stroke-dark"
{disabled}
{onClick}
>
<div class="w-full flex flex-row justify-between items-center p-2 gap-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{#if displayedDapps.length}
<div class="h-full flex flex-col scrollable px-6 items-start gap-3">
{#each displayedDapps as dapp}
<DappCard {dapp} disabled={selectedIndex === 1} onClick={() => onDappCardClick(dapp)} />
<DappCard {dapp} onClick={() => onDappCardClick(dapp)} />
{/each}
</div>
{:else}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
onEditNetworksClick={() => drawerRouter.goTo(DappConfigRoute.EditNetworks)}
onEditAccountsClick={() => drawerRouter.goTo(DappConfigRoute.EditAccounts)}
/>
{:else}
<Text type="body2" align="center">{localize(`${localeKey}.notConnectedToProfile`)}</Text>
{/if}
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@iota/sdk": "1.1.5",
"@iota/util.js": "2.0.0-rc.2",
"@metamask/eth-sig-util": "7.0.2",
"@spruceid/siwe-parser": "2.0.2",
"@spruceid/siwe-parser": "2.1.2",
"@sveltejs/svelte-virtual-list": "3.0.1",
"@walletconnect/jsonrpc-types": "1.0.4",
"@walletconnect/notify-client": "1.4.1",
Expand All @@ -25,7 +25,7 @@
"qrious": "4.0.2",
"sanitize-html": "2.13.0",
"sha3": "2.1.4",
"svelte": "4.2.17",
"svelte": "4.2.18",
"svelte-i18n": "4.0.0",
"web3": "4.8.0",
"zxcvbn": "4.4.2"
Expand All @@ -36,7 +36,7 @@
"test": "jest"
},
"devDependencies": {
"@swc/core": "1.5.24",
"@swc/core": "1.6.6",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/sanitize-html": "2.11.0",
Expand All @@ -46,9 +46,9 @@
"lokijs": "1.5.12",
"postcss": "8.4.38",
"postcss-cli": "11.0.0",
"svelte-loader": "3.2.0",
"svelte-loader": "3.2.3",
"tailwindcss": "3.4.3",
"tslib": "2.6.2",
"tslib": "2.6.3",
"valid-url": "1.0.9",
"zxcvbn": "4.4.2"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { IAccountState, getAddressFromAccountForNetwork } from '@core/account'
import { get } from 'svelte/store'
import { ISupportedNamespace } from '../types'
import { getWalletClient, walletClient } from '../stores'
import { EvmNetworkId } from '@core/network/types'
import { buildCaip10Address } from '../utils'
import { connectedDapps } from '../stores'

export async function addAccountToAllDappSessions(account: IAccountState): Promise<void> {
const dapps = get(connectedDapps)
for (const dapp of dapps) {
if (dapp.sessionTopic && dapp.namespaces) {
await addAccountForDappSession(dapp.sessionTopic, dapp.namespaces, account)
}
}
}

export async function addAccountForDappSession(
sessionTopic: string,
namespaces: Record<string, ISupportedNamespace>,
account: IAccountState
): Promise<void> {
const walletConnectClient = get(walletClient)
if (!walletConnectClient) {
return
}

const protocols = Object.keys(namespaces ?? {})
for (const protocol of protocols) {
if (!namespaces[protocol]) {
continue
}

const chainsForSession = (namespaces[protocol].chains ?? []) as EvmNetworkId[]
const addressOfAccountForEachChain = chainsForSession
.map((chainId) => {
const address = getAddressFromAccountForNetwork(account, chainId)
return address ? buildCaip10Address(address, chainId) : undefined
})
.filter(Boolean) as string[]

namespaces[protocol].accounts = [...addressOfAccountForEachChain, ...namespaces[protocol].accounts]
}

await getWalletClient()?.updateSession({ topic: sessionTopic, namespaces })
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './addAccountToAllDappSessions'
export * from './approveSession'
export * from './approveSessionAuthenticate'
export * from './buildSupportedNamespaceFromSelections'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { setSelectedAccount } from './setSelectedAccount'
import { getActiveProfile } from '@core/profile/stores'
import { ProfileType } from '@core/profile'
import { generateAndStoreEvmAddressForAccounts, pollEvmBalancesForAccount } from '@core/layer-2/actions'
import { getEvmNetworks } from '@core/network/stores'
import { IError } from '@core/error/interfaces'
import { DEFAULT_COIN_TYPE, SupportedNetworkId } from '@core/network/constants'
import { addAccountToAllDappSessions, updateAccountForConnectedDapps } from '@auxiliary/wallet-connect/actions'

export async function tryCreateAdditionalAccount(alias: string, color: string): Promise<void> {
try {
Expand All @@ -21,11 +22,12 @@ export async function tryCreateAdditionalAccount(alias: string, color: string):

const activeProfile = getActiveProfile()
if (activeProfile.type === ProfileType.Software) {
const coinType = getEvmNetworks()[0]?.coinType
if (coinType !== undefined) {
void generateAndStoreEvmAddressForAccounts(activeProfile.type, coinType, account)
const coinType = DEFAULT_COIN_TYPE[SupportedNetworkId.Ethereum]
generateAndStoreEvmAddressForAccounts(activeProfile.type, coinType, account).then(async () => {
void pollEvmBalancesForAccount(activeProfile.id, account)
}
await addAccountToAllDappSessions(account)
await updateAccountForConnectedDapps(account)
})
}

return Promise.resolve()
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/shared/src/lib/core/nfts/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './collectibles-tabs.constant'
export * from './current-irc27-version.constant'
export * from './default-nft-filter.constant'
export * from './default-nft-name.constant'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { KeyValue } from '@ui'
import { Writable, writable } from 'svelte/store'
import { COLLECTIBLES_TABS } from '../constants'

export const selectedCollectiblesTab: Writable<KeyValue<string>> = writable(COLLECTIBLES_TABS[0])
export const selectedCollectiblesTab: Writable<number> = writable(0)
1 change: 1 addition & 0 deletions packages/shared/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@
"description": "Description",
"url": "URL",
"verifyUrl": "Verify URL",
"notConnectedToProfile": "Not connected to this profile",
"disconnect": {
"title": "Disconnect",
"description": "Do you want to disconnect from {dappName}?"
Expand Down
Loading

0 comments on commit 5c9d091

Please sign in to comment.