From 7674a66de67eb4eb62b5d38840d869fea55ae8bc Mon Sep 17 00:00:00 2001 From: Jack Works <5390719+Jack-Works@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:23:50 +0000 Subject: [PATCH 1/2] wip --- .vscode/settings.json | 3 +- .../services/identity/persona/sign.ts | 62 ++++++++++--------- .../services/wallet/services/send.ts | 38 +++++++----- .../hooks/useClaimNftRedpacketCallback.ts | 10 ++- .../src/SiteAdaptor/hooks/useSignedMessage.ts | 3 +- .../src/Web3/EVM/apis/SignerAPI.ts | 23 +++++-- .../evm/src/helpers/createAccount.ts | 12 ++-- .../evm/src/helpers/signMessage.ts | 13 ++-- .../evm/src/helpers/signTransaction.ts | 12 ++-- .../evm/src/libs/AccountTransaction.ts | 2 - .../web3-shared/evm/src/libs/PayloadEditor.ts | 58 ++++++++++------- packages/web3-shared/evm/src/libs/Signer.ts | 21 ------- packages/web3-shared/evm/src/libs/index.ts | 1 - packages/web3-shared/evm/src/types/index.ts | 14 ++--- 14 files changed, 139 insertions(+), 133 deletions(-) delete mode 100644 packages/web3-shared/evm/src/libs/Signer.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index b32cb66cdda3..d92bbad25782 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,8 @@ { "typescript.tsdk": "node_modules/typescript/lib", "typescript.preferences.importModuleSpecifierEnding": "js", - "typescript.experimental.useTsgo": true, + // https://github.com/microsoft/typescript-go/issues/2780 + "typescript.experimental.useTsgo": false, "js/ts.implicitProjectConfig.module": "NodeNext", "js/ts.implicitProjectConfig.target": "ESNext", "editor.formatOnSave": true, diff --git a/packages/mask/background/services/identity/persona/sign.ts b/packages/mask/background/services/identity/persona/sign.ts index bb64692a2bd7..ed554aee510f 100644 --- a/packages/mask/background/services/identity/persona/sign.ts +++ b/packages/mask/background/services/identity/persona/sign.ts @@ -11,6 +11,35 @@ import { import { queryPersonasWithPrivateKey } from '../../../database/persona/web.js' import { openPopupWindow } from '../../helper/popup-opener.js' +async function getIdentifier( + message: unknown, + identifier?: ECKeyIdentifier, + source?: string, + silent = false, +) { + if (!identifier || !silent) { + const requestID = crypto.randomUUID() + await openPopupWindow(PopupRoutes.PersonaSignRequest, { + message: JSON.stringify(message), + requestID, + identifier: identifier?.toText(), + source, + }) + + return timeout( + new Promise((resolve, reject) => { + MaskMessages.events.personaSignRequest.on((approval) => { + if (approval.requestID !== requestID) return + if (!approval.selectedPersona) reject(new Error('The user refused to sign message with persona.')) + resolve(approval.selectedPersona!) + }) + }), + 60 * 1000, + 'Timeout of signing with persona.', + ) + } + return identifier +} /** * Generate a signature w or w/o confirmation from user */ @@ -20,37 +49,12 @@ export async function signWithPersona( identifier?: ECKeyIdentifier, source?: string, silent = false, -): Promise { - const getIdentifier = async () => { - if (!identifier || !silent) { - const requestID = crypto.randomUUID() - await openPopupWindow(PopupRoutes.PersonaSignRequest, { - message: JSON.stringify(message), - requestID, - identifier: identifier?.toText(), - source, - }) - - return timeout( - new Promise((resolve, reject) => { - MaskMessages.events.personaSignRequest.on((approval) => { - if (approval.requestID !== requestID) return - if (!approval.selectedPersona) - reject(new Error('The user refused to sign message with persona.')) - resolve(approval.selectedPersona!) - }) - }), - 60 * 1000, - 'Timeout of signing with persona.', - ) - } - return identifier - } - - const identifier_ = await getIdentifier() +): Promise +{ + identifier = await getIdentifier(message, identifier, source, silent) // find the persona with the signer's identifier - const persona = (await queryPersonasWithPrivateKey()).find((x) => x.identifier === identifier_) + const persona = (await queryPersonasWithPrivateKey()).find((x) => x.identifier === identifier) if (!persona?.privateKey.d) throw new Error('Persona not found') return Signer.sign(type, Buffer.from(fromBase64URL(persona.privateKey.d)), message) diff --git a/packages/mask/background/services/wallet/services/send.ts b/packages/mask/background/services/wallet/services/send.ts index f6fea576f4c6..1a3e8e8bdcd0 100644 --- a/packages/mask/background/services/wallet/services/send.ts +++ b/packages/mask/background/services/wallet/services/send.ts @@ -1,5 +1,5 @@ import type { JsonRpcRequest } from 'web3-types' -import { ECKeyIdentifier, type SignType } from '@masknet/shared-base' +import { ECKeyIdentifier, SignType } from '@masknet/shared-base' import { EVMRequestReadonly, EVMWeb3Readonly } from '@masknet/web3-providers' import { ChainId, @@ -8,10 +8,10 @@ import { EthereumMethodType, PayloadEditor, type TransactionOptions, - Signer, } from '@masknet/web3-shared-evm' import { signWithWallet } from './wallet/index.js' import { signWithPersona } from '../../identity/persona/sign.js' +import type { TransactionSerializable } from 'viem' /** * The entrance of all RPC requests to MaskWallet. @@ -23,25 +23,33 @@ export async function send(payload: JsonRpcRequest, options?: TransactionOptions from, chainId = options?.chainId ?? ChainId.Mainnet, signableMessage, - signableConfig, + signableTransaction, } = PayloadEditor.fromPayload(payload, options) const identifier = ECKeyIdentifier.from(options?.identifier).unwrapOr(undefined) - const signer = - identifier ? - new Signer(identifier, (type: SignType, message: T, identifier?: ECKeyIdentifier) => - signWithPersona(type, message, identifier, undefined, true), - ) - : new Signer(owner || from!, signWithWallet) + const signTransaction = async (transaction: TransactionSerializable) => { + if (identifier) { + return signWithPersona(SignType.Transaction, transaction, identifier) + } else { + return signWithWallet(SignType.Transaction, transaction, owner || from!) + } + } + const signMessageOrTypedData = async (type: SignType.Message | SignType.TypedData, message: string) => { + if (identifier) { + return signWithPersona(type, message, identifier) + } else { + return signWithWallet(type, message, owner || from!) + } + } switch (payload.method) { case EthereumMethodType.eth_sendTransaction: case EthereumMethodType.MASK_REPLACE_TRANSACTION: - if (!signableConfig) throw new Error('No transaction to be sent.') + if (!signableTransaction) throw new Error('No transaction to be sent.') try { return createJsonRpcResponse( pid, - await EVMWeb3Readonly.sendSignedTransaction(await signer.signTransaction(signableConfig), { + await EVMWeb3Readonly.sendSignedTransaction(await signTransaction(signableTransaction), { chainId, providerURL, }), @@ -53,21 +61,21 @@ export async function send(payload: JsonRpcRequest, options?: TransactionOptions case EthereumMethodType.personal_sign: try { if (!signableMessage) throw new Error('No message to be signed.') - return createJsonRpcResponse(pid, await signer.signMessage(signableMessage)) + return createJsonRpcResponse(pid, await signMessageOrTypedData(SignType.Message, signableMessage)) } catch (error) { throw ErrorEditor.from(error, null, 'Failed to sign message.').error } case EthereumMethodType.eth_signTypedData_v4: try { if (!signableMessage) throw new Error('No typed data to be signed.') - return createJsonRpcResponse(pid, await signer.signTypedData(signableMessage)) + return createJsonRpcResponse(pid, await signMessageOrTypedData(SignType.TypedData, signableMessage)) } catch (error) { throw ErrorEditor.from(error, null, 'Failed to sign typed data.').error } case EthereumMethodType.eth_signTransaction: try { - if (!signableConfig) throw new Error('No transaction to be signed.') - return createJsonRpcResponse(pid, await signer.signTransaction(signableConfig)) + if (!signableTransaction) throw new Error('No transaction to be signed.') + return createJsonRpcResponse(pid, await signTransaction(signableTransaction)) } catch (error) { throw ErrorEditor.from(error, null, 'Failed to sign transaction.').error } diff --git a/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useClaimNftRedpacketCallback.ts b/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useClaimNftRedpacketCallback.ts index 16d594a2d363..74e8844ca652 100644 --- a/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useClaimNftRedpacketCallback.ts +++ b/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useClaimNftRedpacketCallback.ts @@ -7,7 +7,7 @@ import { EVMWeb3 } from '@masknet/web3-providers' import { useNftRedPacketContract } from './useNftRedPacketContract.js' import type { RedPacketNftJSONPayload } from '@masknet/web3-providers/types' import { useSignedMessage } from './useSignedMessage.js' -import { useMemo } from 'react' +import type { Hex } from 'viem' const EXTRA_GAS_PER_NFT = 335 @@ -16,12 +16,10 @@ export function useClaimNftRedpacketCallback(payload: RedPacketNftJSONPayload, t const nftRedPacketContract = useNftRedPacketContract(chainId) const { refetch } = useSignedMessage(account, payload) const id = payload.id - const signedMsg = useMemo(() => { - return signMessage(account, payload.privateKey).signature ?? '' - }, [account, payload.privateKey]) return useAsyncFn(async () => { - if (!nftRedPacketContract || !id || !account || !totalAmount || !signedMsg) return + if (!nftRedPacketContract || !id || !account || !totalAmount || !payload.privateKey) return + const signedMsg = await signMessage(account, payload.privateKey as Hex) const transaction = nftRedPacketContract.methods.claim(id, signedMsg, account) const estimatedGas = await transaction.estimateGas({ from: account }) const tx = await new ContractTransaction(nftRedPacketContract).fillAll(transaction, { @@ -30,5 +28,5 @@ export function useClaimNftRedpacketCallback(payload: RedPacketNftJSONPayload, t chainId, }) return EVMWeb3.sendTransaction(tx, { chainId }) - }, [id, refetch, account, chainId, totalAmount, signedMsg]) + }, [id, refetch, account, chainId, totalAmount, account, payload.privateKey]) } diff --git a/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useSignedMessage.ts b/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useSignedMessage.ts index c94569d85859..ad58a7d79811 100644 --- a/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useSignedMessage.ts +++ b/packages/plugins/RedPacket/src/SiteAdaptor/hooks/useSignedMessage.ts @@ -4,6 +4,7 @@ import { type RedPacketJSONPayload, type RedPacketNftJSONPayload } from '@maskne import { signMessage } from '@masknet/web3-shared-evm' import { useQuery } from '@tanstack/react-query' import { usePlatformType } from './usePlatformType.js' +import type { Hex } from 'viem' // TODO NFT redpacket is not supported by the API yet. export function useSignedMessage( @@ -34,7 +35,7 @@ export function useSignedMessage( queryKey: ['red-packet', 'signed-message', rpid, version, password, account, profile, isTokenRedPacket], queryFn: async () => { if (isTokenRedPacket && version <= 3) return password ?? null - if (password) return signMessage(account, password).signature + if (password) return signMessage(account, password as Hex) if (!profile) return '' return ( (await FireflyRedPacket.createClaimSignature({ diff --git a/packages/web3-providers/src/Web3/EVM/apis/SignerAPI.ts b/packages/web3-providers/src/Web3/EVM/apis/SignerAPI.ts index 4da41b4ed21c..6f3f345fb23c 100644 --- a/packages/web3-providers/src/Web3/EVM/apis/SignerAPI.ts +++ b/packages/web3-providers/src/Web3/EVM/apis/SignerAPI.ts @@ -1,10 +1,25 @@ import defer * as _metamask_eth_sig_util from '@metamask/eth-sig-util' -import { signTransaction, type Transaction } from '@masknet/web3-shared-evm' +import { signTransaction } from '@masknet/web3-shared-evm' import { SignType, toHex } from '@masknet/shared-base' import { unreachable } from '@masknet/kit' +import type { Hex, TransactionSerializable } from 'viem' export class Signer { - static async sign(type: SignType, key: Buffer, message: unknown): Promise { + static async sign( + type: SignType.Message | SignType.TypedData, + key: Buffer, + message: string, + ): Promise + static async sign( + type: SignType.Transaction, + key: Buffer, + message: TransactionSerializable, + ): Promise + static async sign( + type: SignType, + key: Buffer, + message: string | TransactionSerializable, + ): Promise { switch (type) { case SignType.Message: return _metamask_eth_sig_util.personalSign({ @@ -18,12 +33,12 @@ export class Signer { version: _metamask_eth_sig_util.SignTypedDataVersion.V4, }) case SignType.Transaction: - const transaction = message as Transaction + const transaction = message as TransactionSerializable const chainId = transaction.chainId if (!chainId) throw new Error('Invalid chain id.') - const { rawTransaction } = await signTransaction(transaction, toHex(key)) + const rawTransaction = await signTransaction(transaction, toHex(key) as Hex) if (!rawTransaction) throw new Error('Failed to sign transaction.') return rawTransaction diff --git a/packages/web3-shared/evm/src/helpers/createAccount.ts b/packages/web3-shared/evm/src/helpers/createAccount.ts index b527902e6afb..66b01e92ba54 100644 --- a/packages/web3-shared/evm/src/helpers/createAccount.ts +++ b/packages/web3-shared/evm/src/helpers/createAccount.ts @@ -1,9 +1,7 @@ -import type { Account } from 'web3-core' -import defer * as Web3Accounts from 'web3-eth-accounts' -import type { Accounts } from 'web3-eth-accounts' +import { generatePrivateKey, privateKeyToAddress } from 'viem/accounts' -export function createAccount(): Account { - const Accounts_ = Web3Accounts.default as unknown as typeof Accounts - const accounts = new Accounts_() - return accounts.create() +export function createAccount() { + const privateKey = generatePrivateKey() + const address = privateKeyToAddress(privateKey) + return { privateKey, address } } diff --git a/packages/web3-shared/evm/src/helpers/signMessage.ts b/packages/web3-shared/evm/src/helpers/signMessage.ts index f6cb889203ce..27d0dbf75c27 100644 --- a/packages/web3-shared/evm/src/helpers/signMessage.ts +++ b/packages/web3-shared/evm/src/helpers/signMessage.ts @@ -1,8 +1,9 @@ -import defer * as Web3Accounts from 'web3-eth-accounts' -import type { Accounts } from 'web3-eth-accounts' +import type { Hex } from 'viem' +import { signMessage as viem_sign } from 'viem/accounts' -export function signMessage(message: string, privateKey: string): Web3Accounts.Sign { - const Accounts_ = Web3Accounts.default as unknown as typeof Accounts - const accounts = new Accounts_() - return accounts.sign(message, privateKey) +export function signMessage(message: string, privateKey: Hex): Promise { + return viem_sign({ + message: message.startsWith('0x') ? { raw: message as Hex } : message, + privateKey, + }) } diff --git a/packages/web3-shared/evm/src/helpers/signTransaction.ts b/packages/web3-shared/evm/src/helpers/signTransaction.ts index 69ea4b572ed4..973a20e14ab2 100644 --- a/packages/web3-shared/evm/src/helpers/signTransaction.ts +++ b/packages/web3-shared/evm/src/helpers/signTransaction.ts @@ -1,10 +1,6 @@ -import defer * as Web3Accounts from 'web3-eth-accounts' -import type { Accounts } from 'web3-eth-accounts' -import type { Transaction } from '../types/index.js' +import { signTransaction as viem_signTransaction } from 'viem/accounts' +import type { Hex, TransactionSerializable } from 'viem' -export function signTransaction(transaction: Transaction, privateKey: string) { - if (typeof transaction.nonce === 'undefined') throw new Error('Nonce is required.') - const Accounts_ = Web3Accounts.default as unknown as typeof Accounts - const accounts = new Accounts_() - return accounts.signTransaction(transaction, privateKey) +export function signTransaction(transaction: TransactionSerializable, privateKey: Hex) { + return viem_signTransaction({ privateKey, transaction }) } diff --git a/packages/web3-shared/evm/src/libs/AccountTransaction.ts b/packages/web3-shared/evm/src/libs/AccountTransaction.ts index 64b3c7c1db98..977513ffb3f3 100644 --- a/packages/web3-shared/evm/src/libs/AccountTransaction.ts +++ b/packages/web3-shared/evm/src/libs/AccountTransaction.ts @@ -57,7 +57,6 @@ export class AccountTransaction { maxFeePerGas, data, nonce, - _disableExceptionSnackbar, _disableSuccessSnackbar, _disableSnackbar, } = { @@ -76,7 +75,6 @@ export class AccountTransaction { maxPriorityFeePerGas: maxPriorityFeePerGas ? normalizeHex(maxPriorityFeePerGas) : undefined, maxFeePerGas: maxFeePerGas ? normalizeHex(maxFeePerGas) : undefined, nonce, - _disableExceptionSnackbar, _disableSuccessSnackbar, _disableSnackbar, }, diff --git a/packages/web3-shared/evm/src/libs/PayloadEditor.ts b/packages/web3-shared/evm/src/libs/PayloadEditor.ts index ba1e85d8eea2..bc91a9ffb9d0 100644 --- a/packages/web3-shared/evm/src/libs/PayloadEditor.ts +++ b/packages/web3-shared/evm/src/libs/PayloadEditor.ts @@ -1,8 +1,6 @@ import { first, isUndefined, omitBy } from 'lodash-es' -import defer * as web3_utils from 'web3-utils' import type { JsonRpcRequest } from 'web3-types' import type { Wallet } from '@masknet/shared-base' -import { formatEthereumAddress } from '../helpers/formatter.js' import { parseChainId } from '../helpers/parseChainId.js' import { createJsonRpcRequest } from '../helpers/createJsonRpcRequest.js' import { @@ -14,6 +12,7 @@ import { import { readonlyMethodType } from '../helpers/isReadonlyMethodType.js' import { riskyMethodType } from '../helpers/isRiskyMethodType.js' import { gasConsumingMethodType } from '../helpers/isGasConsumingMethodType.js' +import { hexToBigInt, hexToNumber, isHex, type Hex, type TransactionSerializable } from 'viem' type Options = Pick @@ -87,7 +86,7 @@ export class PayloadEditor { return omitBy( { ...raw, - nonce: parseHexNumber(raw?.nonce), + nonce: toNumber(raw?.nonce), from: raw?.from ?? this.options?.account, chainId: parseChainId(raw?.chainId) ?? this.options?.chainId, }, @@ -124,24 +123,27 @@ export class PayloadEditor { } } - get signableConfig() { + get signableTransaction(): TransactionSerializable | undefined { if (!this.config) return - return omitBy( - { - ...this.config, - from: this.config.from ? formatEthereumAddress(this.config.from) : '', - value: parseHexNumberString(this.config.value), - gas: parseHexNumberString(this.config.gas), - gasPrice: parseHexNumberString(this.config.gasPrice), - maxFeePerGas: parseHexNumberString(this.config.maxFeePerGas), - maxPriorityFeePerGas: parseHexNumberString(this.config.maxPriorityFeePerGas), - // TODO: revert to parseHexNumberString after updating MaskCore - chainId: parseHexNumber(this.config.chainId), - nonce: parseHexNumberString(this.config.nonce), - }, - isUndefined, - ) as Transaction + const tx = { + ...this.config, + type: + this.config.type === '0x0' ? 'legacy' + : this.config.type === '0x1' ? 'eip2930' + : this.config.type === '0x2' ? 'eip1559' + : undefined, + to: this.config.to as Hex, + data: this.config.data as Hex, + value: toBigInt(this.config.value), + gas: toBigInt(this.config.gas), + gasPrice: toBigInt(this.config.gasPrice), + maxFeePerGas: toBigInt(this.config.maxFeePerGas), + maxPriorityFeePerGas: toBigInt(this.config.maxPriorityFeePerGas), + chainId: toNumber(this.config.chainId), + nonce: toNumber(this.config.nonce), + } as TransactionSerializable + return omitBy(tx, isUndefined) } get risky() { @@ -179,10 +181,20 @@ export class PayloadEditor { } } -function parseHexNumberString(hex: string | number | undefined) { - return typeof hex !== 'undefined' ? web3_utils.hexToNumberString(hex ?? '0x0') : undefined +function toBigInt(hex: string | number | undefined) { + if (typeof hex === 'number') return BigInt(hex) + if (typeof hex === 'string') { + if (isHex(hex)) return hexToBigInt(hex) + return BigInt(hex) + } + return undefined } -function parseHexNumber(hex: string | number | undefined) { - return typeof hex !== 'undefined' ? (web3_utils.hexToNumber(hex) as number) : undefined +function toNumber(hex: string | number | undefined) { + if (typeof hex === 'number') return hex + if (typeof hex === 'string') { + if (isHex(hex)) return Number(hexToNumber(hex)) + return Number(hex) + } + return undefined } diff --git a/packages/web3-shared/evm/src/libs/Signer.ts b/packages/web3-shared/evm/src/libs/Signer.ts deleted file mode 100644 index e3e5555a7a24..000000000000 --- a/packages/web3-shared/evm/src/libs/Signer.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { SignType } from '@masknet/shared-base' -import type { Transaction } from '@masknet/web3-shared-evm' - -export class Signer { - constructor( - private identifier: T, - private sign: (type: SignType, message: string | Transaction, identifier: T) => Promise, - ) {} - - signMessage(message: string): Promise { - return this.sign(SignType.Message, message, this.identifier) - } - - signTypedData(data: string): Promise { - return this.sign(SignType.TypedData, data, this.identifier) - } - - signTransaction(transaction: Transaction): Promise { - return this.sign(SignType.Transaction, transaction, this.identifier) - } -} diff --git a/packages/web3-shared/evm/src/libs/index.ts b/packages/web3-shared/evm/src/libs/index.ts index 0191b7bc38b7..a8b5ba6e1c2b 100644 --- a/packages/web3-shared/evm/src/libs/index.ts +++ b/packages/web3-shared/evm/src/libs/index.ts @@ -8,5 +8,4 @@ export * from './GasEditor.js' export * from './PayloadEditor.js' export * from './ProviderURL.js' export * from './RequestID.js' -export * from './Signer.js' export * from './Web3.js' diff --git a/packages/web3-shared/evm/src/types/index.ts b/packages/web3-shared/evm/src/types/index.ts index 2041ee92185c..e73e1169806e 100644 --- a/packages/web3-shared/evm/src/types/index.ts +++ b/packages/web3-shared/evm/src/types/index.ts @@ -406,7 +406,11 @@ export interface Transaction { from?: string to?: string value?: string - /** gasLimit */ + // value?: bigint + // gas?: bigint + // gasPrice?: bigint + // maxPriorityFeePerGas?: bigint + // maxFeePerGas?: bigint gas?: string gasPrice?: string maxPriorityFeePerGas?: string @@ -416,16 +420,8 @@ export interface Transaction { chainId?: number type?: '0x0' | '0x1' | '0x2' - // CELO - feeCurrency?: string // address of the ERC20 contract to use to pay for gas and the gateway fee - gatewayFeeRecipient?: string // coinbase address of the full serving the light client's transactions - gatewayFee?: string // value paid to the gateway fee recipient, denominated in the fee currency - _disableSnackbar?: boolean _disableSuccessSnackbar?: boolean - _disableExceptionSnackbar?: boolean - - _isOKXSwap?: boolean } export type TransactionReceipt = Web3TransactionReceipt export type TransactionDetailed = Web3Transaction From 6bc680b8fc79429dcd25b5bd467a434c43251fee Mon Sep 17 00:00:00 2001 From: Jack-Works Date: Mon, 9 Mar 2026 09:43:41 +0000 Subject: [PATCH 2/2] fix: linter --- .../mask/background/services/identity/persona/sign.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/mask/background/services/identity/persona/sign.ts b/packages/mask/background/services/identity/persona/sign.ts index ed554aee510f..57c8d3581f07 100644 --- a/packages/mask/background/services/identity/persona/sign.ts +++ b/packages/mask/background/services/identity/persona/sign.ts @@ -11,12 +11,7 @@ import { import { queryPersonasWithPrivateKey } from '../../../database/persona/web.js' import { openPopupWindow } from '../../helper/popup-opener.js' -async function getIdentifier( - message: unknown, - identifier?: ECKeyIdentifier, - source?: string, - silent = false, -) { +async function getIdentifier(message: unknown, identifier?: ECKeyIdentifier, source?: string, silent = false) { if (!identifier || !silent) { const requestID = crypto.randomUUID() await openPopupWindow(PopupRoutes.PersonaSignRequest, { @@ -49,8 +44,7 @@ export async function signWithPersona( identifier?: ECKeyIdentifier, source?: string, silent = false, -): Promise -{ +): Promise { identifier = await getIdentifier(message, identifier, source, silent) // find the persona with the signer's identifier