Skip to content
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
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.31.0",
"version": "2.31.1",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
27 changes: 25 additions & 2 deletions packages/web3-hooks/evm/src/useOKXTokenList.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
import { OKX } from '@masknet/web3-providers'
import type { ChainId } from '@masknet/web3-shared-evm'
import { TokenType, type FungibleToken } from '@masknet/web3-shared-base'
import { ChainId, SchemaType } from '@masknet/web3-shared-evm'
import { skipToken, useQuery } from '@tanstack/react-query'

export function useOKXTokenList(chainId: ChainId | undefined, enabled = true) {
return useQuery({
enabled: enabled && !!chainId,
queryKey: ['okx-tokens', chainId],
queryFn: chainId ? () => OKX.getTokens(chainId) : skipToken,
queryFn:
chainId ?
async () => {
const list = await OKX.getTokens(chainId)
if (chainId === ChainId.Scroll && list && !list.some((x) => x.symbol === 'SCR')) {
const scrAddr = '0xd29687c813D741E2F938F4aC377128810E217b1b'
const SCR_Token: FungibleToken<ChainId, SchemaType> = {
id: scrAddr,
chainId: ChainId.Scroll,
type: TokenType.Fungible,
schema: SchemaType.ERC20,
address: scrAddr,
symbol: 'SCR',
name: 'Scroll',
decimals: 18,
logoURL:
'https://www.okx.com/cdn/web3/currency/token/small/534352-0xd29687c813d741e2f938f4ac377128810e217b1b-97?v=1738011884368',
}
return [...list, SCR_Token]
}
return list
}
: skipToken,
})
}
6 changes: 6 additions & 0 deletions packages/web3-providers/src/Cloudflare/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import type { TokenIconAPI } from '../entry-types.js'

class CloudflareAPI implements TokenIconAPI.Provider<ChainId> {
async getFungibleTokenIconURLs(chainId: ChainId, address: string): Promise<string[]> {
// TODO hardcoded for SCR on Scroll chain
if (address.toLowerCase() === '0xd29687c813d741e2f938f4ac377128810e217b1b') {
return [
'https://www.okx.com/cdn/web3/currency/token/small/534352-0xd29687c813d741e2f938f4ac377128810e217b1b-97?v=1738011884368',
]
}
const { NATIVE_TOKEN_ASSET_BASE_URI = EMPTY_LIST, ERC20_TOKEN_ASSET_BASE_URI = EMPTY_LIST } =
getTokenAssetBaseURLConstants(chainId)
const formattedAddress = formatEthereumAddress(address)
Expand Down
5 changes: 3 additions & 2 deletions packages/web3-providers/src/Web3/Base/apis/HubFungible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ export abstract class BaseHubFungible<ChainId, SchemaType> extends AbstractBaseH
initial?: BaseHubOptions<ChainId>,
): Promise<Array<FungibleToken<ChainId, SchemaType>>> {
const options = this.HubOptions.fill({ ...initial, chainId })
const providers = this.getProvidersFungible(initial)
const allProviders = this.getProvidersFungible(initial)
return queryClient.fetchQuery({
queryKey: ['get-fungible-token-list', options.chainId, initial],
queryFn: async () => {
const providers = allProviders.filter((x) => x.getNonFungibleTokenList)
return attemptUntil(
providers.map((x) => () => x.getFungibleTokenList?.(options.chainId)),
providers.map((x) => () => x.getFungibleTokenList!(options.chainId)),
EMPTY_LIST,
)
},
Expand Down
31 changes: 17 additions & 14 deletions packages/web3-providers/src/types/Firefly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,20 +396,23 @@ export namespace FireflyRedPacketAPI {
[RedPacketNftMetaKey]?: object
[SolanaRedPacketMetaKey]?: object
}
redpacket: {
/** the same as meta */
payload: object
canClaim: boolean
canRefund: boolean
canSend: boolean
isPasswordValid: boolean
isClaimed: boolean
isEmpty: boolean
isExpired: boolean
isRefunded: boolean
claimedNumber: number
claimedAmount: string
} | null
redpacket:
| {
/** the same as meta */
payload: object
canClaim: boolean
canRefund: boolean
canSend: boolean
isPasswordValid: boolean
isClaimed: boolean
isEmpty: boolean
isExpired: boolean
isRefunded: boolean
claimedNumber: number
claimedAmount: string
}
// In the backend service, it would be null during fetching the redpacket info.
| null
}
export type ParseResponse = FireflyResponse<ParseResult>

Expand Down