-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4da520c
commit 83bd571
Showing
31 changed files
with
952 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,57 @@ | ||
'use client'; | ||
import { AddAgentForm } from '@/components/AddAgentForm/AddAgentForm'; | ||
import { InitTokenForm } from '@/components/InitTokenForm/InitTokenForm'; | ||
import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs'; | ||
import { MonoAdd } from '@kadena/kode-icons'; | ||
import { Button } from '@kadena/kode-ui'; | ||
import { SideBarBreadcrumbsItem, useLayout } from '@kadena/kode-ui/patterns'; | ||
import { useState } from 'react'; | ||
|
||
const Home = () => { | ||
return <div>Hello world</div>; | ||
const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); | ||
const [hasOpenInitForm, setHasOpenInitForm] = useState(false); | ||
const [hasOpenAgentForm, setHasOpenAgentForm] = useState(false); | ||
|
||
const handleAddAgent = () => { | ||
setIsRightAsideExpanded(true); | ||
setHasOpenAgentForm(true); | ||
}; | ||
|
||
const handleInitToken = () => { | ||
setIsRightAsideExpanded(true); | ||
setHasOpenInitForm(true); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<SideBarBreadcrumbs> | ||
<SideBarBreadcrumbsItem href="/">Tokens</SideBarBreadcrumbsItem> | ||
</SideBarBreadcrumbs> | ||
{isRightAsideExpanded && hasOpenAgentForm && ( | ||
<AddAgentForm | ||
onClose={() => { | ||
setIsRightAsideExpanded(false); | ||
setHasOpenAgentForm(false); | ||
}} | ||
/> | ||
)} | ||
{isRightAsideExpanded && hasOpenInitForm && ( | ||
<InitTokenForm | ||
onClose={() => { | ||
setIsRightAsideExpanded(false); | ||
setHasOpenInitForm(false); | ||
}} | ||
/> | ||
)} | ||
<Button startVisual={<MonoAdd />} onClick={handleAddAgent}> | ||
Add Agent | ||
</Button> | ||
|
||
<Button startVisual={<MonoAdd />} onClick={handleInitToken}> | ||
Init Token | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/apps/rwa-demo/src/components/AddAgentForm/AddAgentForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useAccount } from '@/hooks/account'; | ||
import { useNetwork } from '@/hooks/networks'; | ||
import type { IAddAgentProps } from '@/services/addAgent'; | ||
import { addAgent } from '@/services/addAgent'; | ||
import { Button, TextField } from '@kadena/kode-ui'; | ||
import { | ||
RightAside, | ||
RightAsideContent, | ||
RightAsideFooter, | ||
RightAsideHeader, | ||
} from '@kadena/kode-ui/patterns'; | ||
import type { FC } from 'react'; | ||
import { useState } from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
|
||
interface IProps { | ||
onClose: () => void; | ||
} | ||
|
||
export const AddAgentForm: FC<IProps> = ({ onClose }) => { | ||
const { activeNetwork } = useNetwork(); | ||
const { account } = useAccount(); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [_, setError] = useState<string | null>(null); | ||
const { register, handleSubmit } = useForm<IAddAgentProps>({ | ||
defaultValues: { | ||
agent: '', | ||
}, | ||
}); | ||
|
||
const onSubmit = async (data: IAddAgentProps) => { | ||
console.log({ data }); | ||
setError(null); | ||
try { | ||
await addAgent(data, activeNetwork, account!); | ||
|
||
// setIsRightAsideExpanded(false); | ||
} catch (e: any) { | ||
setError(e?.message || e); | ||
} | ||
|
||
// onClose(); | ||
}; | ||
|
||
return ( | ||
<RightAside isOpen onClose={onClose}> | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<RightAsideHeader label="Add Agent" /> | ||
<RightAsideContent> | ||
<TextField | ||
label="Agent Account" | ||
{...register('agent', { required: true })} | ||
/> | ||
</RightAsideContent> | ||
<RightAsideFooter> | ||
<Button onPress={onClose} variant="transparent"> | ||
Cancel | ||
</Button> | ||
<Button type="submit">Add Agent</Button> | ||
</RightAsideFooter> | ||
</form> | ||
</RightAside> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
packages/apps/rwa-demo/src/components/AssetProvider/AssetProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use client'; | ||
import type { FC, PropsWithChildren } from 'react'; | ||
import { createContext, useState } from 'react'; | ||
|
||
interface IAsset { | ||
name: string; | ||
} | ||
|
||
export interface IAssetContext { | ||
asset?: IAsset; | ||
} | ||
|
||
export const AssetContext = createContext<IAssetContext>({}); | ||
|
||
export const AssetProvider: FC<PropsWithChildren> = ({ children }) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [asset, setAsset] = useState<IAsset>(); | ||
|
||
return ( | ||
<AssetContext.Provider value={{ asset }}>{children}</AssetContext.Provider> | ||
); | ||
}; |
68 changes: 68 additions & 0 deletions
68
packages/apps/rwa-demo/src/components/InitTokenForm/InitTokenForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { useAccount } from '@/hooks/account'; | ||
import { useNetwork } from '@/hooks/networks'; | ||
import type { IInitTokenProps } from '@/services/initToken'; | ||
import { initToken } from '@/services/initToken'; | ||
import { Button, TextField } from '@kadena/kode-ui'; | ||
import { | ||
RightAside, | ||
RightAsideContent, | ||
RightAsideFooter, | ||
RightAsideHeader, | ||
} from '@kadena/kode-ui/patterns'; | ||
import type { FC } from 'react'; | ||
import { useState } from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
|
||
interface IProps { | ||
onClose: () => void; | ||
} | ||
|
||
export const InitTokenForm: FC<IProps> = ({ onClose }) => { | ||
const { activeNetwork } = useNetwork(); | ||
const { account } = useAccount(); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [error, setError] = useState<string | null>(null); | ||
const { register, handleSubmit } = useForm<IInitTokenProps>({ | ||
defaultValues: { | ||
name: '', | ||
}, | ||
}); | ||
|
||
const onSubmit = async (data: IInitTokenProps) => { | ||
console.log({ data }); | ||
setError(null); | ||
//try { | ||
await initToken(data, activeNetwork, account!); | ||
|
||
//onClose(); | ||
// setIsRightAsideExpanded(false); | ||
// } catch (e: any) { | ||
// setError(e?.message || e); | ||
// } | ||
}; | ||
|
||
return ( | ||
<RightAside isOpen onClose={onClose}> | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<RightAsideHeader label="Init Asset" /> | ||
<RightAsideContent> | ||
<TextField label="Name" {...register('name', { required: true })} /> | ||
<TextField | ||
label="Symbol" | ||
{...register('symbol', { required: true })} | ||
/> | ||
<TextField | ||
label="KadenaId" | ||
{...register('kadenaId', { required: true })} | ||
/> | ||
</RightAsideContent> | ||
<RightAsideFooter> | ||
<Button onPress={onClose} variant="transparent"> | ||
Cancel | ||
</Button> | ||
<Button type="submit">Create Security</Button> | ||
</RightAsideFooter> | ||
</form> | ||
</RightAside> | ||
); | ||
}; |
Oops, something went wrong.