1import { useState, useCallback } from 'react';
2import Maybe from 'folktale/maybe';
3import * as azimuth from 'azimuth-js';
5import { useNetwork } from '../network';
6import { useWallet } from 'store/wallet';
8const kEmptyControlledPoints = {
9 ownedPoints: Maybe.Nothing(),
10 incomingPoints: Maybe.Nothing(),
11 managingPoints: Maybe.Nothing(),
12 votingPoints: Maybe.Nothing(),
13 spawningPoints: Maybe.Nothing(),
16export default function useControlledPointsStore() {
17 const { contracts } = useNetwork();
18 const { wallet } = useWallet();
19 const [controlledPointsCache, _setControlledPointsCache] = useState(
20 kEmptyControlledPoints
23 const getControlledPoints = useCallback(
24 () => controlledPointsCache || kEmptyControlledPoints,
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;
37 const ownedPoints = await azimuth.azimuth.getOwnedPoints(
41 const incomingPoints = await azimuth.azimuth.getTransferringFor(
45 const managingPoints = await azimuth.azimuth.getManagerFor(
49 const votingPoints = await azimuth.azimuth.getVotingFor(
53 const spawningPoints = await azimuth.azimuth.getSpawningFor(
58 _setControlledPointsCache({
59 ownedPoints: Maybe.Just(ownedPoints),
60 incomingPoints: Maybe.Just(incomingPoints),
61 managingPoints: Maybe.Just(managingPoints),
62 votingPoints: Maybe.Just(votingPoints),
63 spawningPoints: Maybe.Just(spawningPoints),
65 }, [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