Skip to content

Commit 8897d2f

Browse files
authored
[Release] Hotfix 2.23.5 => 2.23.6 (patch) (#11032)
1 parent 352b9b0 commit 8897d2f

File tree

6 files changed

+69
-53
lines changed

6 files changed

+69
-53
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.23.5",
11+
"version": "2.23.6",
1212
"private": true,
1313
"license": "AGPL-3.0-or-later",
1414
"scripts": {

packages/plugins/RedPacket/src/SiteAdaptor/RedPacketERC20Form.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ export function RedPacketERC20Form(props: RedPacketFormProps) {
373373
actualPluginID={pluginID}>
374374
<EthereumERC20TokenApprovedBoundary
375375
amount={totalAmount.toFixed()}
376+
balance={balance}
376377
classes={{ container: classes.unlockContainer }}
377378
ActionButtonProps={{
378379
size: 'medium',

packages/shared/src/UI/components/EthereumERC20TokenApprovedBoundary/index.tsx

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import React, { useCallback, useMemo } from 'react'
12
import { unreachable } from '@masknet/kit'
23
import { TokenIcon } from '@masknet/shared'
34
import { NetworkPluginID } from '@masknet/shared-base'
45
import { ActionButton, ShadowRootTooltip, makeStyles, type ActionButtonProps } from '@masknet/theme'
5-
import { useChainContext, useFungibleTokenSpenders } from '@masknet/web3-hooks-base'
6+
import { useChainContext, useFungibleTokenBalance, useFungibleTokenSpenders } from '@masknet/web3-hooks-base'
67
import { ApproveStateType, useERC20TokenApproveCallback } from '@masknet/web3-hooks-evm'
7-
import { isGte, isSameAddress, type FungibleToken } from '@masknet/web3-shared-base'
8+
import { isGte, isSameAddress, type FungibleToken, rightShift } from '@masknet/web3-shared-base'
89
import type { ChainId, SchemaType } from '@masknet/web3-shared-evm'
910
import { HelpOutline } from '@mui/icons-material'
10-
import React, { useCallback } from 'react'
1111
import { useSharedI18N } from '../../../locales/index.js'
1212

1313
const useStyles = makeStyles<void, 'icon'>()((theme, _, refs) => ({
@@ -29,6 +29,7 @@ const useStyles = makeStyles<void, 'icon'>()((theme, _, refs) => ({
2929

3030
export interface EthereumERC20TokenApprovedBoundaryProps extends withClasses<'button' | 'container'> {
3131
amount: string
32+
balance?: string
3233
spender?: string
3334
token?: FungibleToken<ChainId, SchemaType>
3435
fallback?: React.ReactNode
@@ -45,6 +46,7 @@ export function EthereumERC20TokenApprovedBoundary(props: EthereumERC20TokenAppr
4546
const {
4647
children = null,
4748
amount,
49+
balance,
4850
spender,
4951
token,
5052
infiniteUnlockContent,
@@ -57,6 +59,9 @@ export function EthereumERC20TokenApprovedBoundary(props: EthereumERC20TokenAppr
5759
const t = useSharedI18N()
5860
const { classes } = useStyles(undefined, { props })
5961
const { account, chainId } = useChainContext<NetworkPluginID.PLUGIN_EVM>({ chainId: token?.chainId })
62+
const { data: tokenBalance } = useFungibleTokenBalance(NetworkPluginID.PLUGIN_EVM, token?.address, {
63+
chainId,
64+
})
6065

6166
const {
6267
data: spenders,
@@ -68,20 +73,28 @@ export function EthereumERC20TokenApprovedBoundary(props: EthereumERC20TokenAppr
6873
account,
6974
})
7075

76+
const approveAmount = balance || tokenBalance || amount
7177
const [{ type: approveStateType, allowance }, transactionState, approveCallback] = useERC20TokenApproveCallback(
7278
token?.address ?? '',
73-
amount,
79+
approveAmount,
7480
spender ?? '',
7581
() => {
7682
callback?.()
7783
refetch()
7884
},
7985
token?.chainId,
8086
)
81-
82-
const approved =
83-
isGte(allowance, amount) ||
84-
spenders?.some((x) => isSameAddress(x.tokenInfo.address, token?.address) && isSameAddress(x.address, spender))
87+
const approved = useMemo(() => {
88+
if (isGte(allowance, amount)) return true
89+
if (!token?.address || !spenders?.length) return false
90+
return spenders.some((x) => {
91+
return (
92+
isSameAddress(x.tokenInfo.address, token.address) &&
93+
isSameAddress(x.address, spender) &&
94+
isGte(rightShift(x.amount || 0, x.tokenInfo.decimals || token.decimals), amount)
95+
)
96+
})
97+
}, [allowance, amount, spenders, token?.address, token?.decimals, spender])
8598

8699
const loading =
87100
spendersLoading ||

packages/web3-shared/base/src/specs/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ export interface NonFungibleAsset<ChainId, SchemaType> extends NonFungibleToken<
610610
* Authorization about a fungible token.
611611
*/
612612
export interface FungibleTokenSpender<ChainId, SchemaType> {
613-
tokenInfo: Pick<FungibleToken<ChainId, SchemaType>, 'address' | 'logoURL' | 'symbol' | 'name'>
613+
tokenInfo: Pick<FungibleToken<ChainId, SchemaType>, 'address' | 'logoURL' | 'symbol' | 'name'> & {
614+
decimals?: number
615+
}
614616
/** spender address */
615617
address: string
616618
/** spender name */

packages/web3-shared/evm/src/constants/chains.json

+26-26
Original file line numberDiff line numberDiff line change
@@ -413,25 +413,27 @@
413413
]
414414
},
415415
{
416-
"chainId": 250,
417-
"type": "Fantom",
418-
"name": "Fantom",
419-
"fullName": "Fantom Opera",
416+
"chainId": 534352,
417+
"type": "Scroll",
418+
"name": "Scroll",
420419
"network": "mainnet",
421-
"shortName": "ftm",
420+
"fullName": "Scroll",
421+
"shortName": "Scroll",
422+
"rpc": ["https://rpc.scroll.io"],
423+
"faucets": [],
422424
"features": [],
423425
"nativeCurrency": {
424-
"chainId": 250,
425-
"name": "Fantom",
426-
"symbol": "FTM",
426+
"chainId": 534352,
427+
"name": "Ether",
428+
"symbol": "ETH",
427429
"decimals": 18,
428-
"logoURL": "https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/fantom/info/logo.png/quality=85"
430+
"logoURL": "https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/ethereum/info/logo.png/quality=85"
429431
},
430-
"infoURL": "https://fantom.foundation",
432+
"infoURL": "https://scrollscan.com/",
431433
"explorers": [
432434
{
433-
"name": "ftmscan",
434-
"url": "https://ftmscan.com",
435+
"name": "blockscout",
436+
"url": "https://scrollscan.com/",
435437
"standard": "EIP3091"
436438
}
437439
]
@@ -649,27 +651,25 @@
649651
]
650652
},
651653
{
652-
"chainId": 534352,
653-
"type": "Scroll",
654-
"name": "Scroll",
654+
"chainId": 250,
655+
"type": "Fantom",
656+
"name": "Fantom",
657+
"fullName": "Fantom Opera",
655658
"network": "mainnet",
656-
"fullName": "Scroll",
657-
"shortName": "Scroll",
658-
"rpc": ["https://rpc.scroll.io"],
659-
"faucets": [],
659+
"shortName": "ftm",
660660
"features": [],
661661
"nativeCurrency": {
662-
"chainId": 534352,
663-
"name": "Ether",
664-
"symbol": "ETH",
662+
"chainId": 250,
663+
"name": "Fantom",
664+
"symbol": "FTM",
665665
"decimals": 18,
666-
"logoURL": "https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/ethereum/info/logo.png/quality=85"
666+
"logoURL": "https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/fantom/info/logo.png/quality=85"
667667
},
668-
"infoURL": "https://scrollscan.com/",
668+
"infoURL": "https://fantom.foundation",
669669
"explorers": [
670670
{
671-
"name": "blockscout",
672-
"url": "https://scrollscan.com/",
671+
"name": "ftmscan",
672+
"url": "https://ftmscan.com",
673673
"standard": "EIP3091"
674674
}
675675
]

packages/web3-shared/evm/src/constants/descriptors.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,16 @@ export const NETWORK_DESCRIPTORS: Array<NetworkDescriptor<ChainId, NetworkType>>
197197
isMainnet: false,
198198
},
199199
{
200-
ID: `${PLUGIN_ID}_fantom`,
200+
ID: `${PLUGIN_ID}_scroll`,
201201
networkSupporterPluginID: PLUGIN_ID,
202-
chainId: ChainId.Fantom,
203-
type: NetworkType.Fantom,
204-
name: 'Fantom',
205-
icon: new URL('../assets/fantom.png', import.meta.url).href,
206-
iconColor: 'rgb(73, 169, 166)',
207-
averageBlockDelay: 10,
208-
backgroundGradient: 'linear-gradient(180deg, rgba(24, 94, 255, 0.15) 0%, rgba(24, 94, 255, 0.05) 100%)',
202+
chainId: ChainId.Scroll,
203+
type: NetworkType.Scroll,
204+
name: 'Scroll',
205+
icon: new URL('../assets/scroll.svg', import.meta.url).href,
206+
backgroundGradient:
207+
'linear-gradient(180deg, rgba(98, 126, 234, 0.15) 0%, rgba(98, 126, 234, 0.05) 100%), rgba(255, 255, 255, 0.2)',
208+
iconColor: 'rgb(255, 248, 243)',
209+
averageBlockDelay: 9,
209210
isMainnet: true,
210211
},
211212
{
@@ -256,16 +257,15 @@ export const NETWORK_DESCRIPTORS: Array<NetworkDescriptor<ChainId, NetworkType>>
256257
isMainnet: true,
257258
},
258259
{
259-
ID: `${PLUGIN_ID}_scroll`,
260+
ID: `${PLUGIN_ID}_fantom`,
260261
networkSupporterPluginID: PLUGIN_ID,
261-
chainId: ChainId.Scroll,
262-
type: NetworkType.Scroll,
263-
name: 'Scroll',
264-
icon: new URL('../assets/scroll.svg', import.meta.url).href,
265-
backgroundGradient:
266-
'linear-gradient(180deg, rgba(98, 126, 234, 0.15) 0%, rgba(98, 126, 234, 0.05) 100%), rgba(255, 255, 255, 0.2)',
267-
iconColor: 'rgb(255, 248, 243)',
268-
averageBlockDelay: 9,
262+
chainId: ChainId.Fantom,
263+
type: NetworkType.Fantom,
264+
name: 'Fantom',
265+
icon: new URL('../assets/fantom.png', import.meta.url).href,
266+
iconColor: 'rgb(73, 169, 166)',
267+
averageBlockDelay: 10,
268+
backgroundGradient: 'linear-gradient(180deg, rgba(24, 94, 255, 0.15) 0%, rgba(24, 94, 255, 0.05) 100%)',
269269
isMainnet: true,
270270
},
271271
{

0 commit comments

Comments
 (0)