From d9d4cb336a6be1c03700c796eb7c830cc4ecba2d Mon Sep 17 00:00:00 2001 From: Nicole O'Brien Date: Thu, 29 Feb 2024 08:17:52 +0000 Subject: [PATCH 1/4] refactor: store local evm transactions in same store as blockscout evm transactions (#2013) Co-authored-by: Mark Nardi --- .../popup/popups/SyncAccountsPopup.svelte | 4 +- .../generateAndStoreActivitiesForAccount.ts | 3 +- ...enerateAndStoreActivitiesForAllAccounts.ts | 4 +- .../stores/persisted-transactions.store.ts | 42 +------------------ .../utils/generateActivitiesFromChains.ts | 21 ++++++---- .../nfts/actions/loadNftsForActiveProfile.ts | 29 +++++++------ .../profile/actions/active-profile/login.ts | 2 +- .../actions/profiles/removeAllProfileData.ts | 4 +- .../send/signAndSendTransactionFromEvm.ts | 30 +++++++------ 9 files changed, 56 insertions(+), 83 deletions(-) diff --git a/packages/desktop/components/popup/popups/SyncAccountsPopup.svelte b/packages/desktop/components/popup/popups/SyncAccountsPopup.svelte index cfc389888a..c06f02376c 100644 --- a/packages/desktop/components/popup/popups/SyncAccountsPopup.svelte +++ b/packages/desktop/components/popup/popups/SyncAccountsPopup.svelte @@ -9,7 +9,7 @@ import { DEFAULT_ACCOUNT_RECOVERY_CONFIGURATION } from '@core/profile' import { RecoverAccountsPayload, recoverAccounts } from '@core/profile-manager' import { checkActiveProfileAuth, getBaseToken, loadAccounts } from '@core/profile/actions' - import { activeAccounts, activeProfile, visibleActiveAccounts } from '@core/profile/stores' + import { activeAccounts, activeProfile, activeProfileId, visibleActiveAccounts } from '@core/profile/stores' import { formatTokenAmountBestMatch } from '@core/token' import { refreshAccountTokensForActiveProfile } from '@core/token/actions' import { closePopup } from '@desktop/auxiliary/popup' @@ -141,7 +141,7 @@ onDestroy(async () => { if (hasUsedWalletFinder) { await refreshAccountTokensForActiveProfile() - await generateAndStoreActivitiesForAllAccounts() + await generateAndStoreActivitiesForAllAccounts($activeProfileId) loadNftsForActiveProfile() } }) diff --git a/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts b/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts index ced967a1c4..73672c13c3 100644 --- a/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts +++ b/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAccount.ts @@ -13,6 +13,7 @@ import { NetworkId } from '@core/network' import { setOutgoingAsyncActivitiesToClaimed } from './setOutgoingAsyncActivitiesToClaimed' export async function generateAndStoreActivitiesForAccount( + profileId: string, account: IAccountState, networkId: NetworkId ): Promise { @@ -34,7 +35,7 @@ export async function generateAndStoreActivitiesForAccount( const balanceChangeActivities = await generateActivitiesFromBalanceChanges(account) activities.push(...balanceChangeActivities) - const chainActivities = await generateActivitiesFromChains(account) + const chainActivities = await generateActivitiesFromChains(profileId, account) activities.push(...chainActivities) // Step 4: set account activities with generated activities diff --git a/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAllAccounts.ts b/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAllAccounts.ts index 864599c0b8..52805d78e2 100644 --- a/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAllAccounts.ts +++ b/packages/shared/src/lib/core/activity/actions/generateAndStoreActivitiesForAllAccounts.ts @@ -4,13 +4,13 @@ import { activeAccounts } from '@core/profile/stores' import { generateAndStoreActivitiesForAccount } from './generateAndStoreActivitiesForAccount' import { getActiveNetworkId } from '@core/network' -export async function generateAndStoreActivitiesForAllAccounts(): Promise { +export async function generateAndStoreActivitiesForAllAccounts(profileId: string): Promise { try { const networkId = getActiveNetworkId() const accounts = get(activeAccounts) await Promise.all( - accounts.map((activeAccount) => generateAndStoreActivitiesForAccount(activeAccount, networkId)) + accounts.map((activeAccount) => generateAndStoreActivitiesForAccount(profileId, activeAccount, networkId)) ) } catch (err) { console.error(err) diff --git a/packages/shared/src/lib/core/activity/stores/persisted-transactions.store.ts b/packages/shared/src/lib/core/activity/stores/persisted-transactions.store.ts index fc7d640c41..2a9f66e91d 100644 --- a/packages/shared/src/lib/core/activity/stores/persisted-transactions.store.ts +++ b/packages/shared/src/lib/core/activity/stores/persisted-transactions.store.ts @@ -1,9 +1,6 @@ -import { activeProfileId } from '@core/profile/stores' +import { NetworkId } from '@core/network/types' import { persistent } from '@core/utils/store' -import { get } from 'svelte/store' import { PersistedEvmTransaction } from '../types' -import { NetworkId } from '@core/network/types' -import { IChain } from '@core/network/interfaces' type PersistedEvmTransactions = { [profileId: string]: { @@ -14,40 +11,3 @@ type PersistedEvmTransactions = { } export const persistedEvmTransactions = persistent('evmTransactions', {}) - -export function getPersistedEvmTransactions(accountIndex: number, chain: IChain): PersistedEvmTransaction[] { - const networkId = chain.getConfiguration().id - return get(persistedEvmTransactions)?.[get(activeProfileId)]?.[accountIndex]?.[networkId] ?? [] -} - -export function addPersistedTransaction( - accountIndex: number, - chain: IChain, - ...newTransactions: PersistedEvmTransaction[] -): void { - const networkId = chain.getConfiguration().id - const profileId = get(activeProfileId) - persistedEvmTransactions.update((state) => { - if (!state[profileId]) { - state[profileId] = {} - } - if (!state[profileId][accountIndex]) { - state[profileId][accountIndex] = { - [networkId]: [], - } - } - if (!state[profileId][accountIndex][networkId]) { - state[profileId][accountIndex][networkId] = [] - } - - state[get(activeProfileId)][accountIndex][networkId]?.push(...newTransactions) - return state - }) -} - -export function removePersistedEvmTransactionsForProfile(profileId: string): void { - persistedEvmTransactions.update((state) => { - delete state[profileId] - return state - }) -} diff --git a/packages/shared/src/lib/core/activity/utils/generateActivitiesFromChains.ts b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromChains.ts index 7f485d1b12..b814d9ddd4 100644 --- a/packages/shared/src/lib/core/activity/utils/generateActivitiesFromChains.ts +++ b/packages/shared/src/lib/core/activity/utils/generateActivitiesFromChains.ts @@ -1,21 +1,24 @@ import { IAccountState } from '@core/account' +import { network } from '@core/network' +import { getPersistedTransactionsForChain } from '@core/transactions/stores' +import { get } from 'svelte/store' 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 { +export async function generateActivitiesFromChains(profileId: string, account: IAccountState): Promise { const activities: Activity[] = [] const chains = get(network)?.getChains() ?? [] for (const chain of chains) { - const transactions = getPersistedEvmTransactions(account.index, chain) - for (const transaction of transactions) { + const persistedTransactions = getPersistedTransactionsForChain(profileId, account.index, chain) + for (const transaction of persistedTransactions) { try { - const activity = await generateActivityFromEvmTransaction(transaction, chain, account) - if (activity) { - activities.push(activity) + if (transaction.local) { + // TODO: build activities from persisted transactions + const activity = await generateActivityFromEvmTransaction(transaction.local, chain, account) + if (activity) { + activities.push(activity) + } } } catch (error) { console.error(error) diff --git a/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts b/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts index 12c7f89985..8df381d0c2 100644 --- a/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts +++ b/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts @@ -1,25 +1,27 @@ -import { NftOutput, OutputType } from '@iota/sdk/out/types' +import { getAddressFromAccountForNetwork } from '@core/account' import { IAccountState } from '@core/account/interfaces' -import { activeAccounts } from '@core/profile/stores' +import { ActivityType } from '@core/activity' import { getNftId } from '@core/activity/utils/outputs' +import { getTransferInfoFromTransactionData } from '@core/layer-2/utils/getTransferInfoFromTransactionData' +import { getActiveNetworkId, getNetwork } from '@core/network' +import { activeAccounts, activeProfileId } from '@core/profile/stores' +import { getPersistedTransactionsForChain } from '@core/transactions/stores' import { IWrappedOutput } from '@core/wallet/interfaces' +import { NftOutput, OutputType } from '@iota/sdk/out/types' import { get } from 'svelte/store' import { Nft } from '../interfaces' -import { buildNftFromNftOutput } from './buildNftFromNftOutput' -import { setAccountNftsInAllAccountNfts } from './setAccountNftsInAllAccountNfts' -import { getActiveNetworkId, getNetwork } from '@core/network' -import { ActivityType, getPersistedEvmTransactions } from '@core/activity' -import { getTransferInfoFromTransactionData } from '@core/layer-2/utils/getTransferInfoFromTransactionData' import { buildNftFromPersistedErc721Nft, getNftsFromNftIds } from '../utils' import { addNftsToDownloadQueue } from './addNftsToDownloadQueue' +import { buildNftFromNftOutput } from './buildNftFromNftOutput' import { getPersistedErc721Nfts } from './getPersistedErc721Nfts' -import { getAddressFromAccountForNetwork } from '@core/account' +import { setAccountNftsInAllAccountNfts } from './setAccountNftsInAllAccountNfts' export async function loadNftsForActiveProfile(): Promise { let nftsToDownload: Nft[] = [] + const profileId = get(activeProfileId) const allAccounts = get(activeAccounts) for (const account of allAccounts) { - const accountNfts = await loadNftsForAccount(account) + const accountNfts = await loadNftsForAccount(profileId, account) nftsToDownload = [...nftsToDownload, ...accountNfts] } @@ -27,7 +29,7 @@ export async function loadNftsForActiveProfile(): Promise { void addNftsToDownloadQueue(nftsToDownload) } -export async function loadNftsForAccount(account: IAccountState): Promise { +export async function loadNftsForAccount(profileId: string, account: IAccountState): Promise { const accountNfts: Nft[] = [] const unspentOutputs = await account.unspentOutputs() const networkId = getActiveNetworkId() @@ -40,10 +42,13 @@ export async function loadNftsForAccount(account: IAccountState): Promise for (const chain of getNetwork()?.getChains() ?? []) { // Wrapped L1 NFTs - const transactionsOnChain = getPersistedEvmTransactions(account.index, chain) + const transactionsOnChain = getPersistedTransactionsForChain(profileId, account.index, chain) const nftIdsOnChain = [] for (const transaction of transactionsOnChain) { - const transferInfo = getTransferInfoFromTransactionData(transaction, chain) + if (!transaction.local) { + continue + } + const transferInfo = getTransferInfoFromTransactionData(transaction.local, chain) if (transferInfo?.type !== ActivityType.Nft) { continue } diff --git a/packages/shared/src/lib/core/profile/actions/active-profile/login.ts b/packages/shared/src/lib/core/profile/actions/active-profile/login.ts index 24dc6d6d8f..be09aaa201 100644 --- a/packages/shared/src/lib/core/profile/actions/active-profile/login.ts +++ b/packages/shared/src/lib/core/profile/actions/active-profile/login.ts @@ -85,7 +85,7 @@ export async function login(loginOptions?: ILoginOptions): Promise { // Step 5: generate and store activities for all accounts incrementLoginProgress() - await generateAndStoreActivitiesForAllAccounts() + await generateAndStoreActivitiesForAllAccounts(_activeProfile.id) if (type === ProfileType.Software) { // Step 6: set initial stronghold status diff --git a/packages/shared/src/lib/core/profile/actions/profiles/removeAllProfileData.ts b/packages/shared/src/lib/core/profile/actions/profiles/removeAllProfileData.ts index 5871946a87..47016e7d06 100644 --- a/packages/shared/src/lib/core/profile/actions/profiles/removeAllProfileData.ts +++ b/packages/shared/src/lib/core/profile/actions/profiles/removeAllProfileData.ts @@ -3,15 +3,15 @@ import { removeClaimedActivitiesForProfile, removeHiddenActivitiesForProfile, removePersistedBalanceChangesForProfile, - removePersistedEvmTransactionsForProfile, } from '@core/activity/stores' import { removePersistedNftsForProfile } from '@core/nfts/stores' import { removePersistedProfile } from '@core/profile/stores' import { removePersistedTokensForProfile } from '@core/token/stores' +import { removePersistedTransactionsForProfile } from '@core/transactions/stores' export function removeAllProfileData(profileId: string): void { removePersistedProfile(profileId) - removePersistedEvmTransactionsForProfile(profileId) + removePersistedTransactionsForProfile(profileId) removePersistedBalanceChangesForProfile(profileId) removeClaimedActivitiesForProfile(profileId) removePersistedNftsForProfile(profileId) diff --git a/packages/shared/src/lib/core/wallet/actions/send/signAndSendTransactionFromEvm.ts b/packages/shared/src/lib/core/wallet/actions/send/signAndSendTransactionFromEvm.ts index 328f40da0a..501bfb18ee 100644 --- a/packages/shared/src/lib/core/wallet/actions/send/signAndSendTransactionFromEvm.ts +++ b/packages/shared/src/lib/core/wallet/actions/send/signAndSendTransactionFromEvm.ts @@ -1,8 +1,4 @@ -import { addAccountActivity, addPersistedTransaction } from '@core/activity/stores' -import { EvmTransactionData } from '@core/layer-2' -import { IChain } from '@core/network' -import { signEvmTransaction } from '../signEvmTransaction' -import { generateActivityFromEvmTransaction } from '@core/activity/utils/generateActivityFromEvmTransaction' +import { IAccountState } from '@core/account' import { Activity, ActivityDirection, @@ -10,15 +6,21 @@ import { PersistedEvmTransaction, calculateAndAddPersistedNftBalanceChange, } from '@core/activity' -import { IAccountState } from '@core/account' -import { updateL2BalanceWithoutActivity } from '../updateL2BalanceWithoutActivity' +import { addAccountActivity } from '@core/activity/stores' +import { generateActivityFromEvmTransaction } from '@core/activity/utils/generateActivityFromEvmTransaction' +import { EvmTransactionData } from '@core/layer-2' +import { EvmNetworkId, IChain } from '@core/network' +import { addLocalTransactionToPersistedTransaction } from '@core/transactions/stores' import { sendSignedEvmTransaction } from '@core/wallet/actions/sendSignedEvmTransaction' +import { signEvmTransaction } from '../signEvmTransaction' +import { updateL2BalanceWithoutActivity } from '../updateL2BalanceWithoutActivity' export async function signAndSendTransactionFromEvm( preparedTransaction: EvmTransactionData, chain: IChain, account: IAccountState, - signAndSend: boolean + signAndSend: boolean, + profileId: string ): Promise { const signedTransaction = await signEvmTransaction(preparedTransaction, chain, account) if (!signedTransaction) { @@ -40,16 +42,18 @@ export async function signAndSendTransactionFromEvm( ...transactionReceipt, timestamp: Date.now(), } - await persistEvmTransaction(evmTransaction, chain, account) + await persistEvmTransaction(profileId, account, chain, evmTransaction) return transactionReceipt.transactionHash } async function persistEvmTransaction( - evmTransaction: PersistedEvmTransaction, + profileId: string, + account: IAccountState, chain: IChain, - account: IAccountState + evmTransaction: PersistedEvmTransaction ): Promise { - addPersistedTransaction(account.index, chain, evmTransaction) + const networkId = chain.getConfiguration().id as EvmNetworkId + addLocalTransactionToPersistedTransaction(profileId, account.index, networkId, [evmTransaction]) const activity = await generateActivityFromEvmTransaction(evmTransaction, chain, account) if (!activity) { @@ -62,7 +66,7 @@ async function persistEvmTransaction( if (activity.recipient?.type === 'account') { const recipientAccount = activity.recipient.account - addPersistedTransaction(recipientAccount.index, chain, evmTransaction) + addLocalTransactionToPersistedTransaction(profileId, recipientAccount.index, networkId, [evmTransaction]) const receiveActivity = await generateActivityFromEvmTransaction(evmTransaction, chain, recipientAccount) if (!receiveActivity) { return From 0952d3eb56db494a4308d67b2438fe3cf123ab65 Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Thu, 29 Feb 2024 12:08:48 +0100 Subject: [PATCH 2/4] feat: implement eth sendrawtransaction handler (#1994) * split signing and sending evm transaction * parse rawMessage * get sender from rawtransaction * remove demo data * rename return value * extract to own file + move error * enum for rpc methods * pass raw message * fix type --------- Co-authored-by: Tuditi <45079109+Tuditi@users.noreply.github.com> --- .../popups/EvmTransactionFromDappPopup.svelte | 51 ++++++++++++++----- .../components/PermissionSelection.svelte | 3 +- .../views/TransactionSummaryView.svelte | 7 ++- .../general-supported-methods.constant.ts | 4 +- .../methods-for-permissions.constant.ts | 15 +++--- .../auxiliary/wallet-connect/enums/index.ts | 1 + .../wallet-connect/enums/rpc-method.enum.ts | 11 ++++ .../handlers/eth_transaction.handler.ts | 8 +-- .../handlers/onSessionRequest.handler.ts | 32 +++++++----- .../handlers/sign_message.handler.ts | 8 +-- .../utils/getPermissionForMethod.ts | 4 +- .../utils/getEvmTransactionFromHexString.ts | 24 +++++++++ .../layer-2/utils/getHexEncodedTransaction.ts | 8 +++ .../src/lib/core/layer-2/utils/index.ts | 2 + .../utils/signEvmTransactionWithStronghold.ts | 8 +-- packages/shared/src/lib/core/utils/convert.ts | 4 +- .../src/lib/core/wallet/actions/send/index.ts | 2 +- ...ts => sendAndPersistTransactionFromEvm.ts} | 17 ++----- .../actions/sendSignedEvmTransaction.ts | 3 +- .../core/wallet/actions/signEvmTransaction.ts | 12 +++-- 20 files changed, 150 insertions(+), 74 deletions(-) create mode 100644 packages/shared/src/lib/auxiliary/wallet-connect/enums/rpc-method.enum.ts create mode 100644 packages/shared/src/lib/core/layer-2/utils/getEvmTransactionFromHexString.ts create mode 100644 packages/shared/src/lib/core/layer-2/utils/getHexEncodedTransaction.ts rename packages/shared/src/lib/core/wallet/actions/send/{signAndSendTransactionFromEvm.ts => sendAndPersistTransactionFromEvm.ts} (90%) diff --git a/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte b/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte index a49222b68b..f210d84640 100644 --- a/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte +++ b/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte @@ -3,7 +3,7 @@ import { handleError } from '@core/error/handlers' import { IConnectedDapp } from '@auxiliary/wallet-connect/interface' import { CallbackParameters } from '@auxiliary/wallet-connect/types' - import { signAndSendTransactionFromEvm } from '@core/wallet/actions' + import { sendAndPersistTransactionFromEvm, signEvmTransaction } from '@core/wallet/actions' import { selectedAccount } from '@core/account/stores' import { ExplorerEndpoint, IChain, getDefaultExplorerUrl } from '@core/network' import { DappInfo, TransactionAssetSection } from '@ui' @@ -13,6 +13,7 @@ import { calculateEstimatedGasFeeFromTransactionData, calculateMaxGasFeeFromTransactionData, + getHexEncodedTransaction, getMethodNameForEvmTransaction, } from '@core/layer-2' import { getTokenFromSelectedAccountTokens } from '@core/token/stores' @@ -28,17 +29,23 @@ import { BASE_TOKEN_ID } from '@core/token/constants' import { checkActiveProfileAuthAsync } from '@core/profile/actions' import { LedgerAppName } from '@core/ledger' - import { DappVerification } from '@auxiliary/wallet-connect/enums' + import { DappVerification, RpcMethod } from '@auxiliary/wallet-connect/enums' + import { LegacyTransaction } from '@ethereumjs/tx' export let preparedTransaction: EvmTransactionData export let chain: IChain export let dapp: IConnectedDapp - export let signAndSend: boolean export let verifiedState: DappVerification + export let method: RpcMethod.EthSendTransaction | RpcMethod.EthSignTransaction | RpcMethod.EthSendRawTransaction export let callback: (params: CallbackParameters) => void const { id } = chain.getConfiguration() - $: localeKey = signAndSend ? (isSmartContractCall ? 'smartContractCall' : 'sendTransaction') : 'signTransaction' + $: localeKey = + method === RpcMethod.EthSignTransaction + ? 'signTransaction' + : isSmartContractCall + ? 'smartContractCall' + : 'sendTransaction' let nft: Nft | undefined let tokenTransfer: TokenTransferData | undefined @@ -79,6 +86,30 @@ } } + async function getSignedTransaction(): Promise { + if (preparedTransaction?.v && preparedTransaction?.s && preparedTransaction?.r) { + const transaction = LegacyTransaction.fromTxData(preparedTransaction) + return getHexEncodedTransaction(transaction) + } else { + return await signEvmTransaction(preparedTransaction, chain, $selectedAccount) + } + } + + async function signOrSend(): Promise { + const signedTransaction = await getSignedTransaction() + if (method === RpcMethod.EthSignTransaction) { + callback({ result: signedTransaction }) + return + } + const transactionHash = await sendAndPersistTransactionFromEvm( + preparedTransaction, + signedTransaction, + chain, + $selectedAccount + ) + callback({ result: transactionHash }) + } + async function onConfirmClick(): Promise { try { await checkActiveProfileAuthAsync(LedgerAppName.Ethereum) @@ -89,15 +120,11 @@ try { busy = true modifyPopupState({ preventClose: true }) - const response = await signAndSendTransactionFromEvm( - preparedTransaction, - chain, - $selectedAccount, - signAndSend - ) + + await signOrSend() + modifyPopupState({ preventClose: false }, true) busy = false - callback({ result: response }) openPopup({ id: PopupId.SuccessfulDappInteraction, props: { @@ -112,7 +139,7 @@ } } - $: setMethodName(preparedTransaction) + $: void setMethodName(preparedTransaction) async function setMethodName(preparedTransaction: EvmTransactionData): Promise { const result = await getMethodNameForEvmTransaction(preparedTransaction) methodName = result?.startsWith('0x') ? undefined : result diff --git a/packages/desktop/views/dashboard/drawers/dapp-config/components/PermissionSelection.svelte b/packages/desktop/views/dashboard/drawers/dapp-config/components/PermissionSelection.svelte index 133f5df4f7..87e15070c1 100644 --- a/packages/desktop/views/dashboard/drawers/dapp-config/components/PermissionSelection.svelte +++ b/packages/desktop/views/dashboard/drawers/dapp-config/components/PermissionSelection.svelte @@ -7,6 +7,7 @@ import { SupportedNamespaces } from '@auxiliary/wallet-connect/types' import { Text } from '@bloomwalletio/ui' import { getPermissionForMethod } from '@auxiliary/wallet-connect/utils' + import { RpcMethod } from '@auxiliary/wallet-connect/enums' import { SelectionOption } from '@core/utils/interfaces' export let checkedMethods: string[] @@ -37,7 +38,7 @@ } checkedMethods[method.method] = true - const permission = getPermissionForMethod(method.method) + const permission = getPermissionForMethod(method.method as RpcMethod) if (!permission || addedPermission[permission]) { continue } diff --git a/packages/desktop/views/dashboard/send-flow/views/TransactionSummaryView.svelte b/packages/desktop/views/dashboard/send-flow/views/TransactionSummaryView.svelte index d98bd92b6f..316802fc32 100644 --- a/packages/desktop/views/dashboard/send-flow/views/TransactionSummaryView.svelte +++ b/packages/desktop/views/dashboard/send-flow/views/TransactionSummaryView.svelte @@ -10,8 +10,9 @@ import { createEvmTransactionFromSendFlowParameters, createStardustOutputFromSendFlowParameters, - signAndSendTransactionFromEvm, + sendAndPersistTransactionFromEvm, signAndSendStardustTransaction, + signEvmTransaction, } from '@core/wallet/actions' import { sendFlowParameters } from '@core/wallet/stores' import { getNetworkIdFromSendFlowParameters, validateSendConfirmation } from '@core/wallet/utils' @@ -104,7 +105,9 @@ busy = true modifyPopupState({ preventClose: true }) if (isSourceNetworkLayer2) { - await signAndSendTransactionFromEvm(preparedTransaction, chain, $selectedAccount, true) + const signedTransaction = await signEvmTransaction(preparedTransaction, chain, $selectedAccount) + + await sendAndPersistTransactionFromEvm(preparedTransaction, signedTransaction, chain, $selectedAccount) } else { await signAndSendStardustTransaction(preparedOutput, $selectedAccount) } diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/constants/general-supported-methods.constant.ts b/packages/shared/src/lib/auxiliary/wallet-connect/constants/general-supported-methods.constant.ts index 13f7647d7c..f3d7ba4605 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/constants/general-supported-methods.constant.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/constants/general-supported-methods.constant.ts @@ -1 +1,3 @@ -export const GENERAL_SUPPORTED_METHODS = ['wallet_watchAsset'] +import { RpcMethod } from '../enums' + +export const GENERAL_SUPPORTED_METHODS = [RpcMethod.WalletWatchAsset] diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/constants/methods-for-permissions.constant.ts b/packages/shared/src/lib/auxiliary/wallet-connect/constants/methods-for-permissions.constant.ts index 493583b769..421ef75737 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/constants/methods-for-permissions.constant.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/constants/methods-for-permissions.constant.ts @@ -1,13 +1,14 @@ import { DappPermission } from '../enums/dapp-permission.enum' +import { RpcMethod } from '../enums/rpc-method.enum' export const METHODS_FOR_PERMISSION = { [DappPermission.SignData]: [ - 'eth_sign', - 'personal_sign', - 'eth_signTypedData', - 'eth_signTypedData_v3', - 'eth_signTypedData_v4', + RpcMethod.EthSign, + RpcMethod.PersonalSign, + RpcMethod.EthSignTypedData, + RpcMethod.EthSignTypedDataV3, + RpcMethod.EthSignTypedDataV4, ], - [DappPermission.SignTransaction]: ['eth_signTransaction'], - [DappPermission.SendTransaction]: ['eth_sendTransaction', 'eth_sendRawTransaction'], + [DappPermission.SignTransaction]: [RpcMethod.EthSignTransaction], + [DappPermission.SendTransaction]: [RpcMethod.EthSendTransaction, RpcMethod.EthSendRawTransaction], } diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/enums/index.ts b/packages/shared/src/lib/auxiliary/wallet-connect/enums/index.ts index 562d4c75be..a392eab438 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/enums/index.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/enums/index.ts @@ -1,3 +1,4 @@ export * from './dapp-permission.enum' export * from './dapp-verification.enum' +export * from './rpc-method.enum' export * from './wallet-connect-events.enum' diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/enums/rpc-method.enum.ts b/packages/shared/src/lib/auxiliary/wallet-connect/enums/rpc-method.enum.ts new file mode 100644 index 0000000000..e35509b6c4 --- /dev/null +++ b/packages/shared/src/lib/auxiliary/wallet-connect/enums/rpc-method.enum.ts @@ -0,0 +1,11 @@ +export enum RpcMethod { + EthSign = 'eth_sign', + PersonalSign = 'personal_sign', + EthSignTypedData = 'eth_signTypedData', + EthSignTypedDataV3 = 'eth_signTypedData_v3', + EthSignTypedDataV4 = 'eth_signTypedData_v4', + EthSignTransaction = 'eth_signTransaction', + EthSendTransaction = 'eth_sendTransaction', + EthSendRawTransaction = 'eth_sendRawTransaction', + WalletWatchAsset = 'wallet_watchAsset', +} diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_transaction.handler.ts b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_transaction.handler.ts index ca6141fad8..8150a32607 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_transaction.handler.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/eth_transaction.handler.ts @@ -7,13 +7,13 @@ import { EvmTransactionData } from '@core/layer-2' import { switchToRequiredAccount } from '@auxiliary/wallet-connect/utils' import { getSdkError } from '@walletconnect/utils' import { Platform } from '@core/app' -import { DappVerification } from '../enums' +import { DappVerification, RpcMethod } from '../enums' export async function handleEthTransaction( evmTransactionData: EvmTransactionData & { from: string }, dapp: IConnectedDapp, chain: IChain, - signAndSend: boolean, + method: RpcMethod.EthSendTransaction | RpcMethod.EthSignTransaction | RpcMethod.EthSendRawTransaction, responseCallback: (params: CallbackParameters) => void, verifiedState: DappVerification ): Promise { @@ -28,7 +28,7 @@ export async function handleEthTransaction( return } - if (!nonce || !gasPrice || !gasLimit) { + if (nonce === undefined || !gasPrice || !gasLimit) { try { const { nonce, gasPrice, gasLimit } = await buildEvmTransactionData( chain, @@ -61,7 +61,7 @@ export async function handleEthTransaction( chain, dapp, preparedTransaction: evmTransactionData, - signAndSend, + method, verifiedState, callback: responseCallback, onCancel: () => responseCallback({ error: getSdkError('USER_REJECTED') }), 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 0f0e5fff51..2c74ea4ce2 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 @@ -9,14 +9,15 @@ import { handleEthSignTypedData } from './eth_signTypedData.handler' import { handleEthTransaction } from './eth_transaction.handler' import { handleSignMessage } from './sign_message.handler' import { handleWatchAsset } from '@auxiliary/wallet-connect/handlers' -import { DappVerification } from '../enums' +import { DappVerification, RpcMethod } from '../enums' +import { EvmTransactionData, getEvmTransactionFromHexString } from '@core/layer-2' export function onSessionRequest(event: Web3WalletTypes.SessionRequest): void { // We need to call this here, because if the dapp requests too fast after approval, we won't have the dapp in the store yet setConnectedDapps() const { topic, params, id, verifyContext } = event const { request, chainId } = params - const method = request.method + const method = request.method as RpcMethod const dapp = getConnectedDappByOrigin(verifyContext.verified.origin) const verifiedState: DappVerification = verifyContext.verified.isScam @@ -58,23 +59,28 @@ export function onSessionRequest(event: Web3WalletTypes.SessionRequest): void { return } - const signAndSend = method === 'eth_sendTransaction' - switch (method) { - case 'eth_sendTransaction': - case 'eth_signTransaction': - void handleEthTransaction(request.params[0], dapp, chain, signAndSend, returnResponse, verifiedState) + case RpcMethod.EthSendTransaction: + case RpcMethod.EthSignTransaction: + case RpcMethod.EthSendRawTransaction: { + const evmTransactionData: EvmTransactionData & { from: string } = + method === RpcMethod.EthSendRawTransaction + ? getEvmTransactionFromHexString(request.params[0]) + : request.params[0] + + void handleEthTransaction(evmTransactionData, dapp, chain, method, returnResponse, verifiedState) break - case 'eth_sign': - case 'personal_sign': + } + case RpcMethod.EthSign: + case RpcMethod.PersonalSign: void handleSignMessage(request.params, dapp, method, chain, returnResponse, verifiedState) break - case 'eth_signTypedData': - case 'eth_signTypedData_v3': - case 'eth_signTypedData_v4': + case RpcMethod.EthSignTypedData: + case RpcMethod.EthSignTypedDataV3: + case RpcMethod.EthSignTypedDataV4: void handleEthSignTypedData(request.params, method, dapp, chain, returnResponse, verifiedState) break - case 'wallet_watchAsset': + case RpcMethod.WalletWatchAsset: void handleWatchAsset(request.params, dapp, chain, returnResponse) break default: diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/sign_message.handler.ts b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/sign_message.handler.ts index 95b0c032e9..a4865dd4bf 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/handlers/sign_message.handler.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/handlers/sign_message.handler.ts @@ -6,7 +6,7 @@ import { CallbackParameters } from '../types' import { switchToRequiredAccount } from '../utils' import { getSdkError } from '@walletconnect/utils' import { Platform } from '@core/app' -import { DappVerification } from '../enums' +import { DappVerification, RpcMethod } from '../enums' import { parseSiweMessage, validateSiwe } from '@core/layer-2' import { showNotification } from '@auxiliary/notification' import { localize } from '@core/i18n' @@ -14,7 +14,7 @@ import { localize } from '@core/i18n' export async function handleSignMessage( params: unknown, dapp: IConnectedDapp, - method: 'personal_sign' | 'eth_sign', + method: RpcMethod.PersonalSign | RpcMethod.EthSign, chain: IChain, responseCallback: (params: CallbackParameters) => void, verifiedState: DappVerification @@ -26,8 +26,8 @@ export async function handleSignMessage( // Type for `eth_sign` params: [ address, hexMessage ] // Type for `personal_sign` params: [ hexMessage, address ] - const hexMessage = method === 'personal_sign' ? params[0] : params[1] - const accountAddress = method === 'personal_sign' ? params[1] : params[0] + const hexMessage = method === RpcMethod.PersonalSign ? params[0] : params[1] + const accountAddress = method === RpcMethod.PersonalSign ? params[1] : params[0] if (typeof hexMessage !== 'string') { responseCallback({ error: getSdkError('INVALID_METHOD') }) diff --git a/packages/shared/src/lib/auxiliary/wallet-connect/utils/getPermissionForMethod.ts b/packages/shared/src/lib/auxiliary/wallet-connect/utils/getPermissionForMethod.ts index feaefedc07..bc3aca4bf0 100644 --- a/packages/shared/src/lib/auxiliary/wallet-connect/utils/getPermissionForMethod.ts +++ b/packages/shared/src/lib/auxiliary/wallet-connect/utils/getPermissionForMethod.ts @@ -1,7 +1,7 @@ import { METHODS_FOR_PERMISSION } from '../constants' -import { DappPermission } from '../enums' +import { DappPermission, RpcMethod } from '../enums' -export function getPermissionForMethod(method: string): DappPermission | undefined { +export function getPermissionForMethod(method: RpcMethod): DappPermission | undefined { for (const permission of Object.values(DappPermission)) { const supportedMethods = METHODS_FOR_PERMISSION[permission] ?? [] diff --git a/packages/shared/src/lib/core/layer-2/utils/getEvmTransactionFromHexString.ts b/packages/shared/src/lib/core/layer-2/utils/getEvmTransactionFromHexString.ts new file mode 100644 index 0000000000..6de2b2568f --- /dev/null +++ b/packages/shared/src/lib/core/layer-2/utils/getEvmTransactionFromHexString.ts @@ -0,0 +1,24 @@ +import { Converter } from '@core/utils' +import { LegacyTransaction, TransactionFactory } from '@ethereumjs/tx' +import { EvmTransactionData } from '../types' + +export function getEvmTransactionFromHexString(transactionHex: string): EvmTransactionData & { from: string } { + const transaction = TransactionFactory.fromSerializedData(Converter.hexToBytes(transactionHex)) as LegacyTransaction + const sender = transaction.getSenderAddress().toString() + + const { nonce, gasPrice, gasLimit, to, value, data, v, r, s, type } = transaction + + return { + nonce: Converter.bigIntToHex(nonce), + gasPrice: Converter.bigIntToHex(gasPrice), + gasLimit: Converter.bigIntToHex(gasLimit), + to, + value: Converter.bigIntToHex(value), + data: Converter.bytesToHex(data), + r: Converter.bigIntToHex(r), + v: Converter.bigIntToHex(v), + s: Converter.bigIntToHex(s), + type, + from: sender, + } +} diff --git a/packages/shared/src/lib/core/layer-2/utils/getHexEncodedTransaction.ts b/packages/shared/src/lib/core/layer-2/utils/getHexEncodedTransaction.ts new file mode 100644 index 0000000000..1cff95d72b --- /dev/null +++ b/packages/shared/src/lib/core/layer-2/utils/getHexEncodedTransaction.ts @@ -0,0 +1,8 @@ +import { HEX_PREFIX } from '@core/utils' +import { LegacyTransaction } from '@ethereumjs/tx' + +export function getHexEncodedTransaction(transaction: LegacyTransaction): string { + const serializedTransaction = transaction.serialize() + const hexEncodedTransaction = HEX_PREFIX + Buffer.from(serializedTransaction).toString('hex') + return hexEncodedTransaction +} diff --git a/packages/shared/src/lib/core/layer-2/utils/index.ts b/packages/shared/src/lib/core/layer-2/utils/index.ts index 795568f6df..90f2b1da1c 100644 --- a/packages/shared/src/lib/core/layer-2/utils/index.ts +++ b/packages/shared/src/lib/core/layer-2/utils/index.ts @@ -9,6 +9,8 @@ export * from './getAmountFromEvmTransactionValue' export * from './getEvmTokenMetadata' export * from './getErc20TransferSmartContractData' export * from './getErc721TransferSmartContractData' +export * from './getEvmTransactionFromHexString' +export * from './getHexEncodedTransaction' export * from './getMethodNameForEvmTransaction' export * from './lookupMethodSignature' export * from './parseLayer2Metadata' diff --git a/packages/shared/src/lib/core/stronghold/utils/signEvmTransactionWithStronghold.ts b/packages/shared/src/lib/core/stronghold/utils/signEvmTransactionWithStronghold.ts index f38d7bf469..c511c32ee7 100644 --- a/packages/shared/src/lib/core/stronghold/utils/signEvmTransactionWithStronghold.ts +++ b/packages/shared/src/lib/core/stronghold/utils/signEvmTransactionWithStronghold.ts @@ -1,5 +1,5 @@ import { LegacyTransaction, TransactionFactory, TypedTxData } from '@ethereumjs/tx' -import { prepareEvmTransaction } from '@core/layer-2/utils' +import { getHexEncodedTransaction, prepareEvmTransaction } from '@core/layer-2/utils' import { EvmChainId, getEvmTransactionOptions } from '@core/network' import { removeLeadingZeros } from '@core/utils/array' import { ECDSASignature } from '@ethereumjs/util' @@ -36,12 +36,6 @@ function createSignedTransaction( return signedTransaction } -function getHexEncodedTransaction(transaction: LegacyTransaction): string { - const serializedTransaction = transaction.serialize() - const hexEncodedTransaction = HEX_PREFIX + Buffer.from(serializedTransaction).toString('hex') - return hexEncodedTransaction -} - function padHexString(str: string): string { return str.length % 2 !== 0 ? '0' + str : str } diff --git a/packages/shared/src/lib/core/utils/convert.ts b/packages/shared/src/lib/core/utils/convert.ts index 0193c14580..77f338453f 100644 --- a/packages/shared/src/lib/core/utils/convert.ts +++ b/packages/shared/src/lib/core/utils/convert.ts @@ -233,8 +233,8 @@ export class Converter { return prefix ? HEX_PREFIX + number.toString(16) : number.toString(16) } - public static bigIntToHex(bigInt: bigint, prefix = true): string { - bigInt = BigInt(bigInt) + public static bigIntToHex(bigInt: bigint | undefined, prefix = true): string { + bigInt = BigInt(bigInt ?? 0) return prefix ? HEX_PREFIX + bigInt.toString(16) : bigInt.toString(16) } diff --git a/packages/shared/src/lib/core/wallet/actions/send/index.ts b/packages/shared/src/lib/core/wallet/actions/send/index.ts index 19bd373c0f..895e123b2d 100644 --- a/packages/shared/src/lib/core/wallet/actions/send/index.ts +++ b/packages/shared/src/lib/core/wallet/actions/send/index.ts @@ -2,5 +2,5 @@ export * from './createEvmChainToEvmChainTransaction' export * from './createEvmChainToStardustNetworkTransaction' export * from './createEvmTransactionFromSendFlowParameters' export * from './createStardustOutputFromSendFlowParameters' -export * from './signAndSendTransactionFromEvm' +export * from './sendAndPersistTransactionFromEvm' export * from './signAndSendStardustTransaction' diff --git a/packages/shared/src/lib/core/wallet/actions/send/signAndSendTransactionFromEvm.ts b/packages/shared/src/lib/core/wallet/actions/send/sendAndPersistTransactionFromEvm.ts similarity index 90% rename from packages/shared/src/lib/core/wallet/actions/send/signAndSendTransactionFromEvm.ts rename to packages/shared/src/lib/core/wallet/actions/send/sendAndPersistTransactionFromEvm.ts index 501bfb18ee..4c7d5d23a4 100644 --- a/packages/shared/src/lib/core/wallet/actions/send/signAndSendTransactionFromEvm.ts +++ b/packages/shared/src/lib/core/wallet/actions/send/sendAndPersistTransactionFromEvm.ts @@ -1,4 +1,3 @@ -import { IAccountState } from '@core/account' import { Activity, ActivityDirection, @@ -12,24 +11,16 @@ import { EvmTransactionData } from '@core/layer-2' import { EvmNetworkId, IChain } from '@core/network' import { addLocalTransactionToPersistedTransaction } from '@core/transactions/stores' import { sendSignedEvmTransaction } from '@core/wallet/actions/sendSignedEvmTransaction' -import { signEvmTransaction } from '../signEvmTransaction' import { updateL2BalanceWithoutActivity } from '../updateL2BalanceWithoutActivity' +import { IAccountState } from '@core/account' -export async function signAndSendTransactionFromEvm( +export async function sendAndPersistTransactionFromEvm( preparedTransaction: EvmTransactionData, + signedTransaction: string, chain: IChain, account: IAccountState, - signAndSend: boolean, profileId: string -): Promise { - const signedTransaction = await signEvmTransaction(preparedTransaction, chain, account) - if (!signedTransaction) { - throw Error('No signed transaction!') - } - if (!signAndSend) { - return signedTransaction - } - +): Promise { const transactionReceipt = await sendSignedEvmTransaction(chain, signedTransaction) if (!transactionReceipt) { throw Error('No transaction receipt!') diff --git a/packages/shared/src/lib/core/wallet/actions/sendSignedEvmTransaction.ts b/packages/shared/src/lib/core/wallet/actions/sendSignedEvmTransaction.ts index c76e27685d..2def0eaf84 100644 --- a/packages/shared/src/lib/core/wallet/actions/sendSignedEvmTransaction.ts +++ b/packages/shared/src/lib/core/wallet/actions/sendSignedEvmTransaction.ts @@ -1,6 +1,5 @@ import { TransactionReceipt } from 'web3-core' import { updateSelectedAccount } from '@core/account/stores' -import { handleError } from '@core/error/handlers' import { closePopup } from '../../../../../../desktop/lib/auxiliary/popup' import { IChain } from '@core/network' import { getIsActiveLedgerProfile } from '@core/profile/stores' @@ -17,7 +16,7 @@ export async function sendSignedEvmTransaction( if (getIsActiveLedgerProfile()) { closePopup({ forceClose: true }) } - handleError(err) + throw err } finally { updateSelectedAccount({ isTransferring: false }) } diff --git a/packages/shared/src/lib/core/wallet/actions/signEvmTransaction.ts b/packages/shared/src/lib/core/wallet/actions/signEvmTransaction.ts index 5c3843b7d4..a9712c3bd5 100644 --- a/packages/shared/src/lib/core/wallet/actions/signEvmTransaction.ts +++ b/packages/shared/src/lib/core/wallet/actions/signEvmTransaction.ts @@ -10,7 +10,7 @@ export async function signEvmTransaction( transaction: EvmTransactionData, chain: IChain, account: IAccountState -): Promise { +): Promise { const { chainId, coinType } = chain.getConfiguration() ?? {} const bip44Path = { coinType, @@ -21,14 +21,20 @@ export async function signEvmTransaction( const { index } = account const transactionCopy = structuredClone(transaction) + let signature: string | undefined if (get(isSoftwareProfile)) { // Follow MetaMask's convention around incrementing address indices instead of account indices bip44Path.addressIndex = index - return await signEvmTransactionWithStronghold(transactionCopy, chainId, bip44Path) + signature = await signEvmTransactionWithStronghold(transactionCopy, chainId, bip44Path) } else if (get(isActiveLedgerProfile)) { bip44Path.account = index delete transactionCopy?.estimatedGas - return (await Ledger.signEvmTransaction(transactionCopy, chainId, bip44Path)) as string + signature = (await Ledger.signEvmTransaction(transactionCopy, chainId, bip44Path)) as string } + + if (!signature) { + throw new Error('Failed to sign EVM transaction') + } + return signature } From 66c12a6624cabd12369d514d4559e8ad4085454c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:55:31 +0100 Subject: [PATCH 3/4] chore: bump es5-ext from 0.10.62 to 0.10.63 (#2006) Bumps [es5-ext](https://github.com/medikoo/es5-ext) from 0.10.62 to 0.10.63. - [Release notes](https://github.com/medikoo/es5-ext/releases) - [Changelog](https://github.com/medikoo/es5-ext/blob/main/CHANGELOG.md) - [Commits](https://github.com/medikoo/es5-ext/compare/v0.10.62...v0.10.63) --- updated-dependencies: - dependency-name: es5-ext dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tuditi <45079109+Tuditi@users.noreply.github.com> --- yarn.lock | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index bcd8b0ea03..2912d40331 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5258,13 +5258,14 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" -es5-ext@^0.10.35, es5-ext@^0.10.46, es5-ext@^0.10.50, es5-ext@^0.10.53, es5-ext@^0.10.61, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.46: - version "0.10.62" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.62.tgz#5e6adc19a6da524bf3d1e02bbc8960e5eb49a9a5" - integrity sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA== +es5-ext@^0.10.35, es5-ext@^0.10.46, es5-ext@^0.10.50, es5-ext@^0.10.53, es5-ext@^0.10.61, es5-ext@^0.10.62, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.46: + version "0.10.63" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.63.tgz#9c222a63b6a332ac80b1e373b426af723b895bd6" + integrity sha512-hUCZd2Byj/mNKjfP9jXrdVZ62B8KuA/VoK7X8nUh5qT+AxDmcbvZz041oDVZdbIN1qW6XY9VDNwzkvKnZvK2TQ== dependencies: es6-iterator "^2.0.3" es6-symbol "^3.1.3" + esniff "^2.0.1" next-tick "^1.1.0" es6-error@^4.1.1: @@ -5528,6 +5529,16 @@ eslint@8.42.0: strip-json-comments "^3.1.0" text-table "^0.2.0" +esniff@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/esniff/-/esniff-2.0.1.tgz#a4d4b43a5c71c7ec51c51098c1d8a29081f9b308" + integrity sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg== + dependencies: + d "^1.0.1" + es5-ext "^0.10.62" + event-emitter "^0.3.5" + type "^2.7.2" + espree@^9.5.2, espree@^9.6.0: version "9.6.1" resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" From e1c20c942dcaa4a29ee29d2756b79e3f163ae7e6 Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Thu, 29 Feb 2024 14:06:35 +0100 Subject: [PATCH 4/4] disable burning on evm chain (#2017) Co-authored-by: Tuditi <45079109+Tuditi@users.noreply.github.com> --- .../desktop/components/menus/CollectibleDetailsMenu.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/desktop/components/menus/CollectibleDetailsMenu.svelte b/packages/desktop/components/menus/CollectibleDetailsMenu.svelte index 627e20ad4a..a1cea4bfcf 100644 --- a/packages/desktop/components/menus/CollectibleDetailsMenu.svelte +++ b/packages/desktop/components/menus/CollectibleDetailsMenu.svelte @@ -3,7 +3,8 @@ import { openUrlInBrowser } from '@core/app' import { handleError } from '@core/error/handlers' import { localize } from '@core/i18n' - import { IIrc27Nft, Nft, isIrc27Nft, isNftLocked } from '@core/nfts' + import { isEvmChain } from '@core/network' + import { IIrc27Nft, Nft, isNftLocked } from '@core/nfts' import { checkActiveProfileAuthAsync } from '@core/profile/actions' import { activeProfile, updateActiveProfile } from '@core/profile/stores' import { CollectiblesRoute, collectiblesRouter } from '@core/router' @@ -14,7 +15,7 @@ export let nft: Nft $: isLocked = isNftLocked(nft) - $: isBurnDisabled = isLocked || !isIrc27Nft(nft) + $: isBurnDisabled = isLocked || isEvmChain(nft.networkId) $: isCurrentPfp = $activeProfile.pfp?.id === nft.id function onSetPfpClick(): void {