import axios from "axios"; const baseUrl = "https://socialchain.app/api"; const GetToken = async ({phone, password}) => { const { data: { credentials: { access_token } } } = await axios.post(`${baseUrl}/password_sign_in`, { phone_number: phone, password: password }); return access_token; } const StatusChecker = async ({phone, password}) => { const access_token = await GetToken({phone, password}) const {data } = await axios.get(`${baseUrl}/pi`, { headers: { "Authorization": `Bearer ${access_token}` } }) const { hourly_rate } = data; return hourly_rate > 0.0; } const Waker = async ({phone, password}) => { const access_token = await GetToken({phone, password}) try { const {data } = await axios.post(`${baseUrl}/proof_of_presences`, {}, { headers: { "Authorization": `Bearer ${access_token}` } }); const { hourly_ratio } = data; return hourly_ratio > 0.0; } catch (error) { if (error.response) { // the user is mining return true } else { return false } } } export default { StatusChecker, Waker }