Skip to content

Commit

Permalink
add tm restrictions to signMessage screen
Browse files Browse the repository at this point in the history
  • Loading branch information
JIOjosBG committed Jun 24, 2024
1 parent 633442a commit 6ae8bab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/SignMessage/SignMessage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState, useEffect, useRef } from 'react'
import * as blockies from 'blockies-ts'
import { toUtf8String, isHexString } from 'ethers/lib/utils'
import supportedDApps from 'ambire-common/src/constants/supportedDApps'
import cn from 'classnames'
import { UNISWAP_UNIVERSAL_ROUTERS, PERMIT_2_ADDRESS } from 'consts/specialAddresses'

import { useSignMessage } from 'hooks'
import {
Expand Down Expand Up @@ -68,9 +68,18 @@ export default function SignMessage({
onConfirmationCodeRequired,
useStorage
})

const isSnapshot = (_dappName, _txn) => _dappName && _dappName.toLowerCase().includes('snapshot') && _txn.domain && _txn.domain.name === 'snapshot'
const isOkPermit2 = (_txn, _chainId) =>
_txn.primaryType &&
_txn.primaryType.toLowerCase().includes('permit') &&
_txn.message && _txn.message.spender &&
_txn.message.spender.toLowerCase() === UNISWAP_UNIVERSAL_ROUTERS[_chainId].toLowerCase() &&
_txn.domain && _txn.domain.verifyingContract &&
_txn.domain.verifyingContract.toLowerCase() === PERMIT_2_ADDRESS.toLowerCase()
const isSigTool = (_dappUrl) => _dappUrl === 'https://sigtool.ambire.com/'

const isDAppSupported =
dApp && (supportedDApps.includes(dApp.url) || supportedDApps.includes(`${dApp.url}/`))
const isDAppSupported = !isTypedData || (dApp && dataV4 && isSnapshot(dApp.url, dataV4)) || isOkPermit2(dataV4, requestedChainId) || (dApp && isSigTool(dApp.url))

const onScroll = (textArea) => {
if (textArea.scrollHeight - textArea.scrollTop - textArea.clientHeight < 1) {
Expand Down
18 changes: 18 additions & 0 deletions src/consts/specialAddresses.js
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
export const UNISWAP_UNIVERSAL_ROUTERS = {
1: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
11155111: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
8453: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
42161: '0x5E325eDA8064b456f4781070C0738d849c824258',
421614: '0x4A7b5Da61326A6379179b40d00F57E5bbDC962c2',
10: '0xCb1355ff08Ab38bBCE60111F1bb2B7845384bE25D7e8',
11155420: '0xD5bBa708b39537d33F2812E5Ea032622456F1A95',
137: '0xec7BE89e9d109e7e3Fec59c222CF297125FEFda2',
84532: '0x050E797f3625EC8785265e1d9BDd4799b97528A1',
56: '0x4Dae2f939ACf50408e13d58534Ff8c2776d45265',
43114: '0x4Dae2f939ACf50408e13d58534Ff8c2776d45265',
42220: '0x643770E279d5D0733F21d6DC03A8efbABf3255B4',
81457: '0x643770E279d5D0733F21d6DC03A8efbABf3255B4'
}

export const PERMIT_2_ADDRESS = '0x000000000022D473030F116dDEE9F6B43aC78BA3'

0 comments on commit 6ae8bab

Please sign in to comment.