Skip to content

Commit 99ad92d

Browse files
[Release] Hotfix 2.21.0 => 2.21.1 (patch) (#9852)
* chore: bump version 2.21.1 * fix: incorrect transaction record (#9853) * fix: computed payment token (#9860) * fix: sns adaptor context (#9858) * chore: update lock file * refactor: code style * refactor: naming * refactor: remove bridge * refactor: remove logs * refactor: send should be readonly * fix: adjust chain id resolver (#9851) * fix: debank cache time (#9863) * fix: set debank cache time to short * fix: add new duration type * fix: remove deploy transaction after confirm transaction successfully (#9862) --------- Co-authored-by: nuanyang233 <[email protected]>
1 parent 565a70f commit 99ad92d

File tree

27 files changed

+162
-267
lines changed

27 files changed

+162
-267
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"yarn": ">=999.0.0",
99
"npm": ">=999.0.0"
1010
},
11-
"version": "2.21.0",
11+
"version": "2.21.1",
1212
"private": true,
1313
"license": "AGPL-3.0-or-later",
1414
"scripts": {

packages/mask/src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Mask Network",
3-
"version": "2.21.0",
3+
"version": "2.21.1",
44
"manifest_version": 2,
55
"permissions": ["storage", "downloads", "webNavigation", "activeTab"],
66
"optional_permissions": ["<all_urls>", "notifications", "clipboardRead"],

packages/mask/src/plugins/Savings/SNSAdaptor/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { useState } from 'react'
2+
import { Trans } from 'react-i18next'
13
import type { Plugin } from '@masknet/plugin-infra'
24
import { ApplicationEntry } from '@masknet/shared'
35
import { Icons } from '@masknet/icons'
4-
import { Trans } from 'react-i18next'
5-
import { useState } from 'react'
66
import { base } from '../base.js'
77
import { SavingsDialog } from './SavingsDialog.js'
88

packages/mask/src/plugins/Wallet/services/send.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isNil } from 'lodash-es'
22
import type { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers'
33
import { defer } from '@masknet/kit'
44
import { ECKeyIdentifier, type SignType } from '@masknet/shared-base'
5-
import { SmartPayAccount, Web3 } from '@masknet/web3-providers'
5+
import { SmartPayAccount, Web3Readonly } from '@masknet/web3-providers'
66
import {
77
ChainId,
88
createJsonRpcResponse,
@@ -15,8 +15,8 @@ import {
1515
} from '@masknet/web3-shared-evm'
1616
import { WalletRPC } from '../messages.js'
1717
import { signWithWallet } from './wallet/index.js'
18-
import { openPopupWindow, removePopupWindow } from '../../../../background/services/helper/index.js'
1918
import { signWithPersona } from '../../../../background/services/identity/index.js'
19+
import { openPopupWindow, removePopupWindow } from '../../../../background/services/helper/index.js'
2020

2121
/**
2222
* Send to built-in RPC endpoints.
@@ -62,7 +62,9 @@ async function internalSend(
6262
null,
6363
createJsonRpcResponse(
6464
pid,
65-
await Web3.sendSignedTransaction(await signer.signTransaction(signableConfig), { chainId }),
65+
await Web3Readonly.sendSignedTransaction(await signer.signTransaction(signableConfig), {
66+
chainId,
67+
}),
6668
),
6769
)
6870
}
@@ -111,7 +113,7 @@ async function internalSend(
111113
callback(new Error('Method not implemented.'))
112114
break
113115
default:
114-
await Web3.getWeb3Provider({ chainId }).send(payload, callback)
116+
await Web3Readonly.getWeb3Provider({ chainId }).send(payload, callback)
115117
break
116118
}
117119
}

packages/plugin-infra/src/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ export namespace Plugin.Shared {
173173

174174
/** Send request to native API, for a risky request will be added into the waiting queue. */
175175
send(payload: JsonRpcPayload, options?: TransactionOptions): Promise<JsonRpcResponse>
176+
176177
/** Confirm a request */
177178
confirmRequest(
178179
payload: JsonRpcPayload,
179180
options?: { disableClose?: boolean; popupsWindow?: boolean },
180181
): Promise<JsonRpcResponse | void>
182+
181183
/** Reject a request */
182184
rejectRequest(payload: JsonRpcPayload): Promise<void>
183185

packages/plugins/EVM/src/UI/Dashboard/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Transaction,
88
TransactionParameter,
99
} from '@masknet/web3-shared-evm'
10-
import { SharedUIPluginContext, Web3State } from '@masknet/web3-providers'
10+
import { SharedPluginContext, Web3State } from '@masknet/web3-providers'
1111
import { base } from '../../base.js'
1212

1313
const dashboard: Plugin.Dashboard.Definition<
@@ -20,7 +20,7 @@ const dashboard: Plugin.Dashboard.Definition<
2020
> = {
2121
...base,
2222
async init(signal, context) {
23-
SharedUIPluginContext.setup(context)
23+
SharedPluginContext.setup(context)
2424

2525
const state = await Web3State.create(context)
2626

packages/plugins/EVM/src/UI/SNSAdaptor/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Transaction,
88
TransactionParameter,
99
} from '@masknet/web3-shared-evm'
10-
import { SharedUIPluginContext, Web3State } from '@masknet/web3-providers'
10+
import { SharedPluginContext, Web3State } from '@masknet/web3-providers'
1111
import { base } from '../../base.js'
1212

1313
const sns: Plugin.SNSAdaptor.Definition<
@@ -20,7 +20,7 @@ const sns: Plugin.SNSAdaptor.Definition<
2020
> = {
2121
...base,
2222
async init(signal, context) {
23-
SharedUIPluginContext.setup(context)
23+
SharedPluginContext.setup(context)
2424

2525
const state = await Web3State.create(context)
2626

packages/plugins/Flow/src/UI/Dashboard/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Transaction,
88
TransactionParameter,
99
} from '@masknet/web3-shared-flow'
10-
import { FlowWeb3State, SharedUIPluginContext } from '@masknet/web3-providers'
10+
import { FlowWeb3State, SharedPluginContext } from '@masknet/web3-providers'
1111
import { base } from '../../base.js'
1212

1313
const dashboard: Plugin.Dashboard.Definition<
@@ -20,7 +20,7 @@ const dashboard: Plugin.Dashboard.Definition<
2020
> = {
2121
...base,
2222
async init(signal, context) {
23-
SharedUIPluginContext.setup(context)
23+
SharedPluginContext.setup(context)
2424

2525
const state = await FlowWeb3State.create(context)
2626

packages/plugins/Flow/src/UI/SNSAdaptor/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Transaction,
88
TransactionParameter,
99
} from '@masknet/web3-shared-flow'
10-
import { FlowWeb3State, SharedUIPluginContext } from '@masknet/web3-providers'
10+
import { FlowWeb3State, SharedPluginContext } from '@masknet/web3-providers'
1111
import { base } from '../../base.js'
1212

1313
const sns: Plugin.SNSAdaptor.Definition<
@@ -20,7 +20,7 @@ const sns: Plugin.SNSAdaptor.Definition<
2020
> = {
2121
...base,
2222
async init(signal, context) {
23-
SharedUIPluginContext.setup(context)
23+
SharedPluginContext.setup(context)
2424

2525
const state = await FlowWeb3State.create(context)
2626

packages/plugins/SmartPay/src/hooks/useDeploy.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function useDeploy(
3232
const snackbarKeyRef = useRef<SnackbarKey>()
3333
const t = useI18N()
3434

35-
const { TransactionWatcher } = useWeb3State()
35+
const { TransactionWatcher, Transaction } = useWeb3State()
3636
const { signWithPersona, hasPaymentPassword, openPopupWindow } = useSNSAdaptorContext()
3737
const lastRecognizedIdentity = useLastRecognizedIdentity()
3838
const { chainId } = useChainContext<NetworkPluginID.PLUGIN_EVM>()
@@ -130,7 +130,8 @@ export function useDeploy(
130130

131131
const deployResult = await Web3.confirmTransaction(deployHash, options)
132132
if (!deployResult?.status) return
133-
133+
await Transaction?.removeTransaction?.(chainId, '', hash)
134+
await Transaction?.removeTransaction?.(chainId, '', deployHash)
134135
onSuccess?.()
135136

136137
return deployResult.transactionHash
@@ -172,5 +173,6 @@ export function useDeploy(
172173
nonce,
173174
onSuccess,
174175
TransactionWatcher,
176+
Transaction,
175177
])
176178
}

packages/plugins/Solana/src/UI/Dashboard/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Transaction,
88
TransactionParameter,
99
} from '@masknet/web3-shared-solana'
10-
import { SharedUIPluginContext, SolanaWeb3State } from '@masknet/web3-providers'
10+
import { SharedPluginContext, SolanaWeb3State } from '@masknet/web3-providers'
1111
import { base } from '../../base.js'
1212

1313
const dashboard: Plugin.Dashboard.Definition<
@@ -20,7 +20,7 @@ const dashboard: Plugin.Dashboard.Definition<
2020
> = {
2121
...base,
2222
async init(signal, context) {
23-
SharedUIPluginContext.setup(context)
23+
SharedPluginContext.setup(context)
2424

2525
const state = await SolanaWeb3State.create(context)
2626

packages/plugins/Solana/src/UI/SNSAdaptor/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Transaction,
88
TransactionParameter,
99
} from '@masknet/web3-shared-solana'
10-
import { SharedUIPluginContext, SolanaWeb3State } from '@masknet/web3-providers'
10+
import { SharedPluginContext, SolanaWeb3State } from '@masknet/web3-providers'
1111
import { base } from '../../base.js'
1212

1313
const sns: Plugin.SNSAdaptor.Definition<
@@ -20,7 +20,7 @@ const sns: Plugin.SNSAdaptor.Definition<
2020
> = {
2121
...base,
2222
async init(signal, context) {
23-
SharedUIPluginContext.setup(context)
23+
SharedPluginContext.setup(context)
2424

2525
const state = await SolanaWeb3State.create(context)
2626

packages/web3-providers/src/DeBank/apis/FungibleTokenAPI.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class DeBankFungibleTokenAPI implements FungibleTokenAPI.Provider<ChainId
2323
{
2424
enableSquash: true,
2525
enableCache: true,
26-
cacheDuration: Duration.LONG,
26+
cacheDuration: Duration.MINIMAL,
2727
},
2828
)
2929

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Plugin } from '@masknet/plugin-infra'
2+
import { ValueRefWithReady } from '@masknet/shared-base'
3+
import { BaseContextAPI } from './BaseAPI.js'
4+
5+
type Context = Pick<Plugin.Shared.SharedUIContext, 'signWithPersona' | 'send'>
6+
7+
export const SharedContextRef = new ValueRefWithReady<Context>()
8+
9+
export class SharedContextAPI extends BaseContextAPI<Context> {
10+
constructor() {
11+
super(SharedContextRef)
12+
}
13+
}

packages/web3-providers/src/PluginContext/apis/SharedUIContextAPI.ts

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './apis/SharedUIContextAPI.js'
1+
export * from './apis/SharedContextAPI.js'
22
export * from './apis/SNSAdaptorContextAPI.js'

packages/web3-providers/src/Storage/apis/Storage.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { NextIDStorage } from '../storages/NextID.js'
44
import { RSS3Storage } from '../storages/RSS3.js'
55
import { FireflyStorage } from '../storages/Firefly.js'
66
import type { StorageAPI } from '../../entry-types.js'
7-
import { SharedUIContextRef } from '../../PluginContext/index.js'
7+
import { SharedContextRef } from '../../PluginContext/index.js'
88

99
export class Web3StorageAPI implements StorageAPI.Provider {
1010
createKVStorage(namespace: string) {
@@ -21,6 +21,6 @@ export class Web3StorageAPI implements StorageAPI.Provider {
2121

2222
createNextIDStorage(proofIdentity: string, platform: NextIDPlatform, signerOrPublicKey: string | ECKeyIdentifier) {
2323
if (!platform || !signerOrPublicKey) throw new Error('Instantiation parameter error.')
24-
return new NextIDStorage(proofIdentity, platform, signerOrPublicKey, SharedUIContextRef.value.signWithPersona)
24+
return new NextIDStorage(proofIdentity, platform, signerOrPublicKey, SharedContextRef.value.signWithPersona)
2525
}
2626
}

packages/web3-providers/src/Web3/EVM/helpers/createContext.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { RequestArguments } from 'web3-core'
22
import { ProviderType, ChainId } from '@masknet/web3-shared-evm'
33
import { type BaseContractWalletProvider, Providers } from '@masknet/web3-providers'
4-
import { SharedUIContextRef } from '../../../PluginContext/index.js'
54
import { Web3StateRef } from '../apis/Web3StateAPI.js'
65
import { ConnectionContext } from '../libs/ConnectionContext.js'
76
import type { ConnectionOptions } from '../types/index.js'
@@ -29,9 +28,5 @@ const initializer = {
2928
}
3029

3130
export function createContext(requestArguments: RequestArguments, options?: ConnectionOptions) {
32-
return new ConnectionContext(requestArguments, options, {
33-
...initializer,
34-
mask_send: SharedUIContextRef.value.send,
35-
mask_signWithPersona: SharedUIContextRef.value.signWithPersona,
36-
})
31+
return new ConnectionContext(requestArguments, options, initializer)
3732
}

packages/web3-providers/src/Web3/EVM/interceptors/ContractWallet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ContractReadonlyAPI } from '../apis/ContractReadonlyAPI.js'
1515
import type { ConnectionContext } from '../libs/ConnectionContext.js'
1616
import { Providers } from '../providers/index.js'
1717
import type { BaseContractWalletProvider } from '../providers/BaseContractWallet.js'
18+
import { SharedContextRef } from '../../../PluginContext/index.js'
1819
import type { BundlerAPI, AbstractAccountAPI, FunderAPI } from '../../../entry-types.js'
1920

2021
export class ContractWallet implements Middleware<ConnectionContext> {
@@ -39,8 +40,7 @@ export class ContractWallet implements Middleware<ConnectionContext> {
3940
return new Signer(
4041
context.identifier,
4142
async <T>(type: SignType, message: T, identifier?: ECKeyIdentifier) => {
42-
if (!context.bridge.signWithPersona) return ''
43-
return context.bridge.signWithPersona(type, message, identifier, true)
43+
return SharedContextRef.value.signWithPersona(type, message, identifier, true)
4444
},
4545
)
4646
if (context.owner)

packages/web3-providers/src/Web3/EVM/interceptors/Popups.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
ProviderType,
1313
} from '@masknet/web3-shared-evm'
1414
import { ExtensionSite, getSiteType, isEnhanceableSiteType } from '@masknet/shared-base'
15-
import { isGreaterThan, toFixed } from '@masknet/web3-shared-base'
15+
import { isGreaterThan, isZero, toFixed } from '@masknet/web3-shared-base'
16+
import { SharedContextRef } from '../../../PluginContext/index.js'
1617
import { SmartPayBundlerAPI } from '../../../SmartPay/index.js'
1718
import { ConnectionReadonlyAPI } from '../apis/ConnectionReadonlyAPI.js'
1819
import { ContractReadonlyAPI } from '../apis/ContractReadonlyAPI.js'
@@ -30,6 +31,7 @@ export class Popups implements Middleware<ConnectionContext> {
3031
private Bundler = new SmartPayBundlerAPI()
3132

3233
private async getPaymentToken(context: ConnectionContext) {
34+
const maskAddress = getMaskTokenAddress(context.chainId)
3335
try {
3436
const smartPayChainId = await this.Bundler.getSupportedChainId()
3537
if (context.chainId !== smartPayChainId || !context.owner) return DEFAULT_PAYMENT_TOKEN_STATE
@@ -46,8 +48,6 @@ export class Popups implements Middleware<ConnectionContext> {
4648

4749
if (!signableConfig?.maxFeePerGas) return DEFAULT_PAYMENT_TOKEN_STATE
4850

49-
const maskAddress = getMaskTokenAddress(context.chainId)
50-
5151
const gas = await this.Web3.estimateTransaction?.(signableConfig, undefined, {
5252
chainId: context.chainId,
5353
account: context.account,
@@ -82,6 +82,14 @@ export class Popups implements Middleware<ConnectionContext> {
8282
paymentToken: context.paymentToken ?? !availableBalanceTooLow ? maskAddress : undefined,
8383
}
8484
} catch (error) {
85+
const nativeBalance = await this.Web3.getNativeTokenBalance({
86+
account: context.account,
87+
chainId: context.chainId,
88+
})
89+
90+
if (isZero(nativeBalance))
91+
return { allowMaskAsGas: true, paymentToken: context.paymentToken ?? maskAddress }
92+
8593
return {
8694
allowMaskAsGas: false,
8795
paymentToken: undefined,
@@ -107,7 +115,7 @@ export class Popups implements Middleware<ConnectionContext> {
107115
isUndefined,
108116
)
109117

110-
const response = await context.bridge.send?.(context.request, options)
118+
const response = await SharedContextRef.value.send(context.request, options)
111119
const editor = ErrorEditor.from(null, response)
112120

113121
if (editor.presence) {

0 commit comments

Comments
 (0)