Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: open urls on click in activitydetails in browser #2010

Merged
merged 7 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity?.nftId)
: undefined
$: nftIsOwned = nft ? $ownedNfts.some((_onMountnft) => _onMountnft.id === nft?.id) : false
$: explorerUrl = setExplorerUrl(activity)
$: explorerUrl = getExplorerUrl(activity)

let title: string = localize('popups.activityDetails.title.fallback')
$: void setTitle(activity)
Expand All @@ -60,7 +60,7 @@
$collectiblesRouter.setBreadcrumb(nft?.name)
}

function setExplorerUrl(_activity: Activity): string | undefined {
function getExplorerUrl(_activity: Activity): string | undefined {
if (activity?.direction === ActivityDirection.Genesis) {
const explorerUrl = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Output)
return explorerUrl ? `${explorerUrl}/${_activity?.outputId}` : undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Bloom Labs Ltd <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"@bloomwalletio/ui": "0.20.8",
"@bloomwalletio/ui": "0.20.9",
"@ethereumjs/rlp": "4.0.1",
"@ethereumjs/tx": "5.2.1",
"@ethereumjs/util": "9.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
<AliasActivityInformation {activity} />
{:else if selectedTab.key === PopupTab.Nft && activity.type === ActivityType.Nft}
<NftActivityInformation {activity} />
{:else if selectedTab.key === PopupTab.Foundry}
{:else if selectedTab.key === PopupTab.Foundry && activity.type === ActivityType.Foundry}
<FoundryActivityInformation {activity} />
{:else if selectedTab.key === PopupTab.Token}
{:else if selectedTab.key === PopupTab.Token && activity.type === ActivityType.Foundry}
<TokenActivityInformation {activity} />
{:else if selectedTab.key === PopupTab.NftMetadata && activity.type === ActivityType.Nft}
<NftMetadataInformation {activity} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@
import { Table } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { AliasActivity } from '@core/activity'
import { getDefaultExplorerUrl } from '@core/network/utils'
import { ExplorerEndpoint } from '@core/network/enums'
import { openUrlInBrowser } from '@core/app/utils'

export let activity: AliasActivity

function onAddressClick(address: string) {
const explorerUrl = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address)
openUrlInBrowser(`${explorerUrl}/${address}`)
}
</script>

<Table
items={[
{
key: localize('general.aliasId'),
value: activity.aliasId,
copyable: true,
truncate: true,
onClick: () => onAddressClick(activity.aliasId),
},
{
key: localize('general.governorAddress'),
value: activity.governorAddress,
copyable: true,
truncate: true,
onClick: () => onAddressClick(activity.governorAddress),
},
{
key: localize('general.stateControllerAddress'),
value: activity.stateControllerAddress,
copyable: true,
truncate: true,
onClick: () => onAddressClick(activity.stateControllerAddress),
},
]}
/>
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
<script lang="ts">
import { Table } from '@bloomwalletio/ui'
import { FoundryActivity } from '@core/activity'
import { openUrlInBrowser } from '@core/app'
import { localize } from '@core/i18n'
import { ExplorerEndpoint } from '@core/network/enums'
import { getDefaultExplorerUrl } from '@core/network/utils'

export let activity: FoundryActivity

function onAliasClick(aliasAddress: string) {
const explorerUrl = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address)
openUrlInBrowser(`${explorerUrl}/${aliasAddress}`)
}

function onTokenClick(tokenId: string) {
const explorerUrl = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Foundry)
openUrlInBrowser(`${explorerUrl}/${tokenId}`)
}
</script>

<Table
Expand All @@ -12,25 +25,25 @@
key: localize('popups.nativeToken.property.aliasAddress'),
value: activity.aliasAddress,
truncate: { firstCharCount: 10, endCharCount: 10 },
copyable: true,
onClick: () => onAliasClick(activity.aliasAddress),
},
{
key: localize('popups.nativeToken.property.tokenId'),
value: activity.tokenTransfer?.tokenId,
truncate: { firstCharCount: 10, endCharCount: 10 },
copyable: true,
onClick: () => onTokenClick(activity.tokenTransfer?.tokenId ?? ''),
},
{
key: localize('popups.nativeToken.property.maximumSupply'),
value: activity.maximumSupply,
value: String(activity.maximumSupply),
},
{
key: localize('popups.nativeToken.property.mintedTokens'),
value: activity.mintedTokens,
value: String(activity.mintedTokens),
},
{
key: localize('popups.nativeToken.property.meltedTokens'),
value: activity.meltedTokens,
value: String(activity.meltedTokens),
},
]}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,50 @@
import { Table } from '@bloomwalletio/ui'
import { selectedAccountIndex } from '@core/account/stores'
import { NftActivity } from '@core/activity'
import { openUrlInBrowser } from '@core/app/utils'
import { localize } from '@core/i18n'
import { ExplorerEndpoint } from '@core/network/enums'
import { getDefaultExplorerUrl } from '@core/network/utils'
import { NftStandard } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { getBech32AddressFromAddressTypes, getHexAddressFromAddressTypes } from '@core/wallet'
import { AddressType } from '@iota/sdk/out/types'
import { type Address, AddressType } from '@iota/sdk/out/types'

export let activity: NftActivity

$: nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity?.nftId)
$: issuer = nft?.standard === NftStandard.Irc27 ? nft?.issuer : undefined

function onNftIdClick(nftId: string) {
const explorerUrl = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Nft)
openUrlInBrowser(`${explorerUrl}/${nftId}`)
}

function onIssuerClick(issuer: Address) {
const explorerUrl = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address)
openUrlInBrowser(`${explorerUrl}/${getBech32AddressFromAddressTypes(issuer)}`)
}
</script>

<Table
items={[
{
key: localize('general.nftId'),
value: activity?.nftId,
truncate: { firstCharCount: 10, endCharCount: 10 },
copyable: true,
onClick: () => onNftIdClick(activity?.nftId),
},
{
key: localize('general.issuerAddress'),
value:
nft?.issuer?.type === AddressType.Ed25519 ? getBech32AddressFromAddressTypes(nft?.issuer) : undefined,
truncate: { firstCharCount: 10, endCharCount: 10 },
copyable: true,
value: issuer?.type === AddressType.Ed25519 ? getBech32AddressFromAddressTypes(issuer) : undefined,
onClick: () => issuer && onIssuerClick(issuer),
},
{
key: localize('general.collectionId'),
value: [AddressType.Nft, AddressType.Alias].includes(nft?.issuer?.type)
? getHexAddressFromAddressTypes(nft?.issuer)
: undefined,
truncate: { firstCharCount: 10, endCharCount: 10 },
copyable: true,
value:
issuer && [AddressType.Nft, AddressType.Alias].includes(issuer?.type)
? getHexAddressFromAddressTypes(issuer)
: undefined,
onClick: () => issuer && onIssuerClick(issuer),
},
]}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Table } from '@bloomwalletio/ui'
import { selectedAccountIndex } from '@core/account/stores'
import { NftActivity } from '@core/activity'
import { openUrlInBrowser } from '@core/app/utils'
import { localize } from '@core/i18n'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { NftStandard } from '@core/nfts/enums'
Expand Down Expand Up @@ -31,7 +32,7 @@
{
key: localize('general.uri'),
value: metadata.uri,
copyable: true,
onClick: () => openUrlInBrowser(metadata?.uri ?? ''),
},
{
key: localize('general.description'),
Expand Down Expand Up @@ -68,7 +69,7 @@
{
key: localize('general.image'),
value: metadata.image,
copyable: true,
onClick: () => openUrlInBrowser(metadata?.image ?? ''),
},
{
key: localize('general.description'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { Table } from '@bloomwalletio/ui'
import { FoundryActivity } from '@core/activity'
import { openUrlInBrowser } from '@core/app/utils'
import { localize } from '@core/i18n'
import { IIrc30Metadata } from '@core/token'
import { getPersistedToken } from '@core/token/stores'
Expand Down Expand Up @@ -35,7 +36,7 @@
{
key: localize('popups.nativeToken.property.url'),
value: metadata.url || undefined,
copyable: true,
onClick: () => openUrlInBrowser(metadata?.url ?? ''),
},
{
key: localize('popups.nativeToken.property.logo'),
Expand All @@ -45,7 +46,7 @@
{
key: localize('popups.nativeToken.property.logoUrl'),
value: metadata.logoUrl || undefined,
copyable: true,
onClick: () => openUrlInBrowser(metadata?.logoUrl ?? ''),
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ export const EXPLORER_ENDPOINTS: Readonly<{ [key in SupportedNetworkId]: { [key
[ExplorerEndpoint.Transaction]: ExplorerEndpoint.Transaction,
[ExplorerEndpoint.Output]: ExplorerEndpoint.Output,
[ExplorerEndpoint.Nft]: ExplorerEndpoint.Nft,
[ExplorerEndpoint.Foundry]: ExplorerEndpoint.Foundry,
[ExplorerEndpoint.Address]: 'addr',
},
[SupportedNetworkId.Shimmer]: {
[ExplorerEndpoint.Transaction]: ExplorerEndpoint.Transaction,
[ExplorerEndpoint.Output]: ExplorerEndpoint.Output,
[ExplorerEndpoint.Nft]: ExplorerEndpoint.Nft,
[ExplorerEndpoint.Foundry]: ExplorerEndpoint.Foundry,
[ExplorerEndpoint.Address]: 'addr',
},
[SupportedNetworkId.Testnet]: {
[ExplorerEndpoint.Transaction]: ExplorerEndpoint.Transaction,
[ExplorerEndpoint.Output]: ExplorerEndpoint.Output,
[ExplorerEndpoint.Nft]: ExplorerEndpoint.Nft,
[ExplorerEndpoint.Foundry]: ExplorerEndpoint.Foundry,
[ExplorerEndpoint.Address]: 'addr',
},
[SupportedNetworkId.ShimmerEvm]: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum ExplorerEndpoint {
Address = 'address',
Foundry = 'foundry',
Nft = 'nft',
Token = 'token',
Transaction = 'transaction',
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@bloomwalletio/[email protected].8":
version "0.20.8"
resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.20.8/c315895a962b23263da7fe5e91ddff0eb61fb9db#c315895a962b23263da7fe5e91ddff0eb61fb9db"
integrity sha512-jwailq9C48f4R+ID3wnzzC+A7KKSMI6TUM/HAX7St/qwhruK583wof05ci6JAkEnJKkj4Y6pGE5i4eHB+s48aQ==
"@bloomwalletio/[email protected].9":
version "0.20.9"
resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.20.9/a388d219d644c1029a6bcbf239cb7149fa23e20f#a388d219d644c1029a6bcbf239cb7149fa23e20f"
integrity sha512-GNej31d/rRZmEnSKDgmWOgMUbfDV/N4oToyD7tniTHK7Q5sPyqp+QaD9kwsXfWPw/yi0UJp1igLEcWll+88Ong==
dependencies:
"@floating-ui/dom" "1.4.3"
"@popperjs/core" "2.11.8"
Expand Down
Loading