1import { useState, useCallback } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import * as azimuth from 'azimuth-js';
5import { useNetwork } from '../network';
6import { useWallet } from 'store/wallet';
8const EMPTY_CONTROLLED_POINTS = {
9 ownedPoints: Nothing(),
10 incomingPoints: Nothing(),
11 managingPoints: Nothing(),
12 votingPoints: Nothing(),
13 spawningPoints: Nothing(),
16export default function useControlledPointsStore() {
17 const { contracts } = useNetwork();
18 const { wallet } = useWallet();
19 const [controlledPointsCache, _setControlledPointsCache] = useState(
20 EMPTY_CONTROLLED_POINTS
23 const getControlledPoints = useCallback(
24 () => controlledPointsCache || EMPTY_CONTROLLED_POINTS,
25 [controlledPointsCache]
28 const syncControlledPoints = useCallback(async () => {
29 const _contracts = contracts.getOrElse(null);
30 const _wallet = wallet.getOrElse(null);
31 if (!_contracts || !_wallet) {
35 const address = _wallet.address;
43 ] = await Promise.all([
44 azimuth.azimuth.getOwnedPoints(_contracts, address),
45 azimuth.azimuth.getTransferringFor(_contracts, address),
46 azimuth.azimuth.getManagerFor(_contracts, address),
47 azimuth.azimuth.getVotingFor(_contracts, address),
48 azimuth.azimuth.getSpawningFor(_contracts, address),
51 _setControlledPointsCache({
52 ownedPoints: Just(ownedPoints),
53 incomingPoints: Just(incomingPoints),
54 managingPoints: Just(managingPoints),
55 votingPoints: Just(votingPoints),
56 spawningPoints: Just(spawningPoints),
58 }, [contracts, wallet, _setControlledPointsCache]);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list