diff --git a/src/controllers/phishing/phishing.ts b/src/controllers/phishing/phishing.ts index 0bf4e0fd32..f8893a6efe 100644 --- a/src/controllers/phishing/phishing.ts +++ b/src/controllers/phishing/phishing.ts @@ -244,8 +244,8 @@ export class PhishingController extends EventEmitter implements IPhishingControl !domainsBlacklistedStatus || domainsBlacklistedStatus[dappId] === undefined ? 'FAILED_TO_GET' : domainsBlacklistedStatus[dappId] - ? 'BLACKLISTED' - : 'VERIFIED' + ? 'BLACKLISTED' + : 'VERIFIED' ) }) @@ -366,8 +366,8 @@ export class PhishingController extends EventEmitter implements IPhishingControl !addressesBlacklistedStatus || addressesBlacklistedStatus[addr] === undefined ? 'FAILED_TO_GET' : addressesBlacklistedStatus[addr] - ? 'BLACKLISTED' - : 'VERIFIED' + ? 'BLACKLISTED' + : 'VERIFIED' ) }) @@ -397,11 +397,11 @@ export class PhishingController extends EventEmitter implements IPhishingControl } async updateAddressesBlacklistedStatus( - urls: string[], + addresses: string[], callback: (res: { [dappId: string]: BlacklistedStatus }) => void ) { try { - await this.#fetchAndSetAddressesBlacklistedStatus(urls, callback) + await this.#fetchAndSetAddressesBlacklistedStatus(addresses, callback) } catch (err: any) { this.emitError({ message: 'Failed to fetch and update addresses blacklisted status', diff --git a/src/controllers/signAccountOp/signAccountOp.ts b/src/controllers/signAccountOp/signAccountOp.ts index a229972425..5d0112de03 100644 --- a/src/controllers/signAccountOp/signAccountOp.ts +++ b/src/controllers/signAccountOp/signAccountOp.ts @@ -627,7 +627,7 @@ export class SignAccountOpController extends EventEmitter implements ISignAccoun } humanize() { - this.humanization = humanizeAccountOp(this.accountOp) + this.humanization = humanizeAccountOp(this.accountOp, this.emitError) const currentHumanizationId = Date.now() this.humanizationId = currentHumanizationId if (this.humanization.length) { @@ -639,7 +639,8 @@ export class SignAccountOpController extends EventEmitter implements ISignAccoun .filter((v) => v.type === 'token' || v.type === 'address') .map((v) => v.address) ) - .filter((addr): addr is string => Boolean(addr)), + .filter((addr): addr is string => Boolean(addr)) + .map((addr) => addr.toLowerCase()), (addressesStatus) => { if (this.humanizationId !== currentHumanizationId) return @@ -647,12 +648,13 @@ export class SignAccountOpController extends EventEmitter implements ISignAccoun if (!call.fullVisualization) continue for (const vis of call.fullVisualization) { + const lowerCaseAddr = vis.address?.toLowerCase() if ( (vis.type === 'token' || vis.type === 'address') && - vis.address && - addressesStatus[vis.address] + lowerCaseAddr && + addressesStatus[lowerCaseAddr] ) { - vis.verification = addressesStatus[vis.address] + vis.verification = addressesStatus[lowerCaseAddr] } } } diff --git a/src/libs/humanizer/index.ts b/src/libs/humanizer/index.ts index a606d61ac1..28f1bf7dfa 100644 --- a/src/libs/humanizer/index.ts +++ b/src/libs/humanizer/index.ts @@ -1,3 +1,5 @@ +import { ErrorRef } from '@/interfaces/eventEmitter' + import humanizerInfo from '../../consts/humanizer/humanizerInfo.json' import { Message } from '../../interfaces/userRequest' import { AccountOp } from '../accountOp/accountOp' @@ -108,14 +110,21 @@ const humanizerTMModules = [ snapshotModule ] -const humanizeAccountOp = (_accountOp: AccountOp): IrCall[] => { +const humanizeAccountOp = (_accountOp: AccountOp, emitError?: (e: ErrorRef) => void): IrCall[] => { const accountOp = parse(stringify(_accountOp)) let currentCalls: IrCall[] = accountOp.calls - humanizerCallModules.forEach((hm) => { + humanizerCallModules.forEach((hm, i) => { try { currentCalls = hm(accountOp, currentCalls, humanizerInfo as HumanizerMeta) - } catch (error) { + } catch (error: any) { + emitError && + emitError({ + message: `Humanizer: Failed to parse tx. Module id ${i} `, + level: 'minor', + sendCrashReport: true, + error + }) console.error(error) // No action is needed here; we only set `currentCalls` if the module successfully resolves the calls. } diff --git a/src/libs/humanizer/utils.ts b/src/libs/humanizer/utils.ts index 8c31115e6d..11f67f5040 100644 --- a/src/libs/humanizer/utils.ts +++ b/src/libs/humanizer/utils.ts @@ -26,21 +26,19 @@ export function getImage(content: string): HumanizerVisualization { export function getBreak(): HumanizerVisualization { return { type: 'break', id: randomId() } } -export function getAddressVisualization(_address: string): HumanizerVisualization { - const address = _address.toLowerCase() - return { type: 'address', address, id: randomId() } +export function getAddressVisualization(address: string): HumanizerVisualization { + return { type: 'address', address: getAddress(address), id: randomId() } } export function getToken( - _address: string, + address: string, amount: bigint, isHidden?: boolean, chainId?: bigint ): HumanizerVisualization { - const address = _address.toLowerCase() return { type: 'token', - address, + address: getAddress(address), value: BigInt(amount), id: randomId(), isHidden,