Skip to content

Commit

Permalink
cartesify nestjs WIP finishing touches
Browse files Browse the repository at this point in the history
  • Loading branch information
gconnect committed Jun 6, 2024
1 parent a8372d8 commit 564fde6
Show file tree
Hide file tree
Showing 265 changed files with 67,855 additions and 5,525 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
npm-debug.log
.
.DS_Store
.mypy_cache
.mypy_cache
.vscode
Binary file modified apps/cartesify/frontend/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions apps/cartesify/frontend/next-app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_WALLECT_CONNECT_PROJECT_ID = 61aeba5659fdc68cec3a40d7359401de
1 change: 1 addition & 0 deletions apps/cartesify/frontend/next-app/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_WALLECT_CONNECT_PROJECT_ID = YOUR_PROJECT_ID
5 changes: 4 additions & 1 deletion apps/cartesify/frontend/next-app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "next/core-web-vitals"
"extends": "next/core-web-vitals",
"rules": {
"react/display-name": "off"
}
}
1 change: 1 addition & 0 deletions apps/cartesify/frontend/next-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
app/cartesi/generated
42 changes: 42 additions & 0 deletions apps/cartesify/frontend/next-app/app/cartesi/Balance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from "react";
import { ethers } from "ethers";
import {
Table,
Thead,
Tbody,
Tr,
Th,
Td,
TableContainer,
Button,
Stack,
Box,
} from '@chakra-ui/react'

export const Balance: React.FC = () => {

return (
<Box borderWidth='0.1px' padding='4' borderRadius='lg' overflow='hidden'>
<TableContainer>
<Stack>
<Table variant='striped' size="lg">
<Thead>
<Tr>
<Th textAlign={'center'} textColor={'slategray'}>Ether</Th>
<Th textAlign={'center'} textColor={'slategray'}>ERC-20</Th>
<Th textAlign={'center'} textColor={'slategray'}>ERC-721</Th>
<Th textAlign={'center'} textColor={'slategray'}>ERC-1155</Th>
</Tr>
</Thead>
<Tbody>
<Tr>
<Td colSpan={4} textAlign={'center'} fontSize='14' color='grey' >looks like your cartesi dapp balance is zero! 🙁</Td>
</Tr>
</Tbody>
</Table>
<Button backgroundColor={"#9395D3"}>Get Balance</Button>
</Stack>
</TableContainer>
</Box>
);
};
23 changes: 23 additions & 0 deletions apps/cartesify/frontend/next-app/app/cartesi/Epoch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use client'
import { Button } from "@chakra-ui/react";

import { sendRPCCommand } from "./services/RestApiCalls";
import { useState } from "react";

export function Epoch() {
const [loading, setLoading] = useState(false)
return (
<div className="text-center text-slate-400">
<h2 className="mt-8 text-2xl mb-4">Epoch</h2>
<p>Advance the epoch by running this command on terminal:</p>
<pre>ETH_RPC_URL=http://localhost:8545 cast rpc evm_increaseTime 5184000</pre>
<p>Or click </p>
<Button className=" p-2 text-black rounded m-2" onClick={ async () => {
setLoading(true)
await sendRPCCommand('evm_increaseTime', [5184000]);
setLoading(true)
}}>{loading ? "loading please wait..." : "Increase Time"}</Button>

</div>
)
}
34 changes: 34 additions & 0 deletions apps/cartesify/frontend/next-app/app/cartesi/RestExample.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client'
import { useState } from "react"
import { Button } from "@chakra-ui/react"
import { useEthersSigner } from "../utils/useEtherSigner"
import { createOrUpdateRequest, getRequest } from "./services/RestApiCalls"

export function RestExample() {
const [backendResponse, setResponse] = useState('')
const signer = useEthersSigner()

return (
<div className="flex justify-center text-white">
<div>
<Button colorScheme="blue" className="p-2 rounded m-2" onClick={async () => {
await getRequest(setResponse, "health")
}}>GET</Button>
<Button colorScheme="green" className=" p-2 rounded m-2" onClick={async () => {
await createOrUpdateRequest(signer, "greeting", "POST", JSON.stringify({ any: 'body' }),)
}}>POST</Button>
<Button colorScheme="orange" className=" p-2 rounded m-2" onClick={async () => {
await createOrUpdateRequest(signer, "greeting", "PUT", JSON.stringify({ any: 'body' }))
}}>PUT</Button>
<Button colorScheme="red" className=" p-2 rounded m-2" onClick={async () => {
await createOrUpdateRequest(signer, "delete?some=body", "DELETE")
}}>DELETE</Button>

<div className="text-lg my-4 text-slate-400">
Backend response: <pre>{backendResponse}</pre>
</div>
</div>

</div>
)
}
Loading

0 comments on commit 564fde6

Please sign in to comment.