1import { useState, useCallback } from 'react';
2import { Nothing, Just } from 'folktale/maybe';
4import { useNetwork } from 'store/network';
5import { useWallet } from 'store/wallet';
11} from 'lib/starRelease';
13export default function useStarRelease() {
14 const { contracts } = useNetwork();
15 const { wallet } = useWallet();
17 const [starReleaseDetails, _setDetails] = useState(Nothing());
19 const [batchLimits, setBatchLimits] = useState([]);
21 const syncStarReleaseDetails = useCallback(async () => {
22 const _wallet = wallet.getOrElse(null);
23 const _contracts = contracts.getOrElse(null);
24 if (!(_contracts && _wallet)) {
27 _setDetails(Nothing());
29 const address = _wallet.address;
32 const [linear, conditional, kind] = await Promise.all([
33 getLinear(_contracts, address),
34 getConditional(_contracts, address),
35 getLockupKind(_contracts, address),
38 const keys = Object.keys(linear);
39 const result = keys.reduce(
40 (acc, key) => ({ ...acc, [key]: linear[key] + conditional[key] }),
44 result.linear = { approvedTransferTo: linear.approvedTransferTo };
45 result.conditional = {
46 approvedTransferTo: conditional.approvedTransferTo,
48 setBatchLimits(conditional.batchLimits);
50 _setDetails(Just(result));
52 _setDetails(Just(null));
53 console.error('error fetching star release details', e);
55 }, [contracts, wallet]);
57 const withdraw = useCallback(
59 const _wallet = wallet.getOrElse(null);
60 const _contracts = contracts.getOrElse(null);
61 if (!(_contracts && _wallet)) {
64 return generateWithdrawTxs(_contracts, batchLimits, amount, to);
66 [batchLimits, contracts, wallet]
69 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