Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: pass correct props to sign-typed-data popup #2701

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<script lang="ts">
import { localize } from '@core/i18n'
import { PopupId, closePopup, openPopup } from '@desktop/auxiliary/popup'
import { IConnectedDapp } from '@auxiliary/wallet-connect/interface'
import { CallbackParameters } from '@auxiliary/wallet-connect/types'
import { WCRequestInfo } from '@auxiliary/wallet-connect/types'
import { Alert, JsonTree, Table, Text } from '@bloomwalletio/ui'
import { IAccountState } from '@core/account'
import { IEvmNetwork } from '@core/network'
import { AccountLabel, DappInfo } from '@ui'
import { checkActiveProfileAuth } from '@core/profile/actions'
import { LedgerAppName } from '@core/ledger'
import PopupTemplate from '../PopupTemplate.svelte'
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'
import { MILLISECONDS_PER_SECOND } from '@core/utils'
import { time } from '@core/app/stores'
import { RequestExpirationAlert } from '@views/dashboard/drawers/dapp-config/components'

export let data: string
export let version: SignTypedDataVersion.V3 | SignTypedDataVersion.V4
export let account: IAccountState
export let evmNetwork: IEvmNetwork
export let dapp: IConnectedDapp
export let verifiedState: DappVerification
export let callback: (params: CallbackParameters) => void
export let requestInfo: WCRequestInfo

const { dapp, responseCallback, verifiedState, evmNetwork, expiryTimestamp } = requestInfo
$: hasExpired =
expiryTimestamp === undefined ? false : expiryTimestamp * MILLISECONDS_PER_SECOND - $time.getTime() <= 0

let isBusy = false

Expand All @@ -37,7 +38,7 @@
const result = await signEip712Message(data, version, evmNetwork.coinType, account)
closePopup({ forceClose: true })

callback({ result })
responseCallback({ result })
openPopup({
id: PopupId.SuccessfulDappInteraction,
props: {
Expand Down Expand Up @@ -66,16 +67,22 @@
continueButton={{
text: localize('popups.signMessage.action'),
onClick: onConfirmClick,
disabled: hasExpired,
}}
busy={isBusy}
>
<DappInfo
slot="banner"
metadata={dapp.metadata}
{verifiedState}
showLink={false}
classes="bg-surface-1 dark:bg-surface-1-dark pb-4"
/>
<svelte:fragment slot="banner">
{#if dapp}
<DappInfo
slot="banner"
metadata={dapp.metadata}
{verifiedState}
showLink={false}
classes="bg-surface-1 dark:bg-surface-1-dark pb-4"
/>
<RequestExpirationAlert {expiryTimestamp} />
{/if}
</svelte:fragment>

<div class="space-y-5">
<div>
Expand Down
Loading