Skip to content

Commit

Permalink
refactor: rp plugin code style (#12065)
Browse files Browse the repository at this point in the history
* refactor: rp plugin code style

* fix: build errors
  • Loading branch information
guanbinrui authored Jan 23, 2025
1 parent 724c4c5 commit 1bee7f7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,14 @@ export function useCreateNftRedpacketCallback(
}

// #region check ownership
type CheckMethodParameters = Parameters<NftRedPacket['methods']['check_ownership']>

const checkParams: CheckMethodParameters = [tokenIdList, contractAddress]
const checkParams: Parameters<NftRedPacket['methods']['check_ownership']> = [tokenIdList, contractAddress]

const isOwner = await nftRedPacketContract.methods.check_ownership(...checkParams).call({ from: account })

if (!isOwner) {
return
}
if (!isOwner) return

// #endregion

type FillMethodParameters = Parameters<NftRedPacket['methods']['create_red_packet']>

const params: FillMethodParameters = [
const params: Parameters<NftRedPacket['methods']['create_red_packet']> = [
publicKey,
duration,
web3_utils.sha3(Math.random().toString())!,
Expand Down Expand Up @@ -87,11 +80,10 @@ export function useCreateNftRedpacketCallback(
})
const receipt = await EVMWeb3.getTransactionReceipt(hash)
if (receipt) {
const events = decodeEvents(nftRedPacketContract.options.jsonInterface, receipt.logs)
return {
hash,
receipt,
events,
events: decodeEvents(nftRedPacketContract.options.jsonInterface, receipt.logs),
}
}
return { hash, receipt }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EventID, EventType } from '@masknet/web3-telemetry/types'
import { useCallback, useContext } from 'react'
import * as web3_utils from /* webpackDefer: true */ 'web3-utils'
import { openComposition } from '../openComposition.js'
import { reduceUselessPayloadInfo } from '../utils/reduceUselessPayloadInfo.js'
import { reduceUselessPayloadInfo } from '../helpers/reduceUselessPayloadInfo.js'
import { CompositionTypeContext } from '../contexts/CompositionTypeContext.js'

interface Options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Telemetry } from '@masknet/web3-telemetry'
import { EventID, EventType } from '@masknet/web3-telemetry/types'
import { useCallback, useContext } from 'react'
import { openComposition } from '../openComposition.js'
import { reduceUselessPayloadInfo } from '../utils/reduceUselessPayloadInfo.js'
import { reduceUselessPayloadInfo } from '../helpers/reduceUselessPayloadInfo.js'
import { CompositionTypeContext } from '../contexts/CompositionTypeContext.js'

interface Options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { FireflyRedPacketAPI as F } from '@masknet/web3-providers/types'
export function usePlatformType() {
const source = usePostInfoDetails.source?.()
if (Sniffings.is_twitter_page) return F.PlatformType.twitter
if (!source) return ''
if (!source) return
return source === 'Lens' ? F.PlatformType.lens : F.PlatformType.farcaster
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useRedpacketToken(chainId: ChainId, hash: string, enabled?: bool
queryFn: async () => {
const receipt = await web3Conn.getTransactionReceipt(hash)
if (!receipt || !inputs) return null
if (!web3) return
if (!web3) return null
const log = receipt.logs.find((x) => x.topics[0] === CREATE_LUCKY_DROP_TOPIC)
if (!log) return null

Expand Down

0 comments on commit 1bee7f7

Please sign in to comment.