on 4c8c607 help sign in
bridge/src/store/lib/useEclipticOwnerStore.js
26 lines 686 B history raw
1import { useCallback, useState } from 'react';
2import * as azimuth from 'azimuth-js';
4import { useNetwork } from 'store/network';
6export default function useEclipticOwnerStore() {
7 const { contracts } = useNetwork();
8 const [eclipticOwner, _setEclipticOwner] = useState(null);
10 const syncEclipticOwner = useCallback(async () => {
11 // owner is generally immutable
12 if (eclipticOwner) {
13 return;
14 }
16 const _contracts = contracts.getOrElse(null);
17 if (!_contracts) {
18 return;
19 }
21 const owner = await azimuth.ecliptic.owner(_contracts);
22 _setEclipticOwner(owner);
23 }, [contracts, eclipticOwner]);
25 return { eclipticOwner, syncEclipticOwner };