Skip to content

Commit

Permalink
fix: claim info (#12044)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuanyang233 authored Jan 20, 2025
1 parent 2d254d6 commit f5f7d7e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 43 deletions.
47 changes: 10 additions & 37 deletions packages/plugins/RedPacket/src/SiteAdaptor/views/HistoryDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { RedPacketRecord } from '../components/RedPacketRecord.js'
import { EmptyStatus, LoadingStatus } from '@masknet/shared'
import { Trans } from '@lingui/react/macro'
import { useEnvironmentContext } from '@masknet/web3-hooks-base'
import { getRpProgram } from '../helpers/getRpProgram.js'
import * as SolanaWeb3 from /* webpackDefer: true */ '@solana/web3.js'

const useStyles = makeStyles()((theme) => ({
container: {
Expand Down Expand Up @@ -55,40 +53,11 @@ export function HistoryDetail() {
queryFn:
rpid ?
async ({ pageParam }) => {
if (pluginID === NetworkPluginID.PLUGIN_SOLANA) {
const program = await getRpProgram()
const records = await program.account.claimRecord.all([
{
memcmp: {
offset: 8, // Adjust the offset based on your account structure
bytes: new SolanaWeb3.PublicKey(rpid).toBase58(),
},
},
])

const results = records.map<FireflyRedPacketAPI.ClaimInfo>(({ account }) => ({
creator: account.claimer.toBase58(),
claim_platform: [],
token_amounts: account.amount.toString(),
token_symbol: history.token_symbol,
token_decimal: history.token_decimal,
ens_name: '',
}))

return {
chain_id: chainId,
cursor: '',
list: results,
}
} else {
const res = await FireflyRedPacket.getClaimHistory(
rpid,
chainId,
createIndicator(undefined, pageParam),
)

return res
}
return FireflyRedPacket.getClaimHistory(
rpid,
pluginID === NetworkPluginID.PLUGIN_EVM ? chainId : undefined,
createIndicator(undefined, pageParam),
)
}
: skipToken,
getNextPageParam: (lastPage) => lastPage.cursor,
Expand All @@ -100,7 +69,11 @@ export function HistoryDetail() {
return (
<div className={classes.container}>
{history ?
<RedPacketRecord onlyView={!!isClaimed} history={history} showDetailLink={false} />
<RedPacketRecord
onlyView={!!isClaimed}
history={{ ...history, claim_numbers: info?.claim_numbers, total_numbers: info?.total_numbers }}
showDetailLink={false}
/>
: null}
{isLoading ?
<div className={cx(classes.interactions, classes.status)}>
Expand Down
1 change: 1 addition & 0 deletions packages/web3-providers/src/Firefly/RedPacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export class FireflyRedPacket {
address: from,
redpacketType: actionType,
cursor: indicator?.id,
claimFrom: FireflyRedPacketAPI.SourceType.All,
size: 20,
})
const { data } = await fetchJSON<FireflyRedPacketAPI.HistoryResponse>(url)
Expand Down
9 changes: 3 additions & 6 deletions packages/web3-shared/solana/src/constants/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ export const NETWORK_DESCRIPTORS: ReadonlyArray<NetworkDescriptor<ChainId, Netwo
name: 'Solana',
icon: new URL('../assets/solana.png', import.meta.url).href,
iconColor: '#5d6fc0',
backgroundGradient:
'linear-gradient(180deg, rgba(25, 251, 155, 0.15) 0%, rgba(25, 251, 155, 0.05) 100%), rgba(255, 255, 255, 1)',
backgroundGradient: 'linear-gradient(180deg, rgba(25, 251, 155, 0.15) 0%, rgba(25, 251, 155, 0.05) 100%)',
averageBlockDelay: 15,
isMainnet: true,
},
Expand All @@ -124,8 +123,7 @@ export const NETWORK_DESCRIPTORS: ReadonlyArray<NetworkDescriptor<ChainId, Netwo
type: NetworkType.Solana,
name: 'Solana Testnet',
icon: new URL('../assets/solana.png', import.meta.url).href,
backgroundGradient:
'linear-gradient(180deg, rgba(25, 251, 155, 0.15) 0%, rgba(25, 251, 155, 0.05) 100%), rgba(255, 255, 255, 1)',
backgroundGradient: 'linear-gradient(180deg, rgba(25, 251, 155, 0.15) 0%, rgba(25, 251, 155, 0.05) 100%)',
iconColor: '#5d6fc0',
averageBlockDelay: 15,
isMainnet: false,
Expand All @@ -138,8 +136,7 @@ export const NETWORK_DESCRIPTORS: ReadonlyArray<NetworkDescriptor<ChainId, Netwo
name: 'Solana',
icon: new URL('../assets/solana.png', import.meta.url).href,
iconColor: '#5d6fc0',
backgroundGradient:
'linear-gradient(180deg, rgba(25, 251, 155, 0.15) 0%, rgba(25, 251, 155, 0.05) 100%), rgba(255, 255, 255, 1)',
backgroundGradient: 'linear-gradient(180deg, rgba(25, 251, 155, 0.15) 0%, rgba(25, 251, 155, 0.05) 100%)',
averageBlockDelay: 15,
isMainnet: true,
},
Expand Down

0 comments on commit f5f7d7e

Please sign in to comment.