Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release 2.8.1 #1530

Merged
merged 18 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "helios",
"private": true,
"version": "2.8.0",
"version": "2.8.1",
"workspaces": [
"websites/*",
"packages/doc-ui/*",
Expand Down
2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fluent-wallet/account",
"version": "1.0.3",
"version": "1.0.4",
"type": "module",
"main": "index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/addr-by-network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fluent-wallet/addr-by-network",
"type": "module",
"main": "index.js",
"version": "0.0.4",
"version": "0.0.5",
"dependencies": {
"@fluent-wallet/account": "workspace:packages/account",
"@fluent-wallet/base32-address": "workspace:packages/base32-address",
Expand Down
8 changes: 6 additions & 2 deletions packages/background/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "helios-background",
"version": "0.0.33",
"version": "0.0.36",
"type": "module",
"main": "src/index.js",
"private": true,
Expand Down Expand Up @@ -58,7 +58,7 @@
"@fluent-wallet/cfx_sign-tx-with-ledger-nano-s": "workspace:*",
"@fluent-wallet/cfx_sign-typed-data_v4": "workspace:packages/rpcs/cfx_signTypedData_v4",
"@fluent-wallet/consts": "workspace:packages/consts",
"@fluent-wallet/db": "1.0.78",
"@fluent-wallet/db": "1.0.79",
"@fluent-wallet/eth_accounts": "workspace:packages/rpcs/eth_accounts",
"@fluent-wallet/eth_block-number": "workspace:packages/rpcs/eth_blockNumber",
"@fluent-wallet/eth_call": "workspace:packages/rpcs/eth_call",
Expand Down Expand Up @@ -133,6 +133,8 @@
"@fluent-wallet/wallet_get-pending-auth-request": "workspace:packages/rpcs/wallet_getPendingAuthRequest",
"@fluent-wallet/wallet_get-permissions": "workspace:packages/rpcs/wallet_getPermissions",
"@fluent-wallet/wallet_get-preferences": "workspace:*",
"@fluent-wallet/wallet_get-side-panel-enabled": "workspace:*",
"@fluent-wallet/wallet_get-side-panel-supported": "workspace:*",
"@fluent-wallet/wallet_handle-unfinished-cfx-tx": "workspace:*",
"@fluent-wallet/wallet_handle-unfinished-eth-tx": "workspace:*",
"@fluent-wallet/wallet_handle-unfinished-txs": "workspace:*",
Expand All @@ -158,6 +160,8 @@
"@fluent-wallet/wallet_set-current-account": "workspace:packages/rpcs/wallet_setCurrentAccount",
"@fluent-wallet/wallet_set-current-network": "workspace:packages/rpcs/wallet_setCurrentNetwork",
"@fluent-wallet/wallet_set-preferences": "workspace:*",
"@fluent-wallet/wallet_set-side-panel-behavior": "workspace:*",
"@fluent-wallet/wallet_set-side-panel-enabled": "workspace:*",
"@fluent-wallet/wallet_unlock": "workspace:packages/rpcs/wallet_unlock",
"@fluent-wallet/wallet_unwatch-asset": "workspace:packages/rpcs/wallet_unwatchAsset",
"@fluent-wallet/wallet_update-account": "workspace:packages/rpcs/wallet_updateAccount",
Expand Down
8 changes: 8 additions & 0 deletions packages/background/src/rpc-engine-opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import * as ethGetBlockByHash from '@fluent-wallet/eth_get-block-by-hash'
import * as ethGetBlockByNumber from '@fluent-wallet/eth_get-block-by-number'
import * as walletSetPreferences from '@fluent-wallet/wallet_set-preferences'
import * as walletGetPreferences from '@fluent-wallet/wallet_get-preferences'
import * as walletSetSidePanelBehavior from '@fluent-wallet/wallet_set-side-panel-behavior'
import * as walletSetSidePanelEnabled from '@fluent-wallet/wallet_set-side-panel-enabled'
import * as walletGetSidePanelEnabled from '@fluent-wallet/wallet_get-side-panel-enabled'
import * as walletGetSidePanelSupported from '@fluent-wallet/wallet_get-side-panel-supported'
import * as walletUpdateNetwork from '@fluent-wallet/wallet_update-network'
import * as cfxGetMaxGasLimit from '@fluent-wallet/cfx_get-max-gas-limit'
import * as walletMetadataForPopup from '@fluent-wallet/wallet_metadata-for-popup'
Expand Down Expand Up @@ -367,6 +371,10 @@ export const rpcEngineOpts = {
walletGetFluentMetadata,
walletGetPreferences,
walletSetPreferences,
walletGetSidePanelEnabled,
walletGetSidePanelSupported,
walletSetSidePanelBehavior,
walletSetSidePanelEnabled,
walletUpsertMemo,
walletDeleteMemo,
walletGetBlockTime,
Expand Down
27 changes: 27 additions & 0 deletions packages/background/src/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ async function initApp() {
() => request({method: 'wallet_cleanupTx', _rpcStack: ['frombg']}),
1000 * 60 * 60,
)
// set panel behavior
request({method: 'wallet_setSidePanelBehavior', _rpcStack: ['frombg']})
}

if (isManifestV3) {
Expand All @@ -147,3 +149,28 @@ async function initApp() {
}

initApp()

let count = 0
const registerInPageContentScript = async () => {
count++
try {
await chrome.scripting.registerContentScripts([
{
id: 'fluent-inpage',
matches: ['file://*/*', 'http://*/*', 'https://*/*'],
js: ['inpage.js'],
runAt: 'document_start',
world: 'MAIN',
allFrames: true,
},
])
} catch (err) {
console.error('registerInPageContentScript failed:', err)
if (count < 3) {
// retry
registerInPageContentScript()
}
}
}

registerInPageContentScript()
2 changes: 1 addition & 1 deletion packages/base32-address/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fluent-wallet/base32-address",
"type": "module",
"main": "index.js",
"version": "0.1.4",
"version": "0.1.5",
"dependencies": {
"@fluent-wallet/account": "workspace:packages/account",
"@fluent-wallet/consts": "workspace:packages/consts",
Expand Down
2 changes: 1 addition & 1 deletion packages/browser-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browser-extension",
"version": "0.0.33",
"version": "0.0.40",
"main": "index.js",
"author": "yqrashawn <namy.19@gmail.com>",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions packages/consts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const TESTNET = 'testnet'
export const LOCALHOST = 'localhost'
export const CUSTOM = 'custom'
export const EXT_STORAGE = 'ext-storage'
export const SIDE_PANEL_KEY = 'side-panel'
export const NULL_HEX_ADDRESS = '0x0000000000000000000000000000000000000000'
export const ADMINE_CONTROL_HEX_ADDRESS =
'0x0888000000000000000000000000000000000000'
Expand Down
2 changes: 1 addition & 1 deletion packages/consts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "@fluent-wallet/consts",
"type": "module",
"main": "index.js",
"version": "0.0.24"
"version": "0.0.25"
}
25 changes: 5 additions & 20 deletions packages/content-script/indexTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import browser from 'webextension-polyfill'
import {stream} from '@thi.ng/rstream'
import {getSiteMetadata} from '@fluent-wallet/site-metadata'

let INPAGE_INJECTED = false

function _retry() {
let retryTimeout = 100
if (CONNECT_RETRY_COUNT >= 10) {
Expand All @@ -23,22 +21,6 @@ function _retry() {
setTimeout(setup, retryTimeout)
}

function injectInpage(content) {
try {
const container = document.head || document.documentElement
const scriptTag = document.createElement('script')
scriptTag.setAttribute('async', 'false')
if (content) scriptTag.textContent = content
else scriptTag.src = browser.runtime.getURL('inpage.js')
container.insertBefore(scriptTag, container.children[0])
container.removeChild(scriptTag)
INPAGE_INJECTED = true
registerSite()
} catch (error) {
console.error('Fluent Wallet: Provider injection failed.', error)
}
}

let CONNECT_RETRY_COUNT = 0
let s

Expand Down Expand Up @@ -91,6 +73,10 @@ function setup() {
typeof e.data.msg !== 'object'
)
return
if (e.data.msg.event === '__INPAGE_INJECTED__') {
registerSite()
return
}
if (!e.data.msg.method) return
if (e.data.msg.jsonrpc !== '2.0') return
if (!Number.isInteger(e.data.msg.id)) return
Expand Down Expand Up @@ -125,7 +111,6 @@ function setup() {
)
})

if (INPAGE_INJECTED) registerSite()
registerSite()
}
injectInpage()
setup()
2 changes: 1 addition & 1 deletion packages/content-script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"main": "index.js",
"type": "module",
"version": "1.0.3",
"version": "1.0.4",
"dependencies": {
"@fluent-wallet/site-metadata": "workspace:packages/site-metadata",
"@thi.ng/rstream": "6.0.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/contract-method-name/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@fluent-wallet/contract-method-name",
"type": "module",
"version": "2.0.2",
"version": "2.0.3",
"main": "index.js",
"dependencies": {
"@ethersproject/abi": "5.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fluent-wallet/db",
"version": "1.0.78",
"version": "1.0.79",
"main": "index.js",
"type": "module",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/detect-address-type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"main": "index.js",
"packageManager": "yarn@3.0.1",
"version": "0.0.3",
"version": "0.0.4",
"dependencies": {
"@fluent-wallet/base32-address": "workspace:packages/base32-address",
"@fluent-wallet/checks": "workspace:packages/checks"
Expand Down
2 changes: 1 addition & 1 deletion packages/did/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fluent-wallet/did",
"main": "index.js",
"type": "module",
"version": "0.0.5",
"version": "0.0.6",
"dependencies": {
"@ensdomains/eth-ens-namehash": "2.0.15",
"@fluent-wallet/base32-address": "workspace:packages/base32-address",
Expand Down
2 changes: 1 addition & 1 deletion packages/estimate-tx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"main": "index.js",
"packageManager": "yarn@3.0.1",
"version": "0.2.5",
"version": "0.2.6",
"dependencies": {
"@fluent-wallet/consts": "workspace:*",
"@fluent-wallet/detect-address-type": "workspace:packages/detect-address-type",
Expand Down
2 changes: 1 addition & 1 deletion packages/inpage/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "helios-inpage",
"type": "module",
"version": "4.0.5",
"version": "4.0.7",
"main": "index.js",
"author": "yqrashawn <namy.19@gmail.com>",
"private": true,
Expand Down
15 changes: 9 additions & 6 deletions packages/inpage/setup-inpage-provider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {rpcStream} from '@fluent-wallet/extension-runtime/rpc-stream.js'
import {initProvider} from '@fluent-wallet/provider-api'
import {takeOver} from './take-over-portal'
import {announceProvider} from './eip-6963'
import {v4 as uuid} from 'uuid'

Expand Down Expand Up @@ -69,6 +68,10 @@ function setupProvider() {
location.origin,
)

post({
event: '__INPAGE_INJECTED__',
})

const {send: sendToBg, stream} = rpcStream({
postMessage: post,
onMessage: {
Expand All @@ -90,17 +93,17 @@ function setupProvider() {
})

window.fluent = PROVIDER
if (!window.ethereum) window.ethereum = PROVIDER
Object.defineProperty(window, 'conflux', {value: PROVIDER, writable: false})
takeOver(PROVIDER, 'cfx')

if (window.localStorage.getItem(FLUENT_OVERRIDE_WINDOW_DOT_ETHEREUM)) {
if (
!window.ethereum ||
window.localStorage.getItem(FLUENT_OVERRIDE_WINDOW_DOT_ETHEREUM)
) {
try {
Object.defineProperty(window, 'ethereum', {
value: PROVIDER,
writable: false,
configurable: false,
})
takeOver(PROVIDER, 'eth')
} catch (error) {
console.log('Failed to override window.ethereum', error)
}
Expand Down
11 changes: 8 additions & 3 deletions packages/inpage/setup-inpage-provider.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {expect, describe, it, vi} from 'vitest'
import {expect, describe, it, vi, beforeEach} from 'vitest'
import {EIP6963EventNames} from './eip-6963.js'

beforeEach(async () => {
window.ethereum = 1
})

describe('inpage', () => {
describe('setupProvider', () => {
it('should setup the provider on window.conflux', async () => {
Expand All @@ -16,9 +21,9 @@ describe('inpage', () => {
expect(eventNames[1]).toBe(EIP6963EventNames.Request)
expect(window.conflux).toBeDefined()
})

})
describe('setupProvider', () => {
it('should not setup the provider on window.ethereum when already defined', async () => {
window.ethereum = 1
expect(window.ethereum).toBe(1)
await import('./index.js')
expect(window.ethereum).toBe(1)
Expand Down
16 changes: 11 additions & 5 deletions packages/inpage/take-over-portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ function _takeOverEthereum(PROVIDER, resolve) {
export async function takeOver(PROVIDER, type = 'cfx') {
if (!PROVIDER) return
const takeOverFn = type === 'cfx' ? _takeOverConflux : _takeOverEthereum
return await new Promise(resolve => {
TakeOverInterval[type] = setInterval(
() => takeOverFn(PROVIDER, resolve),
50,
)
return await new Promise((resolve, reject) => {
TakeOverInterval[type] = setInterval(() => {
try {
takeOverFn(PROVIDER, resolve)
} catch (error) {
if (error?.message?.includes('Cannot redefine property')) {
clearInterval(TakeOverInterval[type])
reject(error)
}
}
}, 50)
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fluent-wallet/ledger",
"type": "module",
"main": "index.js",
"version": "0.1.1",
"version": "0.1.2",
"dependencies": {
"@fluent-wallet/base32-address": "workspace:packages/base32-address",
"@fluent-wallet/hw-app-conflux": "0.1.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/manifest/manifestv3.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"default_title": "Fluent",
"default_popup": "popup.html"
},
"side_panel": {
"default_path": "sidePanel.html"
},
"content_scripts": [
{
"matches": ["file://*/*", "http://*/*", "https://*/*"],
Expand All @@ -78,7 +81,9 @@
"unlimitedStorage",
"clipboardWrite",
"tabs",
"scripting",
"activeTab",
"sidePanel",
"notifications"
],
"host_permissions": [
Expand Down
2 changes: 1 addition & 1 deletion packages/popup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "helios-popup",
"type": "module",
"version": "0.1.15",
"version": "0.1.19",
"main": "index.js",
"author": "yqrashawn <namy.19@gmail.com>",
"license": "MIT",
Expand Down
Loading
Loading