Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into 2390-add-gas-selec…
Browse files Browse the repository at this point in the history
…tor-to-transaction-flow
  • Loading branch information
Tuditi committed May 15, 2024
2 parents dde9e7f + 3f495eb commit 0db50a9
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
id: PopupId.SuccessfulDappInteraction,
props: {
successMessage: getSuccessMessage(),
url: dapp?.metadata?.url,
dapp,
},
})
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
id: PopupId.SuccessfulDappInteraction,
props: {
successMessage: localize('popups.signMessage.success'),
url: dapp.metadata?.url,
dapp,
},
})
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { SignTypedDataVersion } from '@metamask/eth-sig-util'
import { signEip712Message } from '@core/wallet/actions/signEip712Message'
import { DappVerification } from '@auxiliary/wallet-connect/enums'
import { handleError } from '@core/error/handlers'
export let data: string
export let version: SignTypedDataVersion.V3 | SignTypedDataVersion.V4
Expand All @@ -32,7 +33,6 @@
}
isBusy = true
try {
const result = await signEip712Message(data, version, evmNetwork.coinType, account)
closePopup({ forceClose: true })
Expand All @@ -42,12 +42,11 @@
id: PopupId.SuccessfulDappInteraction,
props: {
successMessage: localize('popups.signMessage.success'),
url: dapp.metadata?.url,
dapp,
},
})
} catch (err) {
closePopup({ forceClose: true })
callback({ error: err.message ?? localize('error.global.generic') })
handleError(err)
} finally {
isBusy = false
}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/components/popup/popups/SiwePopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
id: PopupId.SuccessfulDappInteraction,
props: {
successMessage: localize('popups.signMessage.success'),
url: dapp.metadata?.url,
dapp,
},
})
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import { Alert, Text } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { closePopup } from '@desktop/auxiliary/popup/actions'
import { getConnectedDappByOrigin } from '@auxiliary/wallet-connect/stores'
import { DappInfo } from '@ui'
import { IConnectedDapp } from '@auxiliary/wallet-connect/interface'
export let url: string | undefined
export let dapp: IConnectedDapp | undefined
export let successMessage: string
const dapp = getConnectedDappByOrigin(url)
</script>

<PopupTemplate
Expand All @@ -21,7 +19,7 @@
>
<DappInfo
slot="banner"
metadata={dapp.metadata}
metadata={dapp?.metadata}
showLink={false}
classes="bg-surface-1 dark:bg-surface-1-dark pb-4"
/>
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop/lib/electron/managers/transak.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ export default class TransakManager implements ITransakManager {
public positionWindow(): void {
try {
if (windows.transak) {
const [mainWindowX, mainWindowY] = windows.main?.getPosition() ?? []
const [, mainWindowHeight] = windows.main?.getSize() ?? []
const [, bodyHeight] = windows.main?.getContentSize() ?? []
const [mainWindowX, mainWindowY] = windows.main?.getPosition() ?? [0, 0]
const [, mainWindowHeight] = windows.main?.getSize() ?? [1280, 720]
const [, bodyHeight] = windows.main?.getContentSize() ?? [1280, 720]

const menuHeight = mainWindowHeight - bodyHeight

Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/components/molecules/DappInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import { Avatar, Icon, IconName, Link, Text } from '@bloomwalletio/ui'
import { DappVerificationPill } from '@ui'
import { VERIFICATION_ICONS } from '@auxiliary/wallet-connect/constants/verification-icons.constant'
import { IDappMetadata } from '@auxiliary/wallet-connect/interface'
export let metadata: CoreTypes.Metadata | undefined
export let metadata: CoreTypes.Metadata | IDappMetadata | undefined
export let verifiedState: DappVerification | undefined = undefined
export let showLink: boolean = true
export let classes: string = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ import { NetworkId, getEvmNetwork } from '@core/network'
import { JsonRpcResponse } from '@walletconnect/jsonrpc-types'
import { getSdkError } from '@walletconnect/utils'
import { Web3WalletTypes } from '@walletconnect/web3wallet'
import { getConnectedDappByOrigin, getWalletClient, setConnectedDapps, updateVerificationStateForDapp } from '../stores'
import {
getConnectedDappBySessionTopic,
getWalletClient,
setConnectedDapps,
updateVerificationStateForDapp,
} from '../stores'
import { CallbackParameters } from '../types'
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, RpcMethod } from '../enums'
import { EvmTransactionData, getEvmTransactionFromHexString } from '@core/layer-2'
import { activeProfileId } from '@core/profile/stores'
import { get } from 'svelte/store'

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
Expand All @@ -19,12 +26,6 @@ export function onSessionRequest(event: Web3WalletTypes.SessionRequest): void {
const { request, chainId } = params
const method = request.method as RpcMethod

const dapp = getConnectedDappByOrigin(verifyContext.verified.origin)
const verifiedState = verifyContext.verified.isScam
? DappVerification.Scam
: (verifyContext.verified.validation as DappVerification)
updateVerificationStateForDapp(verifyContext.verified.origin, verifiedState)

function returnResponse({ result, error }: CallbackParameters): void {
const response: JsonRpcResponse | undefined = result
? {
Expand All @@ -49,6 +50,17 @@ export function onSessionRequest(event: Web3WalletTypes.SessionRequest): void {
}
}

if (!get(activeProfileId)) {
returnResponse({ error: getSdkError('SESSION_SETTLEMENT_FAILED') })
return
}

const dapp = getConnectedDappBySessionTopic(topic)
const verifiedState = verifyContext.verified.isScam
? DappVerification.Scam
: (verifyContext.verified.validation as DappVerification)
updateVerificationStateForDapp(verifyContext.verified.origin, verifiedState)

if (!dapp) {
returnResponse({ error: getSdkError('SESSION_SETTLEMENT_FAILED') })
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ export function getConnectedDapps(): IConnectedDapp[] {
export function getConnectedDappByOrigin(origin: string): IConnectedDapp | undefined {
return get(connectedDapps).find((dapp) => dapp.metadata?.url === origin)
}

export function getConnectedDappBySessionTopic(sessionTopic: string): IConnectedDapp | undefined {
return get(connectedDapps).find((dapp) => dapp.session?.topic === sessionTopic)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const DEFAULT_EXPLORER_URLS: Readonly<{ [key in NetworkId]?: string }> =
[SupportedNetworkId.Testnet]: 'https://explorer.shimmer.network/testnet/',
[SupportedNetworkId.IotaEvm]: 'https://explorer.evm.iota.org',
[SupportedNetworkId.ShimmerEvm]: 'https://explorer.evm.shimmer.network',
[SupportedNetworkId.IotaTestnetEvm]: 'https://explorer.evm.testnet.iota.org',
[SupportedNetworkId.IotaTestnetEvm]: 'https://explorer.evm.testnet.iotaledger.net',
[SupportedNetworkId.TestnetEvm]: 'https://explorer.evm.testnet.shimmer.network',
[SupportedNetworkId.Ethereum]: 'https://eth.blockscout.com',
[SupportedNetworkId.Sepolia]: 'https://eth-sepolia.blockscout.com',
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/lib/core/network/enums/chain-id.enum.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export enum ChainId {
IotaEvm = '8822',
ShimmerEvm = '148',
IotaTestnetEvm = '1073',
TestnetEvm = '1075',
IotaTestnetEvm = '1075',
TestnetEvm = '1073',
Ethereum = '1',
Sepolia = '11155111',
}

0 comments on commit 0db50a9

Please sign in to comment.