1import { useState, useCallback } from 'react';
2import { Nothing, Just } from 'folktale/maybe';
4import { useNetwork } from 'store/network';
5import { useWallet } from 'store/wallet';
10} from 'lib/starRelease';
12export default function useStarRelease() {
13 const { contracts } = useNetwork();
14 const { wallet } = useWallet();
16 const [starReleaseDetails, _setDetails] = useState(Nothing());
18 const [batchLimits, setBatchLimits] = useState([]);
20 const syncStarReleaseDetails = useCallback(async () => {
21 const _wallet = wallet.getOrElse(null);
22 const _contracts = contracts.getOrElse(null);
23 if (!(_contracts && _wallet)) {
26 _setDetails(Nothing());
28 const address = _wallet.address;
31 const [linear, conditional] = await Promise.all([
32 getLinear(_contracts, address),
33 getConditional(_contracts, address),
36 const keys = Object.keys(linear);
37 const result = keys.reduce(
38 (acc, key) => ({ ...acc, [key]: linear[key] + conditional[key] }),
41 setBatchLimits(conditional.batchLimits);
43 _setDetails(Just(result));
45 _setDetails(Nothing());
48 }, [contracts, wallet]);
50 const withdraw = useCallback(
52 const _wallet = wallet.getOrElse(null);
53 const _contracts = contracts.getOrElse(null);
54 if (!(_contracts && _wallet)) {
57 return generateWithdrawTxs(_contracts, batchLimits, amount, to);
59 [batchLimits, contracts, wallet]
62 return { starReleaseDetails, syncStarReleaseDetails, withdraw };
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