Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2590----create-buysell-exchange-…
Browse files Browse the repository at this point in the history
…ui' into 2735-add-min-and-max-amount-in-amountinput
  • Loading branch information
nicole-obrien committed Aug 8, 2024
2 parents e79a605 + e20e834 commit 95e6694
Show file tree
Hide file tree
Showing 35 changed files with 761 additions and 502 deletions.
4 changes: 2 additions & 2 deletions firefly.diff
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@
delete mode 100644 packages/shared/lib/core/wallet/interfaces/asset.interface.ts
delete mode 100644 packages/shared/lib/core/wallet/interfaces/index.ts
delete mode 100644 packages/shared/lib/core/wallet/interfaces/persisted-assets.interface.ts
delete mode 100644 packages/shared/lib/core/wallet/stores/all-account-activities.store.ts
delete mode 100644 packages/shared/lib/core/wallet/stores/index.ts
delete mode 100644 packages/shared/lib/core/wallet/stores/new-transaction-details.store.ts
delete mode 100644 packages/shared/lib/core/wallet/stores/persisted-assets.store.ts
Expand Down Expand Up @@ -1746,7 +1747,6 @@
rename packages/shared/{lib/core/wallet/enums/alias-subtype.enum.ts => src/lib/core/activity/enums/stardust/stardust-alias-action.enum.ts} (58%)
rename packages/shared/{lib/core/wallet/enums/governance-action.enum.ts => src/lib/core/activity/enums/stardust/stardust-governance-action.enum.ts} (84%)
rename packages/shared/{lib/core/nfts => src/lib/core/activity}/index.ts (83%)
rename packages/shared/{lib/core/wallet => src/lib/core/activity}/stores/all-account-activities.store.ts (51%)
rename packages/shared/{lib/core/wallet => src/lib/core/activity}/stores/claimed-activities.store.ts (61%)
rename packages/shared/{lib/core/wallet => src/lib/core/activity}/stores/hidden-activities.store.ts (53%)
rename packages/shared/{lib/core/wallet/interfaces => src/lib/core/activity/types}/activity-filter.interface.ts (83%)
Expand Down Expand Up @@ -2043,7 +2043,7 @@
rename packages/shared/{ => src}/lib/core/profile/interfaces/login-progress.interface.ts (100%)
rename packages/shared/{ => src}/lib/core/profile/interfaces/profile.interface.ts (91%)
rename packages/shared/{ => src}/lib/core/profile/stores/active-accounts.store.ts (96%)
rename packages/shared/{ => src}/lib/core/profile/stores/active-profile.store.ts (84%)
rename packages/shared/{ => src}/lib/core/profile/stores/active-profile.store.ts (67%)
rename packages/shared/{ => src}/lib/core/profile/stores/hasStrongholdLocked.store.ts (100%)
rename packages/shared/{ => src}/lib/core/profile/stores/index.ts (90%)
rename packages/shared/{ => src}/lib/core/profile/stores/is-active-ledger-profile.store.ts (100%)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
],
"devDependencies": {
"@babel/eslint-parser": "7.24.6",
"@tsconfig/svelte": "5.0.2",
"@tsconfig/svelte": "5.0.4",
"@types/node": "18.15.11",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@typescript-eslint/parser": "7.11.0",
"eslint": "9.6.0",
"eslint-plugin-security": "3.0.0",
"eslint-plugin-security": "3.0.1",
"eslint-plugin-svelte": "2.39.0",
"globals": "^15.7.0",
"husky": "7.0.4",
Expand Down
16 changes: 6 additions & 10 deletions packages/desktop/components/popup/popups/TransakFramePopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,14 @@
}
const rect = transakContainer.getBoundingClientRect()
const transakPaneStyles = getComputedStyle(transakContainer?.children[0])
const extractDigitsToNumbers = (str: string) => Number(str?.replace(/\D/g, '') ?? 0)
const borderTop = extractDigitsToNumbers(transakPaneStyles?.borderTopWidth)
const borderBottom = extractDigitsToNumbers(transakPaneStyles?.borderBottomWidth)
const borderLeft = extractDigitsToNumbers(transakPaneStyles?.borderLeftWidth)
const borderRight = extractDigitsToNumbers(transakPaneStyles?.borderRightWidth)
await Platform.updateTransakBounds({
x: rect.x + borderLeft,
y: rect.y + borderTop,
width: rect.width - borderLeft - borderRight,
height: rect.height - borderTop - borderBottom,
// Safe 1px padding to prevent the iframe from being out of bounds
x: rect.x + 1,
y: rect.y,
// Safe 2px padding to prevent the iframe from being out of bounds
width: rect.width - 2,
height: rect.height,
})
}
Expand Down
10 changes: 5 additions & 5 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "desktop",
"productName": "Bloom",
"version": "1.1.1",
"version": "1.1.3",
"description": "Simple and secure web3 wallet for the IOTA and Shimmer ecosystem",
"main": "public/build/main.process.js",
"repository": "[email protected]:bloomwalletio/bloom.git",
Expand Down Expand Up @@ -44,25 +44,25 @@
"keytar": "7.9.0",
"node-machine-id": "1.1.12",
"stream-http": "3.2.0",
"url": "0.11.3"
"url": "0.11.4"
},
"devDependencies": {
"@types/webpack": "5.28.5",
"autoprefixer": "10.4.16",
"autoprefixer": "10.4.19",
"copy-webpack-plugin": "12.0.2",
"cross-env": "7.0.3",
"css-loader": "7.1.2",
"electron": "30.0.9",
"electron-builder": "24.13.3",
"@electron/notarize": "2.3.0",
"esbuild": "0.22.0",
"esbuild-loader": "4.2.0",
"esbuild-loader": "4.2.2",
"mini-css-extract-plugin": "2.9.0",
"node-loader": "2.0.0",
"npm-run-all": "4.1.5",
"postcss-load-config": "5.0.3",
"postcss-url": "10.1.3",
"webpack": "5.92.1",
"webpack": "5.93.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "5.0.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
export let fiatAmount: number | undefined = undefined
export let fiatSymbol: keyof typeof FiatCurrency | string | undefined = undefined
export let cryptoAmount: number | undefined = undefined
export let onClick: () => void = () => {}
export let selected: boolean = false
</script>

<Tile surface={1} width="full" class={isLoading ? 'animate-pulse' : ''}>
<Tile surface={1} width="full" class={isLoading ? 'animate-pulse' : ''} {onClick} {selected}>
<div class="w-full flex justify-between items-center gap-2">
{#if isLoading}
<div class="w-7 h-7 rounded-full bg-surface-2 dark:bg-surface-2-dark animate-pulse"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
paymentOptions =
supportedCurrencies?.[selectedCurrency as keyof typeof FiatCurrency]?.paymentOptions.map((option) => ({
value: option.id,
label: option.name,
label: localize(`views.buySell.paymentOptions.${option.id}`),
icon: option.id.includes('card') ? IconName.CreditCard : IconName.Bank,
})) ?? []
if (!paymentOptions.some((paymentOption) => paymentOption.value === selectedPaymentOption?.value)) {
Expand Down Expand Up @@ -124,12 +124,14 @@
}
// Quotations
let quotes: ({ fiatAmount: number; cryptoAmount: number } | undefined)[] = new Array(3).fill(undefined)
let quotes: { fiatAmount: number; cryptoAmount: number; provider: string }[] = []
let selectedQuoteId: number | undefined = undefined
let latestQuoteRequestId = 0
let loading = false
async function updateQuote(): Promise<void> {
loading = true
stopQuoteTimer()
selectedQuoteId = undefined
if (!selectedPaymentOption) {
loading = false
Expand Down Expand Up @@ -160,8 +162,10 @@
{
fiatAmount: response.fiatAmount,
cryptoAmount: response.cryptoAmount,
provider: 'Transak',
},
]
selectedQuoteId = 0
startQuoteTimer()
}
Expand Down Expand Up @@ -218,7 +222,8 @@
confirmClickOutside: true,
})
}
$: isButtonDisabled = !selectedCryptoCurrency || !selectedPaymentOption || !selectedRecipient
$: isButtonDisabled =
!selectedCryptoCurrency || !selectedPaymentOption || !selectedRecipient || selectedQuoteId === undefined
onDestroy(() => {
$selectedExchangeCryptoCurrency = undefined
Expand Down Expand Up @@ -287,16 +292,25 @@
<TransakCryptoCurrencyAmountTile isLoading />
<TransakCryptoCurrencyAmountTile isLoading />
{:else if quotes.length > 0}
{#each quotes as quote}
{#each quotes as quote, i}
<TransakCryptoCurrencyAmountTile
cryptoCurrency={selectedCryptoCurrency}
fiatAmount={quote?.fiatAmount}
fiatSymbol={selectedCurrency}
cryptoAmount={quote?.cryptoAmount}
onClick={() => (selectedQuoteId = i)}
selected={selectedQuoteId === i}
/>
{/each}
{/if}
</div>
<Button text={selectedTab.value} on:click={onButtonClick} width="full" disabled={isButtonDisabled} />
<Button
text={selectedQuoteId !== undefined
? localize('views.buySell.quotations.button.selected', { provider: quotes[selectedQuoteId]?.provider })
: localize('views.buySell.quotations.button.unselected')}
on:click={onButtonClick}
width="full"
disabled={isButtonDisabled}
/>
</div>
</Pane>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { BlockscoutApi } from '@auxiliary/blockscout/api'
import { Button, TextInput } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import {
Expand All @@ -15,6 +16,7 @@
import { networks } from '@core/network/stores/networks.store'
import { Router } from '@core/router/classes'
import { isValidHttpsUrl } from '@core/utils'
import { Web3 } from 'web3'
import { NetworkConfigRoute } from '../../network-config-route.enum'
export let drawerRouter: Router<NetworkConfigRoute>
Expand All @@ -34,12 +36,11 @@
$: submitDisabled = !name || !chainId || !rpcEndpoint
function validateName(): void {
if (!name) {
nameError = localize(`${localeKey}.errors.cannotBeEmpty`)
} else if (name.length > MAX_NETWORK_NAME_LENGTH) {
if (name.length > MAX_NETWORK_NAME_LENGTH) {
nameError = localize(`${localeKey}.errors.nameTooLong`)
}
}
function validateChainId(): void {
const networkId = `${NetworkNamespace.Evm}:${chainId}`
if ($networks.some((network) => network.id === networkId)) {
Expand All @@ -54,16 +55,46 @@
}
function validateExplorerUrl(): void {
if (explorerUrl && !isValidHttpsUrl(explorerUrl)) {
if (!isValidHttpsUrl(explorerUrl)) {
explorerUrlError = localize(`${localeKey}.errors.invalidUrl`)
}
}
function validate(): void {
async function verifyRpcAndChainId(): Promise<void> {
try {
const _rpcEndpoint = new URL(rpcEndpoint).href
const provider = new Web3(_rpcEndpoint)
const actualChainId = await provider.eth.net.getId()
if (String(actualChainId) !== chainId) {
chainIdError = localize(`${localeKey}.errors.notMatchingChainId`)
}
} catch (err) {
// TODO: Add more specific error handling for different cases
rpcEndpointError = localize(`${localeKey}.errors.invalidRpcEndpoint`)
}
}
async function verifyExplorer(): Promise<void> {
try {
const blockscoutApi = new BlockscoutApi(explorerUrl)
const backendVersion = await blockscoutApi.getBackendVersion()
if (!backendVersion) {
explorerUrlError = localize(`${localeKey}.errors.invalidExplorerUrl`)
}
} catch (err) {
// TODO: Add more specific error handling for different cases
explorerUrlError = localize(`${localeKey}.errors.invalidExplorerUrl`)
}
}
async function validate(): Promise<void> {
validateName()
validateRpcEndpoint()
validateChainId()
validateExplorerUrl()
await verifyRpcAndChainId()
await verifyExplorer()
}
function trimInputs(): void {
Expand All @@ -75,39 +106,42 @@
function resetErrors(): void {
nameError = ''
chainIdError = ''
rpcEndpointError = ''
explorerUrlError = ''
}
function onSubmitClick(): void {
async function onSubmitClick(): Promise<void> {
trimInputs()
resetErrors()
validate()
await validate()
const hasError = !!nameError || !!rpcEndpointError || !!explorerUrlError || !!chainIdError
if (!hasError) {
const evmNetworkConfiguration: IPureEvmNetworkConfiguration = {
type: NetworkType.Evm,
id: `${NetworkNamespace.Evm}:${chainId}`,
namespace: NetworkNamespace.Evm,
chainId: chainId as ChainId,
name,
rpcEndpoint,
explorerUrl,
coinType: ETHEREUM_COIN_TYPE,
baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.Ethereum],
}
if (hasError) {
return
}
addNewEvmNetwork(evmNetworkConfiguration)
drawerRouter.previous()
const evmNetworkConfiguration: IPureEvmNetworkConfiguration = {
type: NetworkType.Evm,
id: `${NetworkNamespace.Evm}:${chainId}`,
namespace: NetworkNamespace.Evm,
chainId: chainId as ChainId,
name,
rpcEndpoint,
explorerUrl,
coinType: ETHEREUM_COIN_TYPE,
baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.Ethereum],
}
void addNewEvmNetwork(evmNetworkConfiguration)
drawerRouter.previous()
}
</script>

<add-evm-network class="h-full flex flex-col justify-between p-4">
<form id="add-network-form" class="flex flex-col gap-3" on:submit|preventDefault={onSubmitClick}>
<TextInput bind:value={name} label={localize('general.name')} error={nameError} />
<TextInput bind:value={chainId} label={localize(`${localeKey}.chainId`)} error={chainIdError} />
<TextInput bind:value={rpcEndpoint} label={localize(`${localeKey}.rpcEndpoint`)} error={rpcEndpointError} />
<TextInput bind:value={chainId} label={localize(`${localeKey}.chainId`)} error={nameError} />
<TextInput bind:value={explorerUrl} label={localize(`${localeKey}.explorerUrl`)} error={explorerUrlError} />
</form>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import { getTokenFromActivity } from '@core/activity/utils/getTokenFromActivity'
import { formatCurrency, localize } from '@core/i18n'
import { getFiatValueFromTokenAmount } from '@core/market/actions'
import { BASE_TOKEN_ID, ITokenWithBalance, TokenStandard } from '@core/token'
import { BASE_TOKEN_ID, formatTokenAmount, ITokenWithBalance, TokenStandard } from '@core/token'
import { Text } from '@bloomwalletio/ui'
import { selectedAccountTokens } from '@core/token/stores'
import { getPersistedToken, selectedAccountTokens } from '@core/token/stores'
import { NetworkNamespace } from '@core/network'
import { EvmActivityType } from '@core/activity/enums/evm'
import { NftStandard } from '@core/nfts'
Expand Down Expand Up @@ -51,11 +51,21 @@
) {
return '1 ' + localize('general.nft')
} else {
return getFormattedAmountFromActivity(
_activity.tokenTransfer.rawAmount,
_activity.tokenTransfer.tokenId,
_activity
)
if (_activity.type === EvmActivityType.TokenApproval) {
const { rawAmount, tokenId } = _activity.tokenTransfer
const metadata = getPersistedToken(activity.sourceNetworkId, tokenId)?.metadata
const amount = metadata ? formatTokenAmount(rawAmount, metadata) : ''
if (amount.length > 20) {
return 'INFINITE'
}
return amount
} else {
return getFormattedAmountFromActivity(
_activity.tokenTransfer.rawAmount,
_activity.tokenTransfer.tokenId,
_activity
)
}
}
} else {
return '-'
Expand Down
7 changes: 4 additions & 3 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "shared",
"version": "1.1.1",
"version": "1.1.3",
"description": "TypeScript library for the Bloom application",
"author": "Bloom Labs Ltd <[email protected]>",
"license": "PolyForm Strict License 1.0.0",
"dependencies": {
"@bloomwalletio/ui": "0.21.9",
"@bloomwalletio/ui": "0.21.10",
"@ethereumjs/common": "4.3.0",
"@ethereumjs/rlp": "5.0.2",
"@ethereumjs/tx": "5.3.0",
Expand All @@ -24,6 +24,7 @@
"lottie-web": "5.12.2",
"qrious": "4.0.2",
"sanitize-html": "2.13.0",
"semver": "7.6.3",
"sha3": "2.1.4",
"svelte": "4.2.18",
"svelte-i18n": "4.0.0",
Expand All @@ -47,7 +48,7 @@
"postcss": "8.4.38",
"postcss-cli": "11.0.0",
"svelte-loader": "3.2.3",
"tailwindcss": "3.4.3",
"tailwindcss": "3.4.7",
"tslib": "2.6.3",
"valid-url": "1.0.9",
"zxcvbn": "4.4.2"
Expand Down
Loading

0 comments on commit 95e6694

Please sign in to comment.