Skip to content

Commit

Permalink
add validators
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliavas committed Jul 5, 2023
1 parent 26d7e74 commit d6b4356
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 51 deletions.
14 changes: 12 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { useEffect } from 'react';
import {useNavigate} from 'react-router-dom'

function App() {
return (
const navigate = useNavigate();
navigate('/index');

useEffect(() => {
navigate('/index')
})

return (
<div className="App">
hello world
asdf
</div>
);
}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/client/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const commentPost = async (
const result = await signAndExecuteTransactionBlock({
transactionBlock: tx,
});
console.log({ result });

} catch (error) {
console.error(error);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/client/createPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const createPost = async (
files: string,
profileAddr: string
) => {
console.log(text, files, profileAddr);
try{
const tx = new TransactionBlock();
tx.moveCall({
Expand Down
1 change: 0 additions & 1 deletion frontend/src/client/createProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const createProfile = async (
let url = photo_url

const tx = new TransactionBlock();
console.log(PROFILE_REGISTRY_ADDRESS, name, url, SUI_CLOCK_OBJECT_ID)
tx.moveCall({
target: `${CONTRACT_ADDRESS}::meet::create_profile`,
arguments: [
Expand Down
1 change: 0 additions & 1 deletion frontend/src/client/editPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const editPost = async (
const result = await signAndExecuteTransactionBlock({
transactionBlock: tx,
});
console.log({ result });

} catch (error) {
console.error(error);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/client/editProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const editProfile = async (
const result = await signAndExecuteTransactionBlock({
transactionBlock: tx,
});
console.log({ result });

} catch (error) {
console.error(error);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/client/getAllPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export const getAllPosts = async (
cursor: cursor
});

// console.log(objects.data);
// //console.log(objects.data);
let posts = [];
for (let i=0;i<objects.data.length;i++){
console.log(objects.data[i])
//console.log(objects.data[i])
posts.push(objects.data[i].parsedJson.post_id);
}
try {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/client/getFollowers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const getFollowers = async (
id: profileAddr,
options: { showContent: true },
});
console.log(objects);
//console.log(objects);
const FOLLOWERS_REGISTRY_ADDRESS = (objects as any).data.content.fields.followers;
console.log(FOLLOWERS_REGISTRY_ADDRESS);
//console.log(FOLLOWERS_REGISTRY_ADDRESS);

objects = await provider.getObject({
id: FOLLOWERS_REGISTRY_ADDRESS,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/client/getProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { provider } from './config';

export const getProfile = async (profileAddress: string) => {
try {
console.log(profileAddress)
//console.log(profileAddress)
const objects = await provider.getObject({
id: profileAddress,
options: { showContent: true },
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/client/makeDonation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const makeDonate = async (
txb.pure(amount),
]
);
console.log(coin[0])
//console.log(coin[0])


// let objects = await provider.getCoins({
Expand All @@ -40,16 +40,16 @@ export const makeDonate = async (
// await new Promise(r => setTimeout(r, 2000));
// var COIN_ADDR = ''
// for (let i=0;i<objects.data.length;i++){
// console.log((objects as any).data)
// //console.log((objects as any).data)
// if ((objects as any).data[i].balance == amount){
// COIN_ADDR = objects.data[i].coinObjectId;
// console.log(COIN_ADDR)
// //console.log(COIN_ADDR)
// }
// }
// const COIN_ADDRESS = objects.data[0].coinObjectId;

//console.log(postAddr, REGISTRY_ADDRESS()!, COIN_ADDRESS, amount)
console.log(coin)
////console.log(postAddr, REGISTRY_ADDRESS()!, COIN_ADDRESS, amount)
//console.log(coin)
txb.moveCall({
target: `${CONTRACT_ADDRESS}::meet::make_donate`,
arguments: [
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/client/postDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const allPostDetails = async (
for (var j = 0; j < (objects as any).length; ++j) {
var object = (objects as any)[j];
let post_fields = (object as any).data.content.fields;
console.log(post_fields)
//console.log(post_fields)
var comms = [] as any
try {
comms = await provider.multiGetObjects({
Expand All @@ -39,7 +39,7 @@ export const allPostDetails = async (
const file_link = message.files;
const text = message.text;
const timestamp = message.timestamp;
console.log(message, "msg!!")
//console.log(message, "msg!!")
res.push(
{
...message,
Expand All @@ -56,7 +56,7 @@ export const allPostDetails = async (
}
return res
} catch (e) {
console.log(e)
//console.log(e)
}
}

Expand All @@ -68,7 +68,7 @@ export const postDetail = async (postAddr: string) => {
options: { showContent: true },
}
);
console.log(objects);
//console.log(objects);

let post_fields = (objects as any).data.content.fields;

Expand All @@ -84,7 +84,7 @@ export const postDetail = async (postAddr: string) => {

let likes_amount = post_fields.likes.fields.contents.length;
var donated = (parseInt(post_fields.donated) / (10 ** 9)).toFixed(1);
console.log((parseInt(post_fields.donated) / (10 ** 9)).toFixed(1), "contents")
//console.log((parseInt(post_fields.donated) / (10 ** 9)).toFixed(1), "contents")
var liked = post_fields.likes.fields.contents.includes(PROFILE_ADDR())
objects = await provider.getObject({
id: post_fields.message,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/client/unlike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const unlikePost = async (
const result = await signAndExecuteTransactionBlock({
transactionBlock: tx,
});
console.log({ result });
//console.log({ result });

} catch (error) {
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/client/uploadFIle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export const uploadFile = async (file: File) => {

var cid = await storage.put([file]);
var link = `https://${cid}.ipfs.w3s.link/${file.name.replaceAll(' ', '%20')}`
console.log(link);
//console.log(link);
return link
}
14 changes: 11 additions & 3 deletions frontend/src/pages/desktop/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PostHeader } from '../../elements/postHeader';
import { Post, imgCondition } from '../../elements/post';
import { Image } from '../../elements/icons/image';
import { File } from '../../elements/icons/file';
import { useParams } from 'react-router-dom';
import { useNavigate, useParams } from 'react-router-dom';
import { ExtendedProfile } from '../../elements/extendedProfile';
import { getFollowings } from '../../../client/getFollowings';
import { useWalletKit } from '@mysten/wallet-kit';
Expand Down Expand Up @@ -83,7 +83,7 @@ export const PostCreation: react.FC<IPostCreation> = (props) => {
var startImages: string[] = [];
var startFiles: string[] = [];

console.log(props.postId, posts)
//console.log(props.postId, posts)
if (props.postId) {
post = posts.filter(e => e.messageAddr == props.postId)[0];
startImages = post.file.split(';').filter(imgCondition);
Expand Down Expand Up @@ -312,7 +312,7 @@ export const ProfileView: react.FC = () => {
)
}

console.log(posts);
//console.log(posts);

return <>
<div className="post-header__container">
Expand Down Expand Up @@ -528,6 +528,14 @@ export const Main: react.FC = () => {
'subs': <Subs />
}
const {action} = useParams();
const navigate = useNavigate();

if (!localStorage.getItem('profileAddr')) {
setTimeout(() => {
navigate('/sign-up')
}, 200)

}

return <div className='main__container'>
<div className="right-sidebar__media">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/desktop/profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const Profile: react.FC = () => {

var followingsEnabled = !(PROFILE_ADDR() == addr);

console.log(followingsEnabled, addr)
//console.log(followingsEnabled, addr)

var localAction = action ? action : 'posts';

Expand Down
37 changes: 33 additions & 4 deletions frontend/src/pages/desktop/signUp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IDataShortProfile, getSuggestedProfiles } from '../../../service/getSug
import { follow } from '../../../client/follow';
import { unfollow } from '../../../client/unfollow';
import { Puff } from 'react-loader-spinner';
import {Avatar} from 'antd';
import {Avatar, message} from 'antd';


interface ISteps{
Expand Down Expand Up @@ -63,6 +63,7 @@ interface IShortProfileAdd extends IDataShortProfile{
const ShortProfileAdd: react.FC<IShortProfileAdd> = (props) => {
const {signAndExecuteTransactionBlock} = useWalletKit();
const [active, setActive] = react.useState(props.active);

const activeClass = active ? 'active' : ''
return <div className='short-profile_btn__container'>
<ShortProfile
Expand Down Expand Up @@ -95,6 +96,8 @@ export const SignUp: react.FC = () => {
const [name, setName] = react.useState('');
const [image, setImage] = react.useState('');
const [imageLoaded, setImageIsLoaded] = react.useState(false);
const [messageApi, contextHolder] = message.useMessage();


const queried = react.useRef(false);
const [suggestedPeople, setSuggestedPeople] = react.useState<IDataShortProfile[]>([]);
Expand All @@ -119,7 +122,13 @@ export const SignUp: react.FC = () => {
content={"Sign up"}
className=''
onClick={() => {
setCurrentStep(1);
if (name.length) setCurrentStep(1);
else {
messageApi.open({
content: 'Please enter name',
type: 'error'
})
}
}}
/>,
<div className="or__block">
Expand Down Expand Up @@ -149,7 +158,10 @@ export const SignUp: react.FC = () => {
content={'Continute'}
className='cont-btn'
onClick={() => {
setCurrentStep(2);
if (currentAccount?.address) setCurrentStep(2);
else {
messageApi.error('Please connect your wallet')
}
}}
/>
]}
Expand Down Expand Up @@ -198,6 +210,10 @@ export const SignUp: react.FC = () => {
content={"Next"}
className='login_btn'
onClick={() => {
if (!image.length) {
messageApi.error('Please upload avatar')
return;
}
createProfile(
signAndExecuteTransactionBlock,
name,
Expand Down Expand Up @@ -234,6 +250,7 @@ export const SignUp: react.FC = () => {
]

return <div className='sign-up__container'>
{contextHolder}
<div className='decoration'>
<Decoration />
</div>
Expand All @@ -250,7 +267,9 @@ export const SignUp: react.FC = () => {
export const Login: react.FC = () => {
const navigate = useNavigate();
const {currentAccount} = useWalletKit();
const [messageApi, contextHolder] = message.useMessage();
return <div className='sign-up__container'>
{contextHolder}
<div className='decoration'>
<Decoration />
</div>
Expand All @@ -268,7 +287,17 @@ export const Login: react.FC = () => {
content={'Login'}
className='cont-btn'
onClick={async () => {
await getProfileAddr(currentAccount?.address!)
if (!currentAccount?.address) {
messageApi.error("Please connect your wallet")
return;
}
try{
await getProfileAddr(currentAccount?.address!)
} catch {
messageApi.error("Wallet doesn't has profile object. Please Sign up first")
return;
}

navigate('/index');
}}
/>,
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createBrowserRouter } from "react-router-dom";
import { createBrowserRouter, } from "react-router-dom";
import { Main, ProfileView } from "./pages/desktop/main";
import { Login, SignUp } from "./pages/desktop/signUp";
import { Profile } from "./pages/desktop/profile/profile";
import App from './App'


const router = createBrowserRouter([
Expand All @@ -28,6 +29,10 @@ const router = createBrowserRouter([
{
'path': '/profile/:action',
'element': <Main />
},
{
'path': '',
'element': <App />
}
])

Expand Down
Loading

0 comments on commit d6b4356

Please sign in to comment.