Skip to content

Commit cb2e932

Browse files
feat: init side-panel (#1501)
* feat: init side-panel * fix: lock file * fix: rpc error * feat: version * fix: unit text * fix: async * fix: horizontal style * fix: vertical style --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent f6579fa commit cb2e932

File tree

36 files changed

+651
-13
lines changed

36 files changed

+651
-13
lines changed

.yarn/versions/4070ef7a.yml

+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
releases:
2+
"@fluent-wallet/account": patch
3+
"@fluent-wallet/addr-by-network": patch
4+
"@fluent-wallet/base32-address": patch
5+
"@fluent-wallet/cfx_accounts": patch
6+
"@fluent-wallet/cfx_call": patch
7+
"@fluent-wallet/cfx_chain-id": patch
8+
"@fluent-wallet/cfx_check-balance-against-transaction": patch
9+
"@fluent-wallet/cfx_client-version": patch
10+
"@fluent-wallet/cfx_epoch-number": patch
11+
"@fluent-wallet/cfx_estimate-1559-fee": patch
12+
"@fluent-wallet/cfx_estimate-gas-and-collateral": patch
13+
"@fluent-wallet/cfx_fee-history": patch
14+
"@fluent-wallet/cfx_gas-price": patch
15+
"@fluent-wallet/cfx_get-account": patch
16+
"@fluent-wallet/cfx_get-account-pending-info": patch
17+
"@fluent-wallet/cfx_get-account-pending-transactions": patch
18+
"@fluent-wallet/cfx_get-accumulate-interest-rate": patch
19+
"@fluent-wallet/cfx_get-admin": patch
20+
"@fluent-wallet/cfx_get-balance": patch
21+
"@fluent-wallet/cfx_get-best-block-hash": patch
22+
"@fluent-wallet/cfx_get-block-by-block-number": patch
23+
"@fluent-wallet/cfx_get-block-by-epoch-number": patch
24+
"@fluent-wallet/cfx_get-block-by-hash": patch
25+
"@fluent-wallet/cfx_get-block-by-hash-with-pivot-assumption": patch
26+
"@fluent-wallet/cfx_get-block-reward-info": patch
27+
"@fluent-wallet/cfx_get-blocks-by-epoch": patch
28+
"@fluent-wallet/cfx_get-code": patch
29+
"@fluent-wallet/cfx_get-collateral-for-storage": patch
30+
"@fluent-wallet/cfx_get-confirmation-risk-by-hash": patch
31+
"@fluent-wallet/cfx_get-deposit-list": patch
32+
"@fluent-wallet/cfx_get-fee-burnt": patch
33+
"@fluent-wallet/cfx_get-interest-rate": patch
34+
"@fluent-wallet/cfx_get-logs": patch
35+
"@fluent-wallet/cfx_get-max-gas-limit": patch
36+
"@fluent-wallet/cfx_get-next-nonce": patch
37+
"@fluent-wallet/cfx_get-next-usable-nonce": patch
38+
"@fluent-wallet/cfx_get-pos-economics": patch
39+
"@fluent-wallet/cfx_get-pos-reward-by-epoch": patch
40+
"@fluent-wallet/cfx_get-skipped-blocks-by-epoch": patch
41+
"@fluent-wallet/cfx_get-sponsor-info": patch
42+
"@fluent-wallet/cfx_get-staking-balance": patch
43+
"@fluent-wallet/cfx_get-status": patch
44+
"@fluent-wallet/cfx_get-storage-at": patch
45+
"@fluent-wallet/cfx_get-storage-root": patch
46+
"@fluent-wallet/cfx_get-supply-info": patch
47+
"@fluent-wallet/cfx_get-transaction-by-hash": patch
48+
"@fluent-wallet/cfx_get-transaction-receipt": patch
49+
"@fluent-wallet/cfx_get-vote-list": patch
50+
"@fluent-wallet/cfx_max-priority-fee-per-gas": patch
51+
"@fluent-wallet/cfx_net-version": patch
52+
"@fluent-wallet/cfx_opened-method-groups": patch
53+
"@fluent-wallet/cfx_request-accounts": patch
54+
"@fluent-wallet/cfx_send-raw-transaction": patch
55+
"@fluent-wallet/cfx_send-transaction": patch
56+
"@fluent-wallet/cfx_sign-transaction": patch
57+
"@fluent-wallet/cfx_sign-tx-with-ledger-nano-s": patch
58+
"@fluent-wallet/cfx_sign-typed-data_v4": patch
59+
"@fluent-wallet/component-alert": patch
60+
"@fluent-wallet/component-checkbox": patch
61+
"@fluent-wallet/component-dropdown": patch
62+
"@fluent-wallet/component-icons": patch
63+
"@fluent-wallet/component-loading": patch
64+
"@fluent-wallet/component-menu": patch
65+
"@fluent-wallet/component-message": patch
66+
"@fluent-wallet/component-modal": patch
67+
"@fluent-wallet/component-notification": patch
68+
"@fluent-wallet/component-tag": patch
69+
"@fluent-wallet/consts": patch
70+
"@fluent-wallet/contract-method-name": patch
71+
"@fluent-wallet/db": patch
72+
"@fluent-wallet/detect-address-type": patch
73+
"@fluent-wallet/did": patch
74+
"@fluent-wallet/estimate-tx": patch
75+
"@fluent-wallet/eth_accounts": patch
76+
"@fluent-wallet/eth_block-number": patch
77+
"@fluent-wallet/eth_call": patch
78+
"@fluent-wallet/eth_chain-id": patch
79+
"@fluent-wallet/eth_estimate-1559-fee": patch
80+
"@fluent-wallet/eth_estimate-gas": patch
81+
"@fluent-wallet/eth_fee-history": patch
82+
"@fluent-wallet/eth_gas-price": patch
83+
"@fluent-wallet/eth_get-balance": patch
84+
"@fluent-wallet/eth_get-block-by-hash": patch
85+
"@fluent-wallet/eth_get-block-by-number": patch
86+
"@fluent-wallet/eth_get-code": patch
87+
"@fluent-wallet/eth_get-logs": patch
88+
"@fluent-wallet/eth_get-transaction-by-hash": patch
89+
"@fluent-wallet/eth_get-transaction-count": patch
90+
"@fluent-wallet/eth_get-transaction-receipt": patch
91+
"@fluent-wallet/eth_max-priority-fee-per-gas": patch
92+
"@fluent-wallet/eth_request-accounts": patch
93+
"@fluent-wallet/eth_send-raw-transaction": patch
94+
"@fluent-wallet/eth_send-transaction": patch
95+
"@fluent-wallet/eth_sign-transaction": patch
96+
"@fluent-wallet/eth_sign-tx-with-ledger-nano-s": patch
97+
"@fluent-wallet/eth_sign-typed-data_v4": patch
98+
"@fluent-wallet/ledger": patch
99+
"@fluent-wallet/net_version": patch
100+
"@fluent-wallet/personal_sign": patch
101+
"@fluent-wallet/rpc-engine": patch
102+
"@fluent-wallet/shorten-address": patch
103+
"@fluent-wallet/signature": patch
104+
"@fluent-wallet/single-call-balance-tracker": patch
105+
"@fluent-wallet/spec": patch
106+
"@fluent-wallet/tx-history-checker": patch
107+
"@fluent-wallet/txpool_next-nonce": patch
108+
"@fluent-wallet/wallet_accounts": patch
109+
"@fluent-wallet/wallet_add-conflux-chain": patch
110+
"@fluent-wallet/wallet_add-ethereum-chain": patch
111+
"@fluent-wallet/wallet_add-hd-path": patch
112+
"@fluent-wallet/wallet_add-network": patch
113+
"@fluent-wallet/wallet_add-pending-user-auth-request": patch
114+
"@fluent-wallet/wallet_add-vault": patch
115+
"@fluent-wallet/wallet_after-unlock": patch
116+
"@fluent-wallet/wallet_chain-id": patch
117+
"@fluent-wallet/wallet_cleanup-tx": patch
118+
"@fluent-wallet/wallet_create-account": patch
119+
"@fluent-wallet/wallet_create-address": patch
120+
"@fluent-wallet/wallet_db-query": patch
121+
"@fluent-wallet/wallet_delete-account": patch
122+
"@fluent-wallet/wallet_delete-account-group": patch
123+
"@fluent-wallet/wallet_delete-app": patch
124+
"@fluent-wallet/wallet_delete-memo": patch
125+
"@fluent-wallet/wallet_delete-network": patch
126+
"@fluent-wallet/wallet_detect-address-type": patch
127+
"@fluent-wallet/wallet_detect-network-type": patch
128+
"@fluent-wallet/wallet_discover-accounts": patch
129+
"@fluent-wallet/wallet_enrich-conflux-tx": patch
130+
"@fluent-wallet/wallet_enrich-ethereum-tx": patch
131+
"@fluent-wallet/wallet_enrich-txs": patch
132+
"@fluent-wallet/wallet_export-account": patch
133+
"@fluent-wallet/wallet_export-account-group": patch
134+
"@fluent-wallet/wallet_export-all": patch
135+
"@fluent-wallet/wallet_generate-address": patch
136+
"@fluent-wallet/wallet_generate-private-key": patch
137+
"@fluent-wallet/wallet_get-account-address-by-network": patch
138+
"@fluent-wallet/wallet_get-account-group": patch
139+
"@fluent-wallet/wallet_get-account-group-vault-value": patch
140+
"@fluent-wallet/wallet_get-address-private-key": patch
141+
"@fluent-wallet/wallet_get-balance": patch
142+
"@fluent-wallet/wallet_get-block-or-epoch-number": patch
143+
"@fluent-wallet/wallet_get-block-time": patch
144+
"@fluent-wallet/wallet_get-blockchain-explorer-url": patch
145+
"@fluent-wallet/wallet_get-current-account": patch
146+
"@fluent-wallet/wallet_get-current-network": patch
147+
"@fluent-wallet/wallet_get-current-viewing-app": patch
148+
"@fluent-wallet/wallet_get-fluent-metadata": patch
149+
"@fluent-wallet/wallet_get-import-hardware-wallet-info": patch
150+
"@fluent-wallet/wallet_get-network": patch
151+
"@fluent-wallet/wallet_get-next-nonce": patch
152+
"@fluent-wallet/wallet_get-next-usable-nonce": patch
153+
"@fluent-wallet/wallet_get-pending-auth-request": patch
154+
"@fluent-wallet/wallet_get-permissions": patch
155+
"@fluent-wallet/wallet_get-preferences": patch
156+
"@fluent-wallet/wallet_get-side-panel-enabled": patch
157+
"@fluent-wallet/wallet_get-side-panel-supported": patch
158+
"@fluent-wallet/wallet_handle-unfinished-cfx-tx": patch
159+
"@fluent-wallet/wallet_handle-unfinished-eth-tx": patch
160+
"@fluent-wallet/wallet_handle-unfinished-txs": patch
161+
"@fluent-wallet/wallet_import-address": patch
162+
"@fluent-wallet/wallet_import-all": patch
163+
"@fluent-wallet/wallet_import-hardware-wallet-account-group-or-account": patch
164+
"@fluent-wallet/wallet_import-mnemonic": patch
165+
"@fluent-wallet/wallet_import-private-key": patch
166+
"@fluent-wallet/wallet_metadata-for-popup": patch
167+
"@fluent-wallet/wallet_network1559compatible": patch
168+
"@fluent-wallet/wallet_refetch-balance": patch
169+
"@fluent-wallet/wallet_refetch-token-list": patch
170+
"@fluent-wallet/wallet_refetch-tx-list": patch
171+
"@fluent-wallet/wallet_register-site-metadata": patch
172+
"@fluent-wallet/wallet_request-accounts": patch
173+
"@fluent-wallet/wallet_request-permissions": patch
174+
"@fluent-wallet/wallet_request-unlock-ui": patch
175+
"@fluent-wallet/wallet_send-transaction": patch
176+
"@fluent-wallet/wallet_send-transaction-with-action": patch
177+
"@fluent-wallet/wallet_set-app-current-account": patch
178+
"@fluent-wallet/wallet_set-app-current-network": patch
179+
"@fluent-wallet/wallet_set-current-account": patch
180+
"@fluent-wallet/wallet_set-current-network": patch
181+
"@fluent-wallet/wallet_set-preferences": patch
182+
"@fluent-wallet/wallet_set-side-panel-behavior": patch
183+
"@fluent-wallet/wallet_set-side-panel-enabled": patch
184+
"@fluent-wallet/wallet_switch-conflux-chain": patch
185+
"@fluent-wallet/wallet_switch-ethereum-chain": patch
186+
"@fluent-wallet/wallet_unlock": patch
187+
"@fluent-wallet/wallet_unwatch-asset": patch
188+
"@fluent-wallet/wallet_update-account": patch
189+
"@fluent-wallet/wallet_update-account-group": patch
190+
"@fluent-wallet/wallet_update-network": patch
191+
"@fluent-wallet/wallet_update-token-list": patch
192+
"@fluent-wallet/wallet_upsert-memo": patch
193+
"@fluent-wallet/wallet_user-approved-auth-request": patch
194+
"@fluent-wallet/wallet_user-rejected-auth-request": patch
195+
"@fluent-wallet/wallet_validate-app-permissions": patch
196+
"@fluent-wallet/wallet_validate-mnemonic": patch
197+
"@fluent-wallet/wallet_validate-password": patch
198+
"@fluent-wallet/wallet_validate-private-key": patch
199+
"@fluent-wallet/wallet_validate20token": patch
200+
"@fluent-wallet/wallet_watch-asset": patch
201+
"@fluent-wallet/wallet_zero-account-group": patch
202+
browser-extension: patch
203+
helios-background: patch
204+
helios-popup: patch
205+
workspace-tools: patch
206+
207+
declined:
208+
- helios
209+
- doc

packages/background/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@
133133
"@fluent-wallet/wallet_get-pending-auth-request": "workspace:packages/rpcs/wallet_getPendingAuthRequest",
134134
"@fluent-wallet/wallet_get-permissions": "workspace:packages/rpcs/wallet_getPermissions",
135135
"@fluent-wallet/wallet_get-preferences": "workspace:*",
136+
"@fluent-wallet/wallet_get-side-panel-enabled": "workspace:*",
137+
"@fluent-wallet/wallet_get-side-panel-supported": "workspace:*",
136138
"@fluent-wallet/wallet_handle-unfinished-cfx-tx": "workspace:*",
137139
"@fluent-wallet/wallet_handle-unfinished-eth-tx": "workspace:*",
138140
"@fluent-wallet/wallet_handle-unfinished-txs": "workspace:*",
@@ -158,6 +160,8 @@
158160
"@fluent-wallet/wallet_set-current-account": "workspace:packages/rpcs/wallet_setCurrentAccount",
159161
"@fluent-wallet/wallet_set-current-network": "workspace:packages/rpcs/wallet_setCurrentNetwork",
160162
"@fluent-wallet/wallet_set-preferences": "workspace:*",
163+
"@fluent-wallet/wallet_set-side-panel-behavior": "workspace:*",
164+
"@fluent-wallet/wallet_set-side-panel-enabled": "workspace:*",
161165
"@fluent-wallet/wallet_unlock": "workspace:packages/rpcs/wallet_unlock",
162166
"@fluent-wallet/wallet_unwatch-asset": "workspace:packages/rpcs/wallet_unwatchAsset",
163167
"@fluent-wallet/wallet_update-account": "workspace:packages/rpcs/wallet_updateAccount",

packages/background/src/rpc-engine-opts.js

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ import * as ethGetBlockByHash from '@fluent-wallet/eth_get-block-by-hash'
3131
import * as ethGetBlockByNumber from '@fluent-wallet/eth_get-block-by-number'
3232
import * as walletSetPreferences from '@fluent-wallet/wallet_set-preferences'
3333
import * as walletGetPreferences from '@fluent-wallet/wallet_get-preferences'
34+
import * as walletSetSidePanelBehavior from '@fluent-wallet/wallet_set-side-panel-behavior'
35+
import * as walletSetSidePanelEnabled from '@fluent-wallet/wallet_set-side-panel-enabled'
36+
import * as walletGetSidePanelEnabled from '@fluent-wallet/wallet_get-side-panel-enabled'
37+
import * as walletGetSidePanelSupported from '@fluent-wallet/wallet_get-side-panel-supported'
3438
import * as walletUpdateNetwork from '@fluent-wallet/wallet_update-network'
3539
import * as cfxGetMaxGasLimit from '@fluent-wallet/cfx_get-max-gas-limit'
3640
import * as walletMetadataForPopup from '@fluent-wallet/wallet_metadata-for-popup'
@@ -367,6 +371,10 @@ export const rpcEngineOpts = {
367371
walletGetFluentMetadata,
368372
walletGetPreferences,
369373
walletSetPreferences,
374+
walletGetSidePanelEnabled,
375+
walletGetSidePanelSupported,
376+
walletSetSidePanelBehavior,
377+
walletSetSidePanelEnabled,
370378
walletUpsertMemo,
371379
walletDeleteMemo,
372380
walletGetBlockTime,

packages/background/src/service-worker.js

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ async function initApp() {
137137
() => request({method: 'wallet_cleanupTx', _rpcStack: ['frombg']}),
138138
1000 * 60 * 60,
139139
)
140+
// set panel behavior
141+
request({method: 'wallet_setSidePanelBehavior', _rpcStack: ['frombg']})
140142
}
141143

142144
if (isManifestV3) {

packages/consts/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const TESTNET = 'testnet'
88
export const LOCALHOST = 'localhost'
99
export const CUSTOM = 'custom'
1010
export const EXT_STORAGE = 'ext-storage'
11+
export const SIDE_PANEL_KEY = 'side-panel'
1112
export const NULL_HEX_ADDRESS = '0x0000000000000000000000000000000000000000'
1213
export const ADMINE_CONTROL_HEX_ADDRESS =
1314
'0x0888000000000000000000000000000000000000'

packages/manifest/manifestv3.json

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"default_title": "Fluent",
6363
"default_popup": "popup.html"
6464
},
65+
"side_panel": {
66+
"default_path": "sidePanel.html"
67+
},
6568
"content_scripts": [
6669
{
6770
"matches": ["file://*/*", "http://*/*", "https://*/*"],
@@ -80,6 +83,7 @@
8083
"tabs",
8184
"scripting",
8285
"activeTab",
86+
"sidePanel",
8387
"notifications"
8488
],
8589
"host_permissions": [

packages/popup/src/App.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import AdvancedSettings from './pages/AdvancedSettings'
5757
import AddressBook from './pages/AddressBook'
5858
import Contacts from './pages/Contacts'
5959
import ResendTransaction from './pages/ResendTransaction'
60+
import {isRunningInSidePanel} from './utils/side-panel'
6061

6162
const {
6263
HOME,
@@ -263,8 +264,9 @@ const AppRoutes = withRouter(
263264
return (
264265
<div
265266
id="router"
266-
className={`m-auto light relative overflow-hidden ${
267-
FULL_WINDOW_ROUTES.includes(location.pathname)
267+
className={`mx-auto light relative overflow-hidden ${
268+
FULL_WINDOW_ROUTES.includes(location.pathname) ||
269+
isRunningInSidePanel()
268270
? 'h-screen w-full'
269271
: 'h-150 w-93'
270272
} ${formatLocalizationLang(i18n.language) === 'zh' ? 'font-zh' : ''}`}

packages/popup/src/components/SlideCard.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {useClickAway} from 'react-use'
33
import {CloseCircleFilled} from '@fluent-wallet/component-icons'
44
import {useRef} from 'react'
55
import {useSlideAnimation} from '../hooks'
6+
import {isRunningInSidePanel} from '../utils/side-panel'
67

78
function SlideCard({
89
onClose,
@@ -16,12 +17,15 @@ function SlideCard({
1617
id = '',
1718
containerClassName = '',
1819
cardClassName = '',
19-
width = 'w-93',
20-
height = 'h-125',
20+
width,
21+
height,
2122
backgroundColor = 'bg-bg',
2223
direction = 'vertical',
2324
}) {
2425
const animateStyle = useSlideAnimation(open, direction, needAnimation)
26+
const inSidePanel = isRunningInSidePanel()
27+
width = width ?? (inSidePanel ? 'w-full' : 'w-93')
28+
height = height ?? (inSidePanel ? 'h-125 max-h-[80%]' : 'h-125')
2529
const ref = useRef(null)
2630

2731
useClickAway(ref, e => {

packages/popup/src/constants/rpcMethods.js

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ export const WALLET_GET_FLUENT_METADATA = 'wallet_getFluentMetadata'
7272
export const CFX_GET_MAX_GAS_LIMIT = 'cfx_getMaxGasLimit'
7373
export const WALLET_SET_PREFERENCES = 'wallet_setPreferences'
7474
export const WALLET_GET_PREFERENCES = 'wallet_getPreferences'
75+
export const WALLET_SET_SIDE_PANEL_ENABLED = 'wallet_setSidePanelEnabled'
76+
export const WALLET_GET_SIDE_PANEL_ENABLED = 'wallet_getSidePanelEnabled'
77+
export const WALLET_GET_SIDE_PANEL_SUPPORTED = 'wallet_getSidePanelSupported'
7578
export const WALLET_UPDATE_ACCOUNT_GROUP = 'wallet_updateAccountGroup'
7679
export const WALLET_UPDATE_NETWORK = 'wallet_updateNetwork'
7780
export const WALLET_SEND_TRANSACTION = 'wallet_sendTransaction'

packages/popup/src/hooks/useApi.js

+19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const {
3737
WALLET_GET_FLUENT_METADATA,
3838
CFX_GET_MAX_GAS_LIMIT,
3939
WALLET_GET_PREFERENCES,
40+
WALLET_GET_SIDE_PANEL_ENABLED,
41+
WALLET_GET_SIDE_PANEL_SUPPORTED,
4042
WALLET_QUERY_MEMO,
4143
WALLET_QUERY_RECENT_TRADING_ADDRESS,
4244
WALLET_NETWORK1559COMPATIBLE,
@@ -695,6 +697,23 @@ export const usePreferences = (stop = false) => {
695697
return {data, mutate}
696698
}
697699

700+
export const useSidePanel = () => {
701+
const {data: enabled} = useRPC([WALLET_GET_SIDE_PANEL_ENABLED], undefined, {
702+
refreshInterval: 0,
703+
})
704+
const {data: isSupported} = useRPC(
705+
[WALLET_GET_SIDE_PANEL_SUPPORTED],
706+
undefined,
707+
{
708+
refreshInterval: 0,
709+
},
710+
)
711+
return {
712+
enabled,
713+
isSupported,
714+
}
715+
}
716+
698717
export const useCurrentNetworkAddressMemo = (params = {}, stopSend = false) => {
699718
const {
700719
data: {

packages/popup/src/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@ import './i18n.js'
66
import {SWRConfig} from 'swr'
77
import {ROUTES} from './constants'
88
import {IS_PROD_MODE, PACKAGE_VERSION} from '@fluent-wallet/inner-utils'
9+
import {isRunningInSidePanel} from './utils/side-panel'
910

1011
const {ERROR, WALLET_UNLOCK} = ROUTES
1112
// import reportWebVitals from './reportWebVitals'
1213

14+
if (isRunningInSidePanel()) {
15+
const sidePanelSheet = new CSSStyleSheet()
16+
sidePanelSheet.insertRule(`
17+
html, body {
18+
width: 100%;
19+
overflow: hidden;
20+
}
21+
`)
22+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sidePanelSheet]
23+
}
24+
1325
// Fix chrome extension render problem in external screen
1426
if (
1527
// From testing the following conditions seem to indicate that the popup was opened on a secondary monitor

0 commit comments

Comments
 (0)