diff --git a/packages/desktop/components/NetworkCard.svelte b/packages/desktop/components/NetworkCard.svelte index 6f0b6d29d3..61641ea492 100644 --- a/packages/desktop/components/NetworkCard.svelte +++ b/packages/desktop/components/NetworkCard.svelte @@ -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, diff --git a/packages/desktop/components/popups/ActivityDetailsPopup.svelte b/packages/desktop/components/popups/ActivityDetailsPopup.svelte index a0eb5c879c..ccd894dc17 100644 --- a/packages/desktop/components/popups/ActivityDetailsPopup.svelte +++ b/packages/desktop/components/popups/ActivityDetailsPopup.svelte @@ -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' @@ -35,8 +34,6 @@ export let activityId: string export let _onMount: (..._: any[]) => Promise = async () => {} - const explorerUrl = getDefaultExplorerUrl($activeProfile?.network?.id) - $: activity = $selectedAccountActivities.find((_activity) => _activity.id === activityId) $: isTimelocked = activity?.asyncData?.asyncStatus === ActivityAsyncStatus.Timelocked $: isActivityIncomingAndUnclaimed = @@ -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) @@ -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 { + async function onClaimClick(_activity: Activity): Promise { await checkActiveProfileAuth( async () => { - await claimActivity(activity) + await claimActivity(_activity) openPopup({ id: PopupId.ActivityDetails, props: { activityId }, @@ -118,52 +116,54 @@ }) - -
- - {title} - - {#if explorerUrl && activity?.transactionId} - - {:else if activity?.transactionId} - - {/if} -
- - +{#if activity} + +
+ + {title} + + {#if explorerUrl && activity.transactionId} + + {:else if activity.transactionId} + + {/if} +
+ + - + - - - {#if !isTimelocked && isActivityIncomingAndUnclaimed} - - - - - {/if} -
+ +
+ {#if !isTimelocked && isActivityIncomingAndUnclaimed} + + + + + {/if} +
+{/if} diff --git a/packages/desktop/components/popups/Popup.svelte b/packages/desktop/components/popups/Popup.svelte index d4d78b5086..2b22de26a0 100644 --- a/packages/desktop/components/popups/Popup.svelte +++ b/packages/desktop/components/popups/Popup.svelte @@ -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' @@ -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, diff --git a/packages/desktop/components/popups/SignMessagePopup.svelte b/packages/desktop/components/popups/SignMessagePopup.svelte new file mode 100644 index 0000000000..43501aa6f6 --- /dev/null +++ b/packages/desktop/components/popups/SignMessagePopup.svelte @@ -0,0 +1,103 @@ + + +
+ + {localize('popups.signMessage.title')} + +
+
+ {localize('popups.signMessage.message')} + {message} + {#if dapp} +
+
+ {dapp.metadata?.name} + + {dapp.metadata?.name} + +
+
+ {/if} +
+
+ + + {address} + +
+ {#if dapp} + + {:else} + + {/if} +
+ + + + +
diff --git a/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts b/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts index c2d0f5d058..3355cbf34d 100644 --- a/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts +++ b/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts @@ -35,6 +35,7 @@ export enum PopupId { RemoveNode = 'removeNode', RemoveProposal = 'removeProposal', Revote = 'revote', + SignMessage = 'signMessage', SendFlow = 'sendFlow', StopVoting = 'stopVoting', BalanceBreakdown = 'balanceBreakdown', diff --git a/packages/desktop/views/dashboard/collectibles/views/CollectiblesDetailsView.svelte b/packages/desktop/views/dashboard/collectibles/views/CollectiblesDetailsView.svelte index 8a9b68e8a1..599765b570 100644 --- a/packages/desktop/views/dashboard/collectibles/views/CollectiblesDetailsView.svelte +++ b/packages/desktop/views/dashboard/collectibles/views/CollectiblesDetailsView.svelte @@ -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' @@ -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 } = @@ -155,7 +154,7 @@ } function onExplorerClick(): void { - openUrlInBrowser(`${explorerUrl}/${ExplorerEndpoint.Nft}/${id}`) + openUrlInBrowser(`${explorerUrl}/${id}`) } function onSendClick(): void { diff --git a/packages/desktop/views/dashboard/send-flow/views/components/DateTimePicker.svelte b/packages/desktop/views/dashboard/send-flow/views/components/DateTimePicker.svelte index 93e4476dc1..ebf506f1ac 100644 --- a/packages/desktop/views/dashboard/send-flow/views/components/DateTimePicker.svelte +++ b/packages/desktop/views/dashboard/send-flow/views/components/DateTimePicker.svelte @@ -1,6 +1,6 @@ - - - -
- - -
-
- - diff --git a/packages/shared/src/components/inputs/ExpirationDateTimePicker.svelte b/packages/shared/src/components/inputs/ExpirationDateTimePicker.svelte index 93e4476dc1..ebf506f1ac 100644 --- a/packages/shared/src/components/inputs/ExpirationDateTimePicker.svelte +++ b/packages/shared/src/components/inputs/ExpirationDateTimePicker.svelte @@ -1,6 +1,6 @@ {#if hasPills} - {#if activity.asyncData?.asyncStatus && activity?.asyncData?.asyncStatus !== ActivityAsyncStatus.Timelocked} + {#if activity.asyncData?.asyncStatus && activity.asyncData?.asyncStatus !== ActivityAsyncStatus.Timelocked} {/if} {#if isTimelocked} {/if} - {#if activity?.parsedLayer2Metadata} + {#if activity.parsedLayer2Metadata} {localize('pills.smartContract')} diff --git a/packages/shared/src/components/tiles/ActivityTile.svelte b/packages/shared/src/components/tiles/ActivityTile.svelte index 55c5870f07..f3697e48a0 100644 --- a/packages/shared/src/components/tiles/ActivityTile.svelte +++ b/packages/shared/src/components/tiles/ActivityTile.svelte @@ -31,7 +31,7 @@ if (persistedToken?.verification?.status === NotVerifiedStatus.New) { const token: IToken = { ...persistedToken, - networkId: activity.networkId, + networkId: activity.sourceNetworkId, balance: { total: 0, available: 0, diff --git a/packages/shared/src/components/tiles/tileContents/TransactionActivityTileContent.svelte b/packages/shared/src/components/tiles/tileContents/TransactionActivityTileContent.svelte index def1cdb132..e5413cd774 100644 --- a/packages/shared/src/components/tiles/tileContents/TransactionActivityTileContent.svelte +++ b/packages/shared/src/components/tiles/tileContents/TransactionActivityTileContent.svelte @@ -34,6 +34,6 @@ {#if token} - + {/if} diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_sendTransaction.handler.ts b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_sendTransaction.handler.ts index a4ee38ca58..a8707e7c91 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_sendTransaction.handler.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_sendTransaction.handler.ts @@ -1,18 +1,17 @@ -import { JsonRpcResponse } from '@walletconnect/jsonrpc-types' +import { CallbackParameters } from '../types' export function handleEthSendTransaction( - id: number, params: unknown, - responseCallback: (response: JsonRpcResponse) => void + responseCallback: (params: CallbackParameters) => void ): void { if (!params || !Array.isArray(params)) { - responseCallback({ id, error: { code: 5000, message: 'Error' }, jsonrpc: '2.0' }) + responseCallback({ error: 'Error' }) return } const transactionObject = params[0] if (!transactionObject || typeof transactionObject !== 'object') { - responseCallback({ id, error: { code: 5000, message: 'Error' }, jsonrpc: '2.0' }) + responseCallback({ error: 'Error' }) return } diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/onSessionRequest.handler.ts b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/onSessionRequest.handler.ts index 89fbd7c90e..2fa2a3eee0 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/onSessionRequest.handler.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/onSessionRequest.handler.ts @@ -5,21 +5,51 @@ import { handleEthSignTypedData } from './eth_signTypedData.handler' import { handlePersonalSign } from './personal_sign.handler' import { JsonRpcResponse } from '@walletconnect/jsonrpc-types' import { Web3WalletTypes } from '@walletconnect/web3wallet' -import { getWalletClient } from '../stores' +import { getConnectedDappByOrigin, getWalletClient } from '../stores' +import { NetworkId, SupportedNetworkId, getNetwork } from '@core/network' +import { CallbackParameters } from '../types' export function onSessionRequest(event: Web3WalletTypes.SessionRequest): void { - const { topic, params, id } = event - const { request } = params - // TODO: to access the chain for which we want to do the action: params.chainId + const { topic, params, id, verifyContext } = event + const { request, chainId } = params const method = request.method - function returnResponse(response: JsonRpcResponse): void { - void getWalletClient()?.respondSessionRequest({ topic, response }) + const dapp = getConnectedDappByOrigin(verifyContext.verified.origin) + + function returnResponse({ result, error }: CallbackParameters): void { + const response: JsonRpcResponse | undefined = result + ? { + id, + result, + jsonrpc: '2.0', + } + : error + ? { + id, + error: { + code: 5000, + message: error, + }, + jsonrpc: '2.0', + } + : undefined + + if (response) { + void getWalletClient()?.respondSessionRequest({ topic, response }) + } + } + + // TODO: the commented code is the correct one, but as long as there are no shimmerevm dapps, we need to hardcode it + // const chain = getNetwork()?.getChain(chainId as NetworkId) + const chain = getNetwork()?.getChain(SupportedNetworkId.ShimmerEvmTestnet ?? (chainId as NetworkId)) + if (!chain) { + returnResponse({ error: 'Chain not supported' }) + return } switch (method) { case 'eth_sendTransaction': - handleEthSendTransaction(id, request.params, returnResponse) + handleEthSendTransaction(request.params, returnResponse) break case 'eth_signTransaction': handleEthSignTransaction() @@ -28,7 +58,7 @@ export function onSessionRequest(event: Web3WalletTypes.SessionRequest): void { handleEthSign() break case 'personal_sign': - handlePersonalSign(id, request.params, returnResponse) + handlePersonalSign(request.params, dapp, chain, returnResponse) break case 'eth_signTypedData': handleEthSignTypedData() diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/personal_sign.handler.ts b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/personal_sign.handler.ts index 5695b2ddde..879d1e9155 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/personal_sign.handler.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/personal_sign.handler.ts @@ -1,45 +1,43 @@ import { Converter } from '@iota/util.js' -import { closePopup, openPopup, PopupId } from '../../../../../../desktop/lib/auxiliary/popup' -import { JsonRpcResponse } from '@walletconnect/jsonrpc-types' +import { openPopup, PopupId } from '../../../../../../desktop/lib/auxiliary/popup' +import { IConnectedDapp } from '../interface' +import { findActiveAccountWithAddress } from '@core/profile/actions' +import { IChain } from '@core/network' +import { CallbackParameters } from '../types' export function handlePersonalSign( - id: number, params: unknown, - responseCallback: (response: JsonRpcResponse) => void + dapp: IConnectedDapp | undefined, + chain: IChain, + responseCallback: (params: CallbackParameters) => void ): void { if (!params || !Array.isArray(params)) { - responseCallback({ id, error: { code: 5000, message: 'Error' }, jsonrpc: '2.0' }) + responseCallback({ error: 'Unexpected format' }) return } const hexMessage = params[0] - // to access the address for which we want to do the action = params[1] - if (typeof hexMessage !== 'string') { - responseCallback({ id, error: { code: 5000, message: 'Error' }, jsonrpc: '2.0' }) + responseCallback({ error: 'Unexpected message' }) return } + const account = findActiveAccountWithAddress(params[1], chain.getConfiguration().id) + if (!account) { + responseCallback({ error: 'Could not find address' }) + return + } const message = Converter.hexToUtf8(hexMessage) - // sign the message - // const signedMessage = await wallet.signMessage(message) - - const signedMessage = 'hello this is signed' - const response = { id, result: signedMessage, jsonrpc: '2.0' } openPopup({ - id: PopupId.Confirmation, + id: PopupId.SignMessage, props: { - title: 'Personal Sign', - description: 'Do you wanna sign the following message: ' + message, - onConfirm: () => { - responseCallback(response) - closePopup() - }, - onCancel: () => { - responseCallback({ id, error: { code: 5000, message: 'User rejected' }, jsonrpc: '2.0' }) - closePopup() - }, + message, + dapp, + account, + chain, + callback: responseCallback, + onCancelled: () => responseCallback({ error: 'User rejected' }), }, }) } diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/stores/connected-dapps.store.ts b/packages/shared/src/lib/auxiliary/wallet-connect/stores/connected-dapps.store.ts index d044cd28a4..3ac61ebba4 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/stores/connected-dapps.store.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/stores/connected-dapps.store.ts @@ -20,3 +20,7 @@ export function setConnectedDapps(): void { export function getConnectedDapps(): IConnectedDapp[] { return get(connectedDapps) } + +export function getConnectedDappByOrigin(origin: string): IConnectedDapp | undefined { + return get(connectedDapps).find((dapp) => dapp.metadata?.url === origin) +} diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/types/callback-parameters.type.ts b/packages/shared/src/lib/auxiliary/wallet-connect/types/callback-parameters.type.ts new file mode 100644 index 0000000000..f849e6a62f --- /dev/null +++ b/packages/shared/src/lib/auxiliary/wallet-connect/types/callback-parameters.type.ts @@ -0,0 +1 @@ +export type CallbackParameters = { result?: unknown; error?: string } diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/types/index.ts b/packages/shared/src/lib/auxiliary/wallet-connect/types/index.ts new file mode 100644 index 0000000000..8302d8e486 --- /dev/null +++ b/packages/shared/src/lib/auxiliary/wallet-connect/types/index.ts @@ -0,0 +1 @@ +export * from './callback-parameters.type' diff --git a/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts b/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts index 97069577bf..0908dae4cb 100644 --- a/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts +++ b/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts @@ -6,10 +6,11 @@ import { preprocessTransactionsForAccount } from './preprocessTransactionsForAcc import { preprocessOutputsForAccount } from './preprocessOutputsForAccount' import { linkTransactionsWithClaimingTransactions } from './linkTransactionsWithClaimingTransactions' import { hideActivitiesForFoundries } from './hideActivitiesForFoundries' -import { generateActivitiesFromProcessedTransactions } from './generateActivitiesFromProcessedTransactions' +import { generateActivitiesFromProcessedTransactions } from '../utils/generateActivitiesFromProcessedTransactions' import { loadAssetsForAllActivities } from './loadAssetsForAllAccounts' -import { generateActivitiesFromBalanceChanges, setOutgoingAsyncActivitiesToClaimed } from '@core/activity/actions' +import { generateActivitiesFromBalanceChanges, generateActivitiesFromChains } from '../utils' import { NetworkId } from '@core/network' +import { setOutgoingAsyncActivitiesToClaimed } from './setOutgoingAsyncActivitiesToClaimed' export async function generateAndStoreActivitiesForAccount( account: IAccountState, @@ -27,9 +28,11 @@ export async function generateAndStoreActivitiesForAccount( // Step 3: generate activities from processed transactions const activities = generateActivitiesFromProcessedTransactions(linkedProcessedTransactions, account, networkId) const balanceChangeActivities = generateActivitiesFromBalanceChanges(account) - activities.push(...balanceChangeActivities) + const chainActivities = await generateActivitiesFromChains(account) + activities.push(...chainActivities) + // Step 4: set account activities with generated activities setAccountActivitiesInAllAccountActivities(account.index, activities) diff --git a/packages/shared/src/lib/core/activity/actions/index.ts b/packages/shared/src/lib/core/activity/actions/index.ts index c38a675acf..746dadb3e5 100644 --- a/packages/shared/src/lib/core/activity/actions/index.ts +++ b/packages/shared/src/lib/core/activity/actions/index.ts @@ -1,5 +1,4 @@ export * from './calculateAndAddPersistedBalanceChange' -export * from './generateActivitiesFromBalanceChanges' export * from './generateAndStoreActivitiesForAccount' export * from './generateAndStoreActivitiesForAllAccounts' export * from './hideActivitiesForFoundries' diff --git a/packages/shared/src/lib/core/activity/types/base-activity.type.ts b/packages/shared/src/lib/core/activity/types/base-activity.type.ts index bdc12a3e81..4816c0d892 100644 --- a/packages/shared/src/lib/core/activity/types/base-activity.type.ts +++ b/packages/shared/src/lib/core/activity/types/base-activity.type.ts @@ -16,13 +16,14 @@ export type BaseActivity = { action: ActivityAction isInternal: boolean storageDeposit: number + gasUsed?: number rawBaseCoinAmount?: number subject: Subject | undefined metadata?: string tag?: string - networkId: NetworkId + sourceNetworkId: NetworkId + destinationNetworkId: NetworkId asyncData?: AsyncData - destinationNetwork?: string parsedLayer2Metadata?: Layer2Metadata } @@ -32,6 +33,6 @@ export type AsyncData = { expirationDate: Date isRejected: boolean isClaiming: boolean - claimingTransactionId: string - claimedDate: Date + claimingTransactionId?: string + claimedDate?: Date } diff --git a/packages/shared/src/lib/core/activity/types/sender-info.type.ts b/packages/shared/src/lib/core/activity/types/sender-info.type.ts index b4335e2e36..f897096019 100644 --- a/packages/shared/src/lib/core/activity/types/sender-info.type.ts +++ b/packages/shared/src/lib/core/activity/types/sender-info.type.ts @@ -1,6 +1,8 @@ import { Subject } from '@core/wallet/types' export type SenderInfo = { + sender: Subject | undefined + recipient: Subject subject: Subject | undefined isInternal: boolean } diff --git a/packages/shared/src/lib/core/activity/actions/generateActivitiesFromBalanceChanges.ts b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromBalanceChanges.ts similarity index 92% rename from packages/shared/src/lib/core/activity/actions/generateActivitiesFromBalanceChanges.ts rename to packages/shared/src/lib/core/activity/utils/generateActivitiesFromBalanceChanges.ts index c985c82adb..2ea7d06e0b 100644 --- a/packages/shared/src/lib/core/activity/actions/generateActivitiesFromBalanceChanges.ts +++ b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromBalanceChanges.ts @@ -3,7 +3,7 @@ import { Activity } from '../types' import { getBalanceChanges } from '../stores' import { get } from 'svelte/store' import { network } from '@core/network' -import { generateBalanceChangeActivity } from '../utils' +import { generateBalanceChangeActivity } from './generateBalanceChangeActivity' export function generateActivitiesFromBalanceChanges(account: IAccountState): Activity[] { const activities: Activity[] = [] diff --git a/packages/shared/src/lib/core/activity/utils/generateActivitiesFromChains.ts b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromChains.ts new file mode 100644 index 0000000000..128dd28bf9 --- /dev/null +++ b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromChains.ts @@ -0,0 +1,23 @@ +import { IAccountState } from '@core/account' +import { Activity } from '../types' +import { getPersistedEvmTransactions } from '../stores' +import { generateActivityFromEvmTransaction } from './generateActivityFromEvmTransaction' +import { get } from 'svelte/store' +import { network } from '@core/network' + +export async function generateActivitiesFromChains(account: IAccountState): Promise { + const activities: Activity[] = [] + + const chains = get(network)?.getChains() ?? [] + for (const chain of chains) { + const networkId = chain.getConfiguration().id + + const transactions = getPersistedEvmTransactions(account.index, networkId) + for (const transaction of transactions) { + const activity = await generateActivityFromEvmTransaction(transaction, networkId, chain.getProvider()) + activities.push(activity) + } + } + + return activities +} diff --git a/packages/shared/src/lib/core/activity/actions/generateActivitiesFromProcessedTransactions.ts b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromProcessedTransactions.ts similarity index 93% rename from packages/shared/src/lib/core/activity/actions/generateActivitiesFromProcessedTransactions.ts rename to packages/shared/src/lib/core/activity/utils/generateActivitiesFromProcessedTransactions.ts index 194cb497b0..0988a949ec 100644 --- a/packages/shared/src/lib/core/activity/actions/generateActivitiesFromProcessedTransactions.ts +++ b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromProcessedTransactions.ts @@ -1,6 +1,6 @@ import { IAccountState } from '@core/account' import { Activity, IProcessedTransaction } from '../types' -import { generateActivities } from '../utils' +import { generateActivities } from '.' import { NetworkId } from '@core/network/types' export function generateActivitiesFromProcessedTransactions( diff --git a/packages/shared/src/lib/core/activity/utils/generateActivityFromEvmTransaction.ts b/packages/shared/src/lib/core/activity/utils/generateActivityFromEvmTransaction.ts new file mode 100644 index 0000000000..46d3187654 --- /dev/null +++ b/packages/shared/src/lib/core/activity/utils/generateActivityFromEvmTransaction.ts @@ -0,0 +1,38 @@ +import { PersistedEvmTransaction, TransactionActivity } from '../types' +import { ActivityAction, ActivityDirection, ActivityType, InclusionState } from '../enums' +import { getCoinType } from '@core/profile/actions' +import { getSubjectFromAddress } from '@core/wallet' +import { WEI_PER_GLOW } from '@core/layer-2' +import Web3 from 'web3' +import { NetworkId } from '@core/network/types' + +export async function generateActivityFromEvmTransaction( + transaction: PersistedEvmTransaction, + networkId: NetworkId, + provider: Web3 +): Promise { + const direction = ActivityDirection.Outgoing // Currently only sent transactions are supported + + const subject = getSubjectFromAddress(transaction.to, networkId) + const timestamp = (await provider.eth.getBlock(transaction.blockNumber)).timestamp + return { + type: ActivityType.Basic, + id: transaction.transactionHash, + transactionId: transaction.transactionHash, + time: new Date(Number(timestamp) * 1000), + inclusionState: InclusionState.Confirmed, + containsValue: true, + isAssetHidden: false, + direction, + action: ActivityAction.Send, + isInternal: false, + storageDeposit: 0, + gasUsed: transaction.gasUsed, + subject, + rawBaseCoinAmount: Number(transaction.value) / Number(WEI_PER_GLOW), + rawAmount: Number(transaction.value) / Number(WEI_PER_GLOW), + tokenId: getCoinType(), + sourceNetworkId: networkId, + destinationNetworkId: networkId, + } +} diff --git a/packages/shared/src/lib/core/activity/utils/generateBalanceChangeActivity.ts b/packages/shared/src/lib/core/activity/utils/generateBalanceChangeActivity.ts index 8073d49d0a..240c0d1a08 100644 --- a/packages/shared/src/lib/core/activity/utils/generateBalanceChangeActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateBalanceChangeActivity.ts @@ -28,6 +28,7 @@ export function generateBalanceChangeActivity( rawBaseCoinAmount: Math.abs(difference), rawAmount: Math.abs(difference), tokenId: tokenId === '0x' ? getCoinType() : tokenId, - networkId, + sourceNetworkId: networkId, + destinationNetworkId: networkId, } } diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleAliasActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleAliasActivity.ts index 47435d81f5..c9b1d2413e 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleAliasActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleAliasActivity.ts @@ -59,7 +59,8 @@ export function generateSingleAliasActivity( time, metadata, tag, - networkId, + sourceNetworkId: networkId, + destinationNetworkId: networkId, inclusionState, containsValue, asyncData, diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts index 5ab2c5dd1a..ed5ce1f0c8 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts @@ -1,6 +1,9 @@ import { isShimmerClaimingTransaction } from '@contexts/onboarding/stores' import { IAccountState } from '@core/account' import { IActivityGenerationParameters } from '@core/activity/types' +import { parseLayer2Metadata } from '@core/layer-2' +import { getNetworkIdFromAddress } from '@core/layer-2/actions' +import { NetworkId } from '@core/network/types' import { getCoinType } from '@core/profile/actions' import { activeProfileId } from '@core/profile/stores' import { IBasicOutput } from '@iota/types' @@ -17,7 +20,6 @@ import { getTagFromOutput, } from './helper' import { getNativeTokenFromOutput } from './outputs' -import { NetworkId } from '@core/network/types' export function generateSingleBasicActivity( account: IAccountState, @@ -43,12 +45,19 @@ export function generateSingleBasicActivity( const metadata = getMetadataFromOutput(output) const publicNote = '' - const sendingInfo = getSendingInformation(processedTransaction, output, account, networkId) + const { sender, recipient, subject, isInternal } = getSendingInformation( + processedTransaction, + output, + account, + networkId + ) + const sourceNetworkId = getNetworkIdFromAddress(sender?.address, networkId) + const destinationNetworkId = getNetworkIdFromAddress(recipient?.address, sourceNetworkId) + const asyncData = getAsyncDataFromOutput(output, outputId, claimingData, account) + const parsedLayer2Metadata = parseLayer2Metadata(metadata) - // const { parsedLayer2Metadata, destinationNetwork } = getLayer2ActivityInformation(metadata, sendingInfo) - // const gasLimit = Number(parsedLayer2Metadata?.gasLimit ?? '0') - const gasLimit = 0 + const gasLimit = Number(parsedLayer2Metadata?.gasLimit ?? '0') const storageDeposit = getStorageDepositFromOutput(output) @@ -83,11 +92,12 @@ export function generateSingleBasicActivity( publicNote, metadata, tag, - networkId, + sourceNetworkId, + destinationNetworkId, tokenId, asyncData, - // destinationNetwork, - // parsedLayer2Metadata, - ...sendingInfo, + parsedLayer2Metadata, + subject, + isInternal, } } diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleConsolidationActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleConsolidationActivity.ts index 7882a2dc49..b98dd32497 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleConsolidationActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleConsolidationActivity.ts @@ -54,7 +54,8 @@ export function generateSingleConsolidationActivity( storageDeposit, metadata, tag, - networkId, + sourceNetworkId: networkId, + destinationNetworkId: networkId, asyncData, amountConsolidatedInputs, ...sendingInfo, diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleFoundryActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleFoundryActivity.ts index 8d146fe143..e2f4166715 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleFoundryActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleFoundryActivity.ts @@ -70,7 +70,8 @@ export function generateSingleFoundryActivity( isHidden, metadata, tag, - networkId, + sourceNetworkId: networkId, + destinationNetworkId: networkId, asyncData, ...sendingInfo, } diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleGovernanceActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleGovernanceActivity.ts index 3b404e6d59..894b4a7dc4 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleGovernanceActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleGovernanceActivity.ts @@ -52,7 +52,8 @@ export function generateSingleGovernanceActivity( storageDeposit, metadata, tag, - networkId, + sourceNetworkId: networkId, + destinationNetworkId: networkId, asyncData: undefined, ...governanceInfo, ...sendingInfo, diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts index 8a59f56daf..ffcb956f25 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts @@ -1,19 +1,20 @@ import { IAccountState } from '@core/account' +import { parseLayer2Metadata } from '@core/layer-2' +import { getNetworkIdFromAddress } from '@core/layer-2/actions' +import { NetworkId } from '@core/network/types' +import type { INftOutput } from '@iota/types' import { ActivityType } from '../enums' import { NftActivity } from '../types' -import type { INftOutput } from '@iota/types' +import { IActivityGenerationParameters } from '../types/activity-generation-parameters.interface' import { getAmountFromOutput, getAsyncDataFromOutput, - getLayer2ActivityInformation, getMetadataFromOutput, getSendingInformation, getStorageDepositFromOutput, getTagFromOutput, } from './helper' -import { IActivityGenerationParameters } from '../types/activity-generation-parameters.interface' import { getNftId } from './outputs' -import { NetworkId } from '@core/network/types' export function generateSingleNftActivity( account: IAccountState, @@ -34,15 +35,20 @@ export function generateSingleNftActivity( const metadata = getMetadataFromOutput(output) const tag = getTagFromOutput(output) - const sendingInfo = getSendingInformation(processedTransaction, output, account, networkId) - const { subject, isInternal } = sendingInfo - const rawBaseCoinAmount = getAmountFromOutput(output) const storageDeposit = getStorageDepositFromOutput(output) - const layer2ActivityInformation = getLayer2ActivityInformation(metadata, sendingInfo) + const { sender, recipient, subject, isInternal } = getSendingInformation( + processedTransaction, + output, + account, + networkId + ) + const sourceNetworkId = getNetworkIdFromAddress(sender?.address, networkId) + const destinationNetworkId = getNetworkIdFromAddress(recipient?.address, sourceNetworkId) const asyncData = getAsyncDataFromOutput(output, outputId, claimingData, account) + const parsedLayer2Metadata = parseLayer2Metadata(metadata) return { type: ActivityType.Nft, @@ -50,7 +56,8 @@ export function generateSingleNftActivity( transactionId, outputId, nftId, - networkId, + sourceNetworkId, + destinationNetworkId: destinationNetworkId, time, isHidden, action, @@ -65,6 +72,6 @@ export function generateSingleNftActivity( subject, isInternal, direction, - ...layer2ActivityInformation, + parsedLayer2Metadata, } } diff --git a/packages/shared/src/lib/core/activity/utils/getTransactionAssets.ts b/packages/shared/src/lib/core/activity/utils/getTransactionAssets.ts index 0c91b0bd47..1f731860ad 100644 --- a/packages/shared/src/lib/core/activity/utils/getTransactionAssets.ts +++ b/packages/shared/src/lib/core/activity/utils/getTransactionAssets.ts @@ -19,7 +19,7 @@ export function getTransactionAssets( } | undefined { if (activity.type === ActivityType.Nft) { - const baseCoin = getTokenFromSelectedAccountTokens(getCoinType(), activity.networkId) + const baseCoin = getTokenFromSelectedAccountTokens(getCoinType(), activity.sourceNetworkId) const nft = getNftByIdFromAllAccountNfts(accountIndex, activity.nftId) return { nft, @@ -29,10 +29,10 @@ export function getTransactionAssets( }, } } else if (activity.type === ActivityType.Basic || activity.type === ActivityType.Foundry) { - const tokenWithBalance = getTokenFromSelectedAccountTokens(activity.tokenId, activity.networkId) + const tokenWithBalance = getTokenFromSelectedAccountTokens(activity.tokenId, activity.sourceNetworkId) const persistedToken = getPersistedToken(activity.tokenId) const token: IToken = { - networkId: activity.networkId, + networkId: activity.sourceNetworkId, balance: { total: 0, available: 0, @@ -48,7 +48,7 @@ export function getTransactionAssets( }, } } else { - const baseCoin = getTokenFromSelectedAccountTokens(getCoinType(), activity.networkId) + const baseCoin = getTokenFromSelectedAccountTokens(getCoinType(), activity.sourceNetworkId) return { tokenTransfer: { rawAmount: String(activity.rawAmount), @@ -61,7 +61,7 @@ export function getTransactionAssets( } } } else if (activity.type === ActivityType.Governance) { - const baseCoin = getTokenFromSelectedAccountTokens(getCoinType(), activity.networkId) + const baseCoin = getTokenFromSelectedAccountTokens(getCoinType(), activity.sourceNetworkId) const isVotingPowerActivity = activity.governanceAction === GovernanceAction.DecreaseVotingPower || diff --git a/packages/shared/src/lib/core/activity/utils/helper/getAsyncDataFromOutput.ts b/packages/shared/src/lib/core/activity/utils/helper/getAsyncDataFromOutput.ts index f9f15f9278..d3d586d182 100644 --- a/packages/shared/src/lib/core/activity/utils/helper/getAsyncDataFromOutput.ts +++ b/packages/shared/src/lib/core/activity/utils/helper/getAsyncDataFromOutput.ts @@ -10,9 +10,9 @@ import { AsyncData, IClaimData } from '@core/activity/types' export function getAsyncDataFromOutput( output: Output, outputId: string, - claimingData: IClaimData, + claimingData: IClaimData | undefined, account: IAccountState -): AsyncData { +): AsyncData | undefined { const isAsync = isOutputAsync(output) if (isAsync) { const isClaiming = false @@ -42,6 +42,6 @@ export function getAsyncDataFromOutput( claimedDate, } } else { - return null + return undefined } } diff --git a/packages/shared/src/lib/core/activity/utils/helper/getLayer2ActivityInformation.ts b/packages/shared/src/lib/core/activity/utils/helper/getLayer2ActivityInformation.ts deleted file mode 100644 index 51b1c1ab48..0000000000 --- a/packages/shared/src/lib/core/activity/utils/helper/getLayer2ActivityInformation.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { parseLayer2Metadata } from '@core/layer-2/utils' -import { getDestinationNetworkFromAddress } from '@core/layer-2/actions' -import { Layer2Metadata } from '@core/layer-2/types' -import { SenderInfo } from '../../types' -import { SubjectType } from '@core/wallet/enums' - -export function getLayer2ActivityInformation( - metadata: string, - sendingInfo: SenderInfo -): { - parsedLayer2Metadata: Layer2Metadata | undefined - destinationNetwork: string -} { - let parsedLayer2Metadata: Layer2Metadata | undefined - let destinationNetwork: string - try { - parsedLayer2Metadata = parseLayer2Metadata(metadata) - destinationNetwork = getDestinationNetworkFromAddress( - sendingInfo.subject?.type === SubjectType.Address ? sendingInfo.subject.address : undefined - ) - } catch (_err) { - parsedLayer2Metadata = undefined - destinationNetwork = getDestinationNetworkFromAddress(undefined) - } - return { - parsedLayer2Metadata, - destinationNetwork, - } -} diff --git a/packages/shared/src/lib/core/activity/utils/helper/getSendingInformation.ts b/packages/shared/src/lib/core/activity/utils/helper/getSendingInformation.ts index 3b17ca5124..04b5826cec 100644 --- a/packages/shared/src/lib/core/activity/utils/helper/getSendingInformation.ts +++ b/packages/shared/src/lib/core/activity/utils/helper/getSendingInformation.ts @@ -25,6 +25,8 @@ export function getSendingInformation( const isInternal = isSubjectInternal(subject) return { + sender, + recipient, subject, isInternal, } diff --git a/packages/shared/src/lib/core/activity/utils/helper/index.ts b/packages/shared/src/lib/core/activity/utils/helper/index.ts index 4f39f92b18..c39fd97a1e 100644 --- a/packages/shared/src/lib/core/activity/utils/helper/index.ts +++ b/packages/shared/src/lib/core/activity/utils/helper/index.ts @@ -5,7 +5,6 @@ export * from './getAmountFromOutput' export * from './getSendingInformation' export * from './getGovernanceInfo' export * from './getGovernorAddressFromAliasOutput' -export * from './getLayer2ActivityInformation' export * from './getMetadataFromOutput' export * from './getStateControllerAddressFromAliasOutput' export * from './getStorageDepositFromOutput' diff --git a/packages/shared/src/lib/core/activity/utils/index.ts b/packages/shared/src/lib/core/activity/utils/index.ts index bb13a4f855..eba4c29621 100644 --- a/packages/shared/src/lib/core/activity/utils/index.ts +++ b/packages/shared/src/lib/core/activity/utils/index.ts @@ -1,9 +1,12 @@ export * from './activityOutputContainsValue' export * from './generateActivities' export * from './generateActivitiesFromAliasOutputs' +export * from './generateActivitiesFromBalanceChanges' export * from './generateActivitiesFromBasicOutputs' +export * from './generateActivitiesFromChains' export * from './generateActivitiesFromFoundryOutputs' export * from './generateActivitiesFromNftOutputs' +export * from './generateActivitiesFromProcessedTransactions' export * from './generateBalanceChangeActivity' export * from './generateSingleAliasActivity' export * from './generateSingleBasicActivity' diff --git a/packages/shared/src/lib/core/app/constants/external-allowed-links.constant.ts b/packages/shared/src/lib/core/app/constants/external-allowed-links.constant.ts index a9c4061922..0da43a43d7 100644 --- a/packages/shared/src/lib/core/app/constants/external-allowed-links.constant.ts +++ b/packages/shared/src/lib/core/app/constants/external-allowed-links.constant.ts @@ -15,6 +15,7 @@ export const externalAllowedLinks = [ 'assembly.sc', 'shimmer.network', 'explorer.shimmer.network', + 'explorer.evm.testnet.shimmer.network', // GitHub 'github.com/iotaledger/firefly/issues', diff --git a/packages/shared/src/lib/core/layer-2/actions/getDestinationNetworkFromAddress.ts b/packages/shared/src/lib/core/layer-2/actions/getDestinationNetworkFromAddress.ts deleted file mode 100644 index 1067ef0627..0000000000 --- a/packages/shared/src/lib/core/layer-2/actions/getDestinationNetworkFromAddress.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { isIscpChain } from '@core/network' -import { getActiveProfile } from '@core/profile/stores' - -export function getDestinationNetworkFromAddress(networkAddress: string | undefined): string { - const { network } = getActiveProfile() ?? {} - if (!networkAddress) { - return network?.name - } - - const chainConfigurations = network?.chainConfigurations.filter(isIscpChain) - const foundDestinationNetwork = chainConfigurations.find((chain) => chain?.aliasAddress === networkAddress) - return foundDestinationNetwork?.name ?? networkAddress -} diff --git a/packages/shared/src/lib/core/layer-2/actions/getNetworkIdFromAddress.ts b/packages/shared/src/lib/core/layer-2/actions/getNetworkIdFromAddress.ts new file mode 100644 index 0000000000..8375c62fde --- /dev/null +++ b/packages/shared/src/lib/core/layer-2/actions/getNetworkIdFromAddress.ts @@ -0,0 +1,10 @@ +import { IIscpChainConfiguration, NetworkId, getNetwork } from '@core/network' + +export function getNetworkIdFromAddress(networkAddress: string | undefined, fallNetworkId: NetworkId): NetworkId { + const network = getNetwork() + const chains = network?.getIscpChains() + const chain = chains?.find( + (chain) => (chain?.getConfiguration() as IIscpChainConfiguration).aliasAddress === networkAddress + ) + return chain?.getConfiguration().id ?? fallNetworkId +} diff --git a/packages/shared/src/lib/core/layer-2/actions/index.ts b/packages/shared/src/lib/core/layer-2/actions/index.ts index c6fe3ed883..4b2371fb53 100644 --- a/packages/shared/src/lib/core/layer-2/actions/index.ts +++ b/packages/shared/src/lib/core/layer-2/actions/index.ts @@ -4,7 +4,7 @@ export * from './buildUnwrapAssetTargetAddress' export * from './estimateGasForLayer1ToLayer2Transaction' export * from './fetchSelectedAccountLayer2Balance' export * from './generateAndStoreEvmAddressForAccount' -export * from './getDestinationNetworkFromAddress' +export * from './getNetworkIdFromAddress' export * from './getGasFeesForLayer1ToLayer2Transaction' export * from './getGasPriceInWei' export * from './getIscpTransferSmartContractData' diff --git a/packages/shared/src/lib/core/layer-2/utils/parseLayer2Metadata.ts b/packages/shared/src/lib/core/layer-2/utils/parseLayer2Metadata.ts index c511192337..f62628685b 100644 --- a/packages/shared/src/lib/core/layer-2/utils/parseLayer2Metadata.ts +++ b/packages/shared/src/lib/core/layer-2/utils/parseLayer2Metadata.ts @@ -1,10 +1,17 @@ import { Layer2Metadata } from '../types' -export function parseLayer2Metadata(metadata: string): Layer2Metadata { - const parsedData = JSON.parse(metadata) - validate(parsedData) +export function parseLayer2Metadata(metadata: string | undefined): Layer2Metadata | undefined { + if (!metadata) { + return undefined + } + try { + const parsedData = JSON.parse(metadata) + validate(parsedData) - return { ...parsedData } + return { ...parsedData } + } catch (error) { + return undefined + } } function validate(data: Layer2Metadata): void { diff --git a/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts b/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts index 09270d6d48..3c635cbf3d 100644 --- a/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts @@ -5,5 +5,5 @@ export const DEFAULT_EXPLORER_URLS: Readonly<{ [key in NetworkId]?: string }> = [SupportedNetworkId.Shimmer]: 'https://explorer.shimmer.network/shimmer', [SupportedNetworkId.Testnet]: 'https://explorer.shimmer.network/testnet', [SupportedNetworkId.ShimmerEvm]: '', - [SupportedNetworkId.ShimmerEvmTestnet]: 'https://explorer.evm.testnet.shimmer.network/', + [SupportedNetworkId.ShimmerEvmTestnet]: 'https://explorer.evm.testnet.shimmer.network', } diff --git a/packages/shared/src/lib/core/network/constants/explorer-endpoints.constant.ts b/packages/shared/src/lib/core/network/constants/explorer-endpoints.constant.ts new file mode 100644 index 0000000000..0137c44d62 --- /dev/null +++ b/packages/shared/src/lib/core/network/constants/explorer-endpoints.constant.ts @@ -0,0 +1,19 @@ +import { ExplorerEndpoint, SupportedNetworkId } from '../enums' +import { NetworkId } from '../types' + +export const EXPLORER_ENDPOINTS: Readonly<{ [key in NetworkId]?: { [key in ExplorerEndpoint]?: string } }> = { + [SupportedNetworkId.Shimmer]: { + [ExplorerEndpoint.Transaction]: ExplorerEndpoint.Transaction, + [ExplorerEndpoint.Nft]: ExplorerEndpoint.Nft, + }, + [SupportedNetworkId.Testnet]: { + [ExplorerEndpoint.Transaction]: ExplorerEndpoint.Transaction, + [ExplorerEndpoint.Nft]: ExplorerEndpoint.Nft, + }, + [SupportedNetworkId.ShimmerEvm]: { + [ExplorerEndpoint.Transaction]: 'tx', + }, + [SupportedNetworkId.ShimmerEvmTestnet]: { + [ExplorerEndpoint.Transaction]: 'tx', + }, +} diff --git a/packages/shared/src/lib/core/network/constants/index.ts b/packages/shared/src/lib/core/network/constants/index.ts index 70bbec80ae..e1eb7c8507 100644 --- a/packages/shared/src/lib/core/network/constants/index.ts +++ b/packages/shared/src/lib/core/network/constants/index.ts @@ -6,6 +6,7 @@ export * from './default-explorer-urls.constant' export * from './default-network-metadata.constant' export * from './default-node-urls.constant' export * from './empty-node.constant' +export * from './explorer-endpoints.constant' export * from './faucet-urls.constant' export * from './max-chain-name-length.constant' export * from './milestone-not-found.constant' diff --git a/packages/shared/src/lib/core/network/utils/getDefaultExplorerUrl.ts b/packages/shared/src/lib/core/network/utils/getDefaultExplorerUrl.ts index 682fa23c34..d224b9cc90 100644 --- a/packages/shared/src/lib/core/network/utils/getDefaultExplorerUrl.ts +++ b/packages/shared/src/lib/core/network/utils/getDefaultExplorerUrl.ts @@ -1,6 +1,13 @@ -import { DEFAULT_EXPLORER_URLS } from '../constants' +import { DEFAULT_EXPLORER_URLS, EXPLORER_ENDPOINTS } from '../constants' +import { ExplorerEndpoint } from '../enums' import { NetworkId } from '../types' -export function getDefaultExplorerUrl(networkId: NetworkId): string { - return DEFAULT_EXPLORER_URLS?.[networkId] ?? '' +export function getDefaultExplorerUrl(networkId: NetworkId, requestedEndpoint: ExplorerEndpoint): string | undefined { + const baseUrl = DEFAULT_EXPLORER_URLS?.[networkId] + const endpoint = EXPLORER_ENDPOINTS?.[networkId]?.[requestedEndpoint] + if (baseUrl && endpoint) { + return `${baseUrl}/${endpoint}` + } else { + return undefined + } } diff --git a/packages/shared/src/lib/core/wallet/actions/send/sendTransactionFromEvm.ts b/packages/shared/src/lib/core/wallet/actions/send/sendTransactionFromEvm.ts index d6b53945fb..37da407297 100644 --- a/packages/shared/src/lib/core/wallet/actions/send/sendTransactionFromEvm.ts +++ b/packages/shared/src/lib/core/wallet/actions/send/sendTransactionFromEvm.ts @@ -1,11 +1,13 @@ import { getSelectedAccount } from '@core/account/stores' -import { addPersistedTransaction } from '@core/activity/stores' -import { EvmTransactionData } from '@core/layer-2/types' -import { LedgerAppName } from '@core/ledger/enums' -import { IChain } from '@core/network/interfaces' +import { addActivitiesToAccountActivitiesInAllAccountActivities, addPersistedTransaction } from '@core/activity/stores' +import { EvmTransactionData } from '@core/layer-2' +import { LedgerAppName } from '@core/ledger' +import { IChain } from '@core/network' import { checkActiveProfileAuth } from '@core/profile/actions' import { signAndSendEvmTransaction } from './signAndSendEvmTransaction' +import { generateActivityFromEvmTransaction } from '@core/activity/utils/generateActivityFromEvmTransaction' +import { PersistedEvmTransaction } from '@core/activity' export async function sendTransactionFromEvm( transaction: EvmTransactionData, @@ -28,10 +30,15 @@ export async function sendTransactionFromEvm( account ) if (transactionReceipt) { - addPersistedTransaction(account.index, networkId, { + const evmTransaction: PersistedEvmTransaction = { ...transaction, ...transactionReceipt, - }) + } + addPersistedTransaction(account.index, networkId, evmTransaction) + + const activity = await generateActivityFromEvmTransaction(evmTransaction, networkId, provider) + addActivitiesToAccountActivitiesInAllAccountActivities(account.index, [activity]) + if (callback && typeof callback === 'function') { callback() } diff --git a/packages/shared/src/locales/en.json b/packages/shared/src/locales/en.json index 086fd74542..da7d79c03f 100644 --- a/packages/shared/src/locales/en.json +++ b/packages/shared/src/locales/en.json @@ -1087,6 +1087,13 @@ "body": "Help the developers improve Firefly by automatically sending diagnostic data when an error or crash occurs. If selected, this will take effect after restarting Firefly.", "checkbox": "Send crash reports to the IOTA Foundation" }, + "signMessage": { + "title": "Sign message", + "message": "Message", + "hint": "No balance will be sent to {dappName} in the process of signing this message.", + "warning": "dApp cannot be determined. No balance will be sent in the process of signing this message.", + "action": "Sign message" + }, "activityDetails": { "title": { "fallback": "Activity details", @@ -1728,6 +1735,7 @@ "transactionTime": "Transaction time", "surplus": "Surplus", "storageDeposit": "Storage deposit", + "gasFee": "Gas fee", "giftedStorageDeposit": "Gifted storage deposit", "storageDepositPerNft": "Storage deposit per NFT", "totalStorageDeposit": "Total storage deposit", diff --git a/patches/svelty-picker+4.1.3.patch b/patches/svelty-picker+4.1.3.patch new file mode 100644 index 0000000000..91e337d45d --- /dev/null +++ b/patches/svelty-picker+4.1.3.patch @@ -0,0 +1,48 @@ +diff --git a/node_modules/svelty-picker/dist/components/SveltyPicker.svelte b/node_modules/svelty-picker/dist/components/SveltyPicker.svelte +index fc6354a..751d4ed 100644 +--- a/node_modules/svelty-picker/dist/components/SveltyPicker.svelte ++++ b/node_modules/svelty-picker/dist/components/SveltyPicker.svelte +@@ -1,5 +1,5 @@ + + +@@ -12,10 +12,10 @@ + import { fade } from "svelte/transition"; + import Calendar from "./Calendar.svelte"; + import Time from "./Time.svelte"; +- import { formatDate, parseDate } from "../utils/dateUtils"; ++ import { formatDate, parseDate } from "../utils/dateUtils.js"; + import { usePosition } from "../utils/actions.js"; +- import { computeResolvedMode, initProps } from "../utils/state"; +- import { MODE_MONTH, STARTVIEW_TIME } from "../utils/constants"; ++ import { computeResolvedMode, initProps } from "../utils/state.js"; ++ import { MODE_MONTH, STARTVIEW_TIME } from "../utils/constants.js"; + + // html + export let inputId = ''; +diff --git a/node_modules/svelty-picker/dist/utils/grid.js b/node_modules/svelty-picker/dist/utils/grid.js +index 19c3403..5318956 100644 +--- a/node_modules/svelty-picker/dist/utils/grid.js ++++ b/node_modules/svelty-picker/dist/utils/grid.js +@@ -1,6 +1,6 @@ + +-import { MODE_YEAR, MODE_DECADE } from "./constants"; +-import { getDaysInMonth } from "./dateUtils"; ++import { MODE_YEAR, MODE_DECADE } from "./constants.js"; ++import { getDaysInMonth } from "./dateUtils.js"; + + /** + * @typedef {object} Dataset +diff --git a/node_modules/svelty-picker/dist/utils/state.js b/node_modules/svelty-picker/dist/utils/state.js +index e264172..c6101a2 100644 +--- a/node_modules/svelty-picker/dist/utils/state.js ++++ b/node_modules/svelty-picker/dist/utils/state.js +@@ -1,4 +1,4 @@ +-import { formatDate, parseDate } from "./dateUtils"; ++import { formatDate, parseDate } from "./dateUtils.js"; + + /** + * @typedef {object} ValueInit diff --git a/yarn.lock b/yarn.lock index 3ef85160b7..c03bfb30ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -342,16 +342,17 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@bloomwalletio/ui@0.7.10": - version "0.7.10" - resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.7.10/517dde2cd81244de9848c41d202bc93d21bfd393#517dde2cd81244de9848c41d202bc93d21bfd393" - integrity sha512-7lfkfCAvpwQd6otDeSoLJ47RYNjvRwCcHJ9Y96EMq8nfRXfGfsR5aPJWDgqTFw2AW020k0YLK41WpXhgpUD0SQ== +"@bloomwalletio/ui@0.7.12": + version "0.7.12" + resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.7.12/80419dcec6f6031dc888a5defabdc69cf7926722#80419dcec6f6031dc888a5defabdc69cf7926722" + integrity sha512-384Eci/XxTGxw/aA/wfzehu0trMg3eTiQr6c7cZhng9S75WsRxnB0kOTlRde9dwawAeo5rTHtEXOTz5xA/PIEw== dependencies: "@floating-ui/dom" "1.4.3" "@popperjs/core" "2.11.8" flowbite "1.7.0" flowbite-svelte "0.39.2" svelte-json-tree "2.1.0" + svelty-picker "4.1.3" tailwind-merge "1.13.2" "@chainsafe/as-sha256@^0.4.1": @@ -1114,7 +1115,7 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" -"@floating-ui/core@^1.3.1": +"@floating-ui/core@^1.3.1", "@floating-ui/core@^1.4.1": version "1.4.1" resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.4.1.tgz#0d633f4b76052668afb932492ac452f7ebe97f17" integrity sha512-jk3WqquEJRlcyu7997NtR5PibI+y5bi+LS3hPmguVClypenMsCY3CBa3LAQnozRCtCrYWSEtAdiskpamuJRFOQ== @@ -1128,6 +1129,14 @@ dependencies: "@floating-ui/core" "^1.3.1" +"@floating-ui/dom@^1.4.5": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.5.1.tgz#88b70defd002fe851f17b4a25efb2d3c04d7a8d7" + integrity sha512-KwvVcPSXg6mQygvA1TjbN/gh///36kKtllIF8SUm0qpFj8+rvYrpvlYdL1JoA71SHpDqgSSdGOSoQ0Mp3uY5aw== + dependencies: + "@floating-ui/core" "^1.4.1" + "@floating-ui/utils" "^0.1.1" + "@floating-ui/utils@^0.1.1": version "0.1.1" resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.1.1.tgz#1a5b1959a528e374e8037c4396c3e825d6cf4a83" @@ -9996,10 +10005,12 @@ svelte@3.58.0: resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.58.0.tgz#d3e6f103efd6129e51c7d709225ad3b4c052b64e" integrity sha512-brIBNNB76mXFmU/Kerm4wFnkskBbluBDCjx/8TcpYRb298Yh2dztS2kQ6bhtjMcvUhd5ynClfwpz5h2gnzdQ1A== -svelty-picker@3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/svelty-picker/-/svelty-picker-3.5.0.tgz#003e602489ba66f82745bd517d926a85879d1015" - integrity sha512-URxe82uJshx1I2mYdHU1/b2DysexvDZhgnfBP3p/aL5VBCa/PN0YltDR5VXQduW4EqxfQAJ9V/7w+adXqfx1rQ== +svelty-picker@4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/svelty-picker/-/svelty-picker-4.1.3.tgz#a19ca75459b5a6f2bc2387567b33b7048427645e" + integrity sha512-83gaWpwn16zhJctNEUuUMA883vvgsdbyj+Eil/nTWrRZ9b+xg2McQIRMcG4KxE+jvS10AdUO5pduxT1HLBBMpQ== + dependencies: + "@floating-ui/dom" "^1.4.5" swarm-js@^0.1.40: version "0.1.42"