Skip to content

Commit

Permalink
Merge branch 'develop' into fix/polish-governance
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro authored Mar 1, 2024
2 parents 034a6e1 + 6201493 commit 468e299
Show file tree
Hide file tree
Showing 34 changed files with 388 additions and 107 deletions.
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
13 changes: 13 additions & 0 deletions packages/desktop/lib/electron/managers/transak.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { ITransakManager, ITransakWindowData } from '@core/app'
import path from 'path'
import { TRANSAK_WIDGET_URL } from '@auxiliary/transak/constants'
import { buildQueryParametersFromObject } from '@core/utils/url'
import { Currency } from '@core/utils/enums'
import { validateBech32Address } from '@core/utils/crypto'
import { IOTA_BECH32_HRP } from '@core/network'

export default class TransakManager implements ITransakManager {
private rect: Electron.Rectangle
Expand Down Expand Up @@ -165,6 +168,16 @@ export default class TransakManager implements ITransakManager {
const { address, currency, service } = data
const apiKey = process.env.TRANSAK_API_KEY

validateBech32Address(IOTA_BECH32_HRP, address)

if (Object.values(Currency).includes(currency as Currency)) {
throw new Error('Invalid Transak currency')
}

if (service !== 'BUY' && service !== 'SELL') {
throw new Error('Invalid Transak service')
}

const queryParams = buildQueryParametersFromObject({
apiKey,
defaultFiatCurrency: currency,
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
28 changes: 25 additions & 3 deletions packages/shared/src/lib/auxiliary/blockscout/api/blockscout.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { QueryParameters } from '@core/utils'
import { BaseApi } from '@core/utils/api'
import { DEFAULT_EXPLORER_URLS } from '@core/network/constants'
import { SupportedNetworkId } from '@core/network/enums'
import { IBlockscoutApi, IBlockscoutAsset, IBlockscoutAssetMetadata, IBlockscoutTransaction } from '../interfaces'
import {
IBlockscoutApi,
IBlockscoutAsset,
IBlockscoutTokenInfo,
IBlockscoutTokenTransfer,
IBlockscoutTransaction,
} from '../interfaces'
import { NetworkId } from '@core/network/types'

interface INextPageParams {
Expand Down Expand Up @@ -54,8 +60,8 @@ export class BlockscoutApi extends BaseApi implements IBlockscoutApi {
)
}

async getAssetMetadata(assetAddress: string): Promise<IBlockscoutAssetMetadata | undefined> {
const response = await this.get<IBlockscoutAssetMetadata>(`tokens/${assetAddress}`)
async getAssetMetadata(assetAddress: string): Promise<IBlockscoutTokenInfo | undefined> {
const response = await this.get<IBlockscoutTokenInfo>(`tokens/${assetAddress}`)
if (response) {
response.type = response.type.replace('-', '') as TokenStandard.Erc20 | NftStandard.Erc721
return response
Expand Down Expand Up @@ -96,4 +102,20 @@ export class BlockscoutApi extends BaseApi implements IBlockscoutApi {
)
return items
}

async getTokenTransfersForAddress(
address: string,
standards?: ('ERC-20' | 'ERC-721')[],
exitFunction?: BlockscoutExitFunction<IBlockscoutTokenTransfer>
): Promise<IBlockscoutTokenTransfer[]> {
const path = `addresses/${address}/token-transfers`
const items = await this.makePaginatedGetRequest<IBlockscoutTokenTransfer>(
path,
standards && standards?.length > 0 ? { type: standards } : undefined,
[],
undefined,
exitFunction
)
return items
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum BlockscoutTransactionStatus {
Ok = 'ok',
Error = 'error',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum BlockscoutTransactionType {
TokenTransfer = 'token_transfer',
ContractCreation = 'contract_creation',
ContractCall = 'contract_call',
TokenCreation = 'token_creation',
CoinTransfer = 'coin_transfer',
}
2 changes: 2 additions & 0 deletions packages/shared/src/lib/auxiliary/blockscout/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './blockscout-transaction-status.enum'
export * from './blockscout-transaction-type.enum'
2 changes: 2 additions & 0 deletions packages/shared/src/lib/auxiliary/blockscout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './enums'
export * from './interfaces'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IAddressTag, IWatchlistName } from './blockscout-transaction.interface'

export interface IBlockscoutAddressParam {
hash: string
implementation_name: string
name: string
is_contract: boolean
private_tags: IAddressTag[]
watchlist_names: IWatchlistName[]
public_tags: IAddressTag[]
is_verified: boolean
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NftStandard } from '@core/nfts/enums'
import { TokenStandard } from '@core/token/enums'
import { IBlockscoutAsset } from './blockscout-asset.interface'
import { IBlockscoutAssetMetadata } from './blockscout-asset-metadata.interface'
import { IBlockscoutTokenInfo } from './blockscout-token-info.interface'
import { IBlockscoutTransaction } from './blockscout-transaction.interface'

export interface IBlockscoutApi {
getAssetMetadata(assetAddress: string): Promise<IBlockscoutAssetMetadata | undefined>
getAssetMetadata(assetAddress: string): Promise<IBlockscoutTokenInfo | undefined>
getAssetsForAddress(
address: string,
tokenStandard?: TokenStandard.Erc20 | NftStandard.Erc721
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IBlockscoutAssetMetadata } from './blockscout-asset-metadata.interface'
import { IBlockscoutTokenInfo } from './blockscout-token-info.interface'

// snake_case returned by the API
export interface IBlockscoutAsset {
token: IBlockscoutAssetMetadata
token: IBlockscoutTokenInfo
token_id: string
token_instance: unknown
value: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// snake_case returned by the API
export interface IBlockscoutAssetMetadata {
export interface IBlockscoutTokenInfo {
address: string
circulating_market_cap: string
decimals: number
Expand Down
Loading

0 comments on commit 468e299

Please sign in to comment.