-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#415): Fix chunking of claims of large #s of hotspots, and add a…
… progress bar (#418) * feat(#415): Add progress bar to bulk claims and fix blockhash expiration * feat(#415): Add progress bar to bulk claims and fix blockhash expiration * feat(#415): Add progress bar to bulk claims and fix blockhash expiration * Feature complete * Add missing file
- Loading branch information
1 parent
fed130d
commit 728f827
Showing
16 changed files
with
445 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { BoxProps } from '@shopify/restyle' | ||
import { Theme } from '@theme/theme' | ||
import React, { useCallback, useEffect, useMemo, useState } from 'react' | ||
import { LayoutChangeEvent, LayoutRectangle } from 'react-native' | ||
import { | ||
useAnimatedStyle, | ||
useSharedValue, | ||
withSpring, | ||
} from 'react-native-reanimated' | ||
import { ReAnimatedBox } from './AnimatedBox' | ||
import Box from './Box' | ||
|
||
const ProgressBar = ({ | ||
progress: progressIn, | ||
...rest | ||
}: BoxProps<Theme> & { progress: number }) => { | ||
const HEIGHT = 15 | ||
|
||
const [progressRect, setProgressRect] = useState<LayoutRectangle>() | ||
|
||
const handleLayout = useCallback((e: LayoutChangeEvent) => { | ||
e.persist() | ||
|
||
setProgressRect(e.nativeEvent.layout) | ||
}, []) | ||
|
||
const PROGRESS_WIDTH = useMemo( | ||
() => (progressRect ? progressRect.width : 0), | ||
[progressRect], | ||
) | ||
|
||
const width = useSharedValue(0) | ||
|
||
useEffect(() => { | ||
// withRepeat to repeat the animation | ||
width.value = withSpring((progressIn / 100) * PROGRESS_WIDTH) | ||
}, [PROGRESS_WIDTH, width, progressIn]) | ||
|
||
const progress = useAnimatedStyle(() => { | ||
return { | ||
width: width.value, | ||
} | ||
}) | ||
|
||
return ( | ||
<Box | ||
onLayout={handleLayout} | ||
{...rest} | ||
borderRadius="round" | ||
width="100%" | ||
height={HEIGHT} | ||
backgroundColor="transparent10" | ||
overflow="hidden" | ||
flexDirection="row" | ||
justifyContent="flex-start" | ||
> | ||
<ReAnimatedBox style={progress}> | ||
<Box | ||
height={HEIGHT - 1} | ||
borderRadius="round" | ||
backgroundColor="lightGrey" | ||
/> | ||
</ReAnimatedBox> | ||
</Box> | ||
) | ||
} | ||
|
||
export default ProgressBar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import { useEffect, useState } from 'react' | ||
import { decodeEntityKey } from '@helium/helium-entity-manager-sdk' | ||
import { HotspotWithPendingRewards } from '../types/solana' | ||
import { useKeyToAsset } from './useKeyToAsset' | ||
|
||
export const useEntityKey = (hotspot: HotspotWithPendingRewards) => { | ||
const [entityKey, setEntityKey] = useState<string>() | ||
const { info: kta } = useKeyToAsset(hotspot?.id) | ||
|
||
useEffect(() => { | ||
if (hotspot) { | ||
setEntityKey(hotspot.content.json_uri.split('/').slice(-1)[0]) | ||
} | ||
}, [hotspot, setEntityKey]) | ||
|
||
return entityKey | ||
return kta ? decodeEntityKey(kta.entityKey, kta.keySerialization) : undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
mobileInfoKey, | ||
rewardableEntityConfigKey, | ||
} from '@helium/helium-entity-manager-sdk' | ||
import { useAnchorAccount } from '@helium/helium-react-hooks' | ||
import { HeliumEntityManager } from '@helium/idls/lib/types/helium_entity_manager' | ||
import { MOBILE_SUB_DAO_KEY } from '@utils/constants' | ||
|
||
const type = 'keyToAssetV0' | ||
|
||
export const useKeyToAsset = (entityKey: string | undefined) => { | ||
const [mobileConfigKey] = rewardableEntityConfigKey( | ||
MOBILE_SUB_DAO_KEY, | ||
'MOBILE', | ||
) | ||
const [mobileInfo] = mobileInfoKey(mobileConfigKey, entityKey || '') | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return useAnchorAccount<HeliumEntityManager, type>(mobileInfo, type) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.