diff --git a/src/background/controller/provider/controller.ts b/src/background/controller/provider/controller.ts index 4e90bded..ff07a350 100644 --- a/src/background/controller/provider/controller.ts +++ b/src/background/controller/provider/controller.ts @@ -8,6 +8,7 @@ import RLP from 'rlp'; import Web3 from 'web3'; import { stringToHex } from 'web3-utils'; +import { signWithKey } from '@/background/utils/modules/publicPrivateKey'; import { ensureEvmAddressPrefix, isValidEthereumAddress } from '@/shared/utils/address'; import { permissionService, @@ -22,9 +23,6 @@ import { storage } from '../../webapi'; import BaseController from '../base'; import Wallet from '../wallet'; -// eslint-disable-next-line import/order -import { signWithKey } from '@/background/utils/modules/publicPrivateKey'; - interface Web3WalletPermission { // The name of the method corresponding to the permission parentCapability: string; diff --git a/src/background/controller/wallet.ts b/src/background/controller/wallet.ts index 31e5733f..d068d99b 100644 --- a/src/background/controller/wallet.ts +++ b/src/background/controller/wallet.ts @@ -386,6 +386,16 @@ export class WalletController extends BaseController { const { origin } = sessionService.getSession(tabId) || {}; return permissionService.getWithoutUpdate(origin); }; + addConnectedSite = ( + origin: string, + name: string, + icon: string, + defaultChain = 747, + isSigned = false + ) => { + permissionService.addConnectedSite(origin, name, icon, defaultChain, isSigned); + }; + updateConnectSite = (origin: string, data: ConnectedSite) => { permissionService.updateConnectSite(origin, data); // sessionService.broadcastEvent( diff --git a/src/background/utils/index.ts b/src/background/utils/index.ts index 85f6ac36..f3026eb9 100644 --- a/src/background/utils/index.ts +++ b/src/background/utils/index.ts @@ -4,7 +4,7 @@ import packageJson from '@/../package.json'; import { storage } from '@/background/webapi'; const { version } = packageJson; -import { mixpanelTrack } from '../service'; +import { mixpanelTrack } from '../service/mixpanel'; import pageStateCache from '../service/pageStateCache'; export { default as createPersistStore } from './persisitStore'; diff --git a/src/ui/views/Approval/components/Connect.tsx b/src/ui/views/Approval/components/Connect.tsx index c8baa075..7aee7b3a 100644 --- a/src/ui/views/Approval/components/Connect.tsx +++ b/src/ui/views/Approval/components/Connect.tsx @@ -4,7 +4,6 @@ import React, { useCallback, useEffect, useState } from 'react'; import { storage } from '@/background/webapi'; import { authnServiceDefinition, serviceDefinition } from 'background/controller/serviceDefinition'; -import { permissionService } from 'background/service'; import flowgrey from 'ui/FRWAssets/svg/flow-grey.svg'; import Link from 'ui/FRWAssets/svg/link.svg'; import linkGlobe from 'ui/FRWAssets/svg/linkGlobe.svg'; @@ -97,7 +96,7 @@ const Connect = ({ params: { /*icon, origin,*/ tabId } }: ConnectProps) => { chainId = 747; } console.log('permission add ', host, title, logo, chainId); - permissionService.addConnectedSite(host, title, logo, chainId); + wallet.addConnectedSite(host, title, logo, chainId); if (appIdentifier && nonce) { const message = WalletUtils.encodeAccountProof({ diff --git a/src/ui/views/EvmMove/MoveFromChild/index.tsx b/src/ui/views/EvmMove/MoveFromChild/index.tsx index d65104b6..f1c00d37 100644 --- a/src/ui/views/EvmMove/MoveFromChild/index.tsx +++ b/src/ui/views/EvmMove/MoveFromChild/index.tsx @@ -3,7 +3,6 @@ import { Box, Button, Typography, Drawer, IconButton, Grid } from '@mui/material import React, { useState, useEffect, useCallback } from 'react'; import { useHistory } from 'react-router-dom'; -import wallet from '@/background/controller/wallet'; import { isValidEthereumAddress, withPrefix } from '@/shared/utils/address'; import { WarningStorageLowSnackbar } from '@/ui/FRWComponent/WarningStorageLowSnackbar'; import { useStorageCheck } from '@/ui/utils/useStorageCheck'; @@ -159,7 +158,7 @@ const MoveFromChild = (props: TransferConfirmationProps) => { const moveToken = useCallback(async () => { setLoading(true); - const tokenResult = await wallet.openapi.getTokenInfo(currentCoin, network); + const tokenResult = await usewallet.openapi.getTokenInfo(currentCoin, network); usewallet .moveFTfromChild(childUserInfo!.address, 'flowTokenProvider', amount!, tokenResult!.name) .then(async (createRes) => { diff --git a/src/ui/views/EvmMove/MoveFromEvm/index.tsx b/src/ui/views/EvmMove/MoveFromEvm/index.tsx index af1efe65..0539dfcc 100644 --- a/src/ui/views/EvmMove/MoveFromEvm/index.tsx +++ b/src/ui/views/EvmMove/MoveFromEvm/index.tsx @@ -3,7 +3,6 @@ import { Box, Button, Typography, Drawer, IconButton, Grid } from '@mui/material import React, { useState, useEffect, useCallback } from 'react'; import { useHistory } from 'react-router-dom'; -import wallet from '@/background/controller/wallet'; import { isValidEthereumAddress, withPrefix } from '@/shared/utils/address'; import { WarningStorageLowSnackbar } from '@/ui/FRWComponent/WarningStorageLowSnackbar'; import { useStorageCheck } from '@/ui/utils/useStorageCheck'; @@ -164,7 +163,7 @@ const MoveFromEvm = (props: TransferConfirmationProps) => { const bridgeToken = async () => { setLoading(true); - const tokenResult = await wallet.openapi.getEvmTokenInfo(currentCoin, network); + const tokenResult = await usewallet.openapi.getEvmTokenInfo(currentCoin, network); let flowId = tokenResult!['flowIdentifier']; diff --git a/src/ui/views/EvmMove/MoveFromFlow/index.tsx b/src/ui/views/EvmMove/MoveFromFlow/index.tsx index 219aff5a..d80d93c2 100644 --- a/src/ui/views/EvmMove/MoveFromFlow/index.tsx +++ b/src/ui/views/EvmMove/MoveFromFlow/index.tsx @@ -3,7 +3,6 @@ import { Box, Button, Typography, Drawer, IconButton, Grid } from '@mui/material import React, { useState, useEffect, useCallback } from 'react'; import { useHistory } from 'react-router-dom'; -import wallet from '@/background/controller/wallet'; import { withPrefix, isValidEthereumAddress } from '@/shared/utils/address'; import { WarningStorageLowSnackbar } from '@/ui/FRWComponent/WarningStorageLowSnackbar'; import { useStorageCheck } from '@/ui/utils/useStorageCheck'; @@ -177,7 +176,7 @@ const MoveFromFlow = (props: TransferConfirmationProps) => { const bridgeToken = async () => { setLoading(true); - const tokenResult = await wallet.openapi.getTokenInfo(currentCoin, network); + const tokenResult = await usewallet.openapi.getTokenInfo(currentCoin, network); console.log('tokenResult ', tokenResult); const address = tokenResult!.address.startsWith('0x') ? tokenResult!.address.slice(2) diff --git a/src/ui/views/EvmMove/MoveFromParent/index.tsx b/src/ui/views/EvmMove/MoveFromParent/index.tsx index bd56fd99..5e6f3a8d 100644 --- a/src/ui/views/EvmMove/MoveFromParent/index.tsx +++ b/src/ui/views/EvmMove/MoveFromParent/index.tsx @@ -4,7 +4,6 @@ import { ThemeProvider } from '@mui/material/styles'; import React, { useState, useEffect, useCallback } from 'react'; import { useHistory } from 'react-router-dom'; -import wallet from '@/background/controller/wallet'; import { isValidEthereumAddress, withPrefix } from '@/shared/utils/address'; import { WarningStorageLowSnackbar } from '@/ui/FRWComponent/WarningStorageLowSnackbar'; import { useStorageCheck } from '@/ui/utils/useStorageCheck'; @@ -160,7 +159,7 @@ const MoveFromParent = (props: TransferConfirmationProps) => { const moveToken = async () => { setLoading(true); - const tokenResult = await wallet.openapi.getTokenInfo(currentCoin, network); + const tokenResult = await usewallet.openapi.getTokenInfo(currentCoin, network); console.log('tokenResult ', tokenResult); usewallet .moveFTfromChild(childUserInfo!.address, 'flowTokenProvider', amount!, tokenResult!.name)