-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obscuroscan#2323 #1640
Merged
Merged
Obscuroscan#2323 #1640
Changes from 60 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
f4ee8d6
light theme and other changes
BedrockSquirrel 3ba73a7
feat: initial react commit 🎉
Jennievon 30082c4
feat: install shadcn-ui
Jennievon dafb770
wip: setup dashboard components
Jennievon a304cfe
wip: dashboard
Jennievon 8cc3019
wip: personal pages
Jennievon 2bbbef3
chore: move Obscuroscan v3 to a new folder
Jennievon b0781fa
feat: hooks and API for data fetching
Jennievon 4842780
feat: dashboard analytics
Jennievon b38d970
wip: blockchain data tables
Jennievon 59e6dfd
chore: move blockchain pages to folder
Jennievon 58a6647
fix: build error
Jennievon a25eba6
refactor: blockchain module
Jennievon a1e570e
feat: add Obscuro favicon
Jennievon 25a9cd7
wip: blocks pages
Jennievon f78baa9
wip: blocks data table
Jennievon 4f8b3b8
feat: blocks data table
Jennievon b9b9cc0
feat: batches data table
Jennievon ab11385
feat: wallet provider
Jennievon 1a2ef6a
feat: personal transactions
Jennievon a219289
refactor: dashboard analytics
Jennievon fb5e67c
refactor: folder structure
Jennievon b4fd162
refactor: dashboard analytics view
Jennievon 86bb8e0
feat: view for batch by hash
Jennievon a346f77
Merge branch 'main' of https://github.com/obscuronet/go-obscuro into …
Jennievon 173cbc1
chore: refetch interval for stale data
Jennievon ba57f4f
wip: resources
Jennievon 3039530
update alert component
Jennievon 4f01b09
fix: batch view
Jennievon c6ec9a2
refactor: personal transactions and data table
Jennievon 76d8ec2
revert v2 changes
Jennievon 9d60fd4
revert backend server changes
Jennievon 66bb69e
feat:
Jennievon f654b72
refactor: main nav
Jennievon 60fca42
feat:
Jennievon 05f867c
chore: use tree structure for main nav
Jennievon 96055f7
move components to src folder
Jennievon 9f17cc0
update tailwind config
Jennievon 0508423
fix: build error
Jennievon 9c2e607
refactor: naming conventions
Jennievon d878db0
style modifications
Jennievon f335443
Merge branch 'main' of https://github.com/obscuronet/go-obscuro into …
Jennievon 872f9e7
update favicon
Jennievon 62dd05c
feat: mobile responsiveness
Jennievon 33b26d6
Merge branch 'main' of https://github.com/obscuronet/go-obscuro into …
Jennievon e8ceb8a
Merge branch 'main' of https://github.com/obscuronet/go-obscuro into …
Jennievon 5a9ec03
Merge branch 'jennifer/new-scan-config-setup' of https://github.com/o…
Jennievon 45b1536
Merge pull request #1646 from ten-protocol/jennifer/scan-updates
Jennievon 60e4952
add `services` folder
Jennievon 834576b
wip: update font to `Cloud Soft`
Jennievon 7be5e96
add README to Tenscan
Jennievon 8b171ed
update Tenscan README
Jennievon d98ba61
feat: add a copy component
Jennievon 1354cfc
style: update custom font, logo
Jennievon f4b8cc6
chore: rm unused code
Jennievon 3bbf793
Merge branch 'main' of https://github.com/obscuronet/go-obscuro into …
Jennievon 963e70b
wip: deployment workflow
Jennievon 5ebb300
update API routes to use env variables
Jennievon ef418f2
feat: update workflow and dockerfile
Jennievon 2c56a25
chore: replace Obscuro with Ten
Jennievon 507e17a
update `dns-name-label` and instance `name`
Jennievon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Deploys Ten Scan on Azure for Testnet | ||
# Builds the Ten Scan image, pushes the image to dockerhub and starts the Ten Scan on Azure | ||
|
||
name: "[M] Deploy Ten Scan 3 Testnet" | ||
run-name: "[M] Deploy Ten Scan Testnet ( ${{ github.event.inputs.testnet_type }} )" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
testnet_type: | ||
description: "Testnet Type" | ||
required: true | ||
default: "dev-testnet" | ||
type: choice | ||
options: | ||
- "dev-testnet" | ||
- "uat-testnet" | ||
- "sepolia-testnet" | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ github.event.inputs.testnet_type }} | ||
steps: | ||
- name: "Print GitHub variables" | ||
# This is a useful record of what the environment variables were at the time the job ran, for debugging and reference | ||
run: | | ||
echo "GitHub Variables = ${{ toJSON(vars) }}" | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: "Set up Docker" | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: "Login to Azure docker registry" | ||
uses: azure/docker-login@v1 | ||
with: | ||
login-server: testnetobscuronet.azurecr.io | ||
username: testnetobscuronet | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
- name: "Login via Azure CLI" | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Build and Push Docker FE Image | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }} -f ./tools/obscuroscan_v3/frontend/Dockerfile . | ||
docker push ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }} | ||
|
||
- name: Build and Push Docker API Image | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_API }} -f ./tools/obscuroscan_v2/backend/Dockerfile . | ||
docker push ${{ vars.DOCKER_BUILD_TAG_SCAN_API }} | ||
|
||
- name: "Deploy FE to Azure Container Instances" | ||
uses: "azure/aci-deploy@v1" | ||
with: | ||
resource-group: ${{ secrets.RESOURCE_GROUP }} | ||
dns-name-label: ${{ github.event.inputs.testnet_type }}-obscuro-scan | ||
image: ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }} | ||
name: ${{ github.event.inputs.testnet_type }}-fe-obscuro-scan | ||
Jennievon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
location: "uksouth" | ||
restart-policy: "Never" | ||
environment-variables: NEXT_PUBLIC_API_HOST=https://${{ github.event.inputs.testnet_type }}-api.obscuroscan.io NEXT_PUBLIC_FE_VERSION=${{ GITHUB.RUN_NUMBER }}-${{ GITHUB.SHA }} | ||
command-line: npm run start | ||
ports: "80" | ||
cpu: 2 | ||
memory: 2 | ||
|
||
- name: "Deploy API to Azure Container Instances" | ||
uses: "azure/aci-deploy@v1" | ||
with: | ||
resource-group: ${{ secrets.RESOURCE_GROUP }} | ||
dns-name-label: ${{ github.event.inputs.testnet_type }}-api-obscuro-scan | ||
image: ${{ vars.DOCKER_BUILD_TAG_SCAN_API }} | ||
name: ${{ github.event.inputs.testnet_type }}-api-obscuro-scan | ||
location: "uksouth" | ||
restart-policy: "Never" | ||
command-line: ./cmd/backend --nodeHostAddress http://${{ vars.L2_RPC_URL_VALIDATOR }}:80 --serverAddress 0.0.0.0:80 | ||
ports: "80" | ||
cpu: 2 | ||
memory: 2 |
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,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
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,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
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,9 @@ | ||
FROM node:18-buster as runner | ||
# setup container data structure | ||
RUN mkdir -p /home/obscuro/go-obscuro/tools/obscuroscan_v3/ | ||
COPY ./tools/obscuroscan_v3/frontend /home/obscuro/go-obscuro/tools/obscuroscan_v3/frontend | ||
|
||
WORKDIR /home/obscuro/go-obscuro/tools/obscuroscan_v3/frontend | ||
RUN npm install && npm install http-server -g | ||
Jennievon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
EXPOSE 80 |
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,62 @@ | ||
# Tenscan: Blockchain Explorer for The Encryption Network (TEN) | ||
|
||
Tenscan is a Next.js and Tailwind CSS-powered application that serves as a Blockchain Explorer for The Encryption Network (TEN). This explorer allows users to interact with and explore the blocks, transactions, batches, resources, and personal data on the TEN blockchain. Tenscan is built using the Shadcn-UI Component Library for a consistent and visually appealing user interface. | ||
|
||
## Folder Structure | ||
|
||
``` | ||
📁 Tenscan | ||
├── 📁 api - Contains server-side code, such as API routes or server logic | ||
├── 📁 pages - Typically used for Next.js pages. Each .tsx or .js file in this directory becomes a route in your application | ||
├── 📁 public - This directory is used to serve static assets. Files inside this directory can be referenced in your code with a URL path | ||
├── 📁 src - Main source code directory for this project | ||
│ ├── 📁 components - Contains reusable React components used throughout the application | ||
│ ├── 📁 hooks - Custom React hooks that can be shared and reused across components | ||
│ ├── 📁 lib - Utility functions or modules that provide common functionalities across the application | ||
│ ├── 📁 routes - Route-related logic or configuration can be placed in this directory | ||
│ ├── 📁 services - Used for services that interact with external APIs or handle other data-related tasks | ||
│ └── 📁 types - Type definitions (.d.ts files or TypeScript files) for TypeScript, describing the shape of data and objects used in the application | ||
└── 📁 styles - Global styles, stylesheets, or styling-related configurations for this project | ||
``` | ||
|
||
## Getting Started | ||
|
||
1. **Clone the Repository:** | ||
```bash | ||
git clone https://github.com/ten-protocol/go-ten.git | ||
cd go-ten/tools/obscuroscan_v3/frontend | ||
``` | ||
|
||
2. **Install Dependencies:** | ||
```bash | ||
npm install | ||
``` | ||
|
||
3. **Run the Development Server:** | ||
```bash | ||
npm run dev | ||
``` | ||
|
||
The application will be accessible at [http://localhost:3000](http://localhost:3000). | ||
|
||
## Usage | ||
|
||
- Visit the different sections of the explorer through the navigation links in the UI. | ||
- Explore the different blocks, transactions, batches, resources, and personal data on the TEN. | ||
- View the details of each batch by their hash. | ||
|
||
## Built With | ||
|
||
- [Next.js](https://nextjs.org/) | ||
- [Tailwind CSS](https://tailwindcss.com/) | ||
- [Shadcn-UI](https://shadcn.com/) | ||
- [TypeScript](https://www.typescriptlang.org/) | ||
|
||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please follow our [contribution guidelines](/docs/_docs/community/contributions.md). | ||
|
||
## License | ||
|
||
This project is licensed under the [GNU Affero General Public License v3.0](/LICENSE). |
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,38 @@ | ||
import { httpRequest } from "."; | ||
Jennievon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { apiRoutes } from "@/src/routes"; | ||
import { pathToUrl } from "@/src/routes/router"; | ||
import { ResponseDataInterface } from "@/src/types/interfaces"; | ||
import { | ||
Batch, | ||
BatchDetails, | ||
BatchResponse, | ||
} from "@/src/types/interfaces/BatchInterfaces"; | ||
|
||
export const fetchBatches = async ( | ||
payload?: Record<string, any> | ||
): Promise<ResponseDataInterface<BatchResponse>> => { | ||
return await httpRequest<ResponseDataInterface<BatchResponse>>({ | ||
method: "get", | ||
url: pathToUrl(apiRoutes.getBatches), | ||
searchParams: payload, | ||
}); | ||
}; | ||
|
||
export const fetchLatestBatch = async ( | ||
payload?: Record<string, any> | ||
): Promise<ResponseDataInterface<Batch>> => { | ||
return await httpRequest<ResponseDataInterface<Batch>>({ | ||
method: "get", | ||
url: pathToUrl(apiRoutes.getLatestBatch), | ||
searchParams: payload, | ||
}); | ||
}; | ||
|
||
export const fetchBatchByHash = async ( | ||
hash: string | ||
): Promise<ResponseDataInterface<BatchDetails>> => { | ||
return await httpRequest<ResponseDataInterface<BatchDetails>>({ | ||
method: "get", | ||
url: pathToUrl(apiRoutes.getBatchByHash, { hash }), | ||
}); | ||
}; |
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,14 @@ | ||
import { httpRequest } from "."; | ||
import { apiRoutes } from "@/src/routes"; | ||
import { pathToUrl } from "@/src/routes/router"; | ||
import { ResponseDataInterface } from "@/src/types/interfaces"; | ||
|
||
export const fetchBlocks = async ( | ||
payload?: Record<string, any> | ||
): Promise<ResponseDataInterface<any>> => { | ||
return await httpRequest<ResponseDataInterface<any>>({ | ||
method: "get", | ||
url: pathToUrl(apiRoutes.getBlocks), | ||
searchParams: payload, | ||
}); | ||
}; |
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,25 @@ | ||
import { httpRequest } from "."; | ||
import { apiRoutes } from "@/src/routes"; | ||
import { pathToUrl } from "@/src/routes/router"; | ||
import { ResponseDataInterface } from "@/src/types/interfaces"; | ||
import { ContractCount } from "@/src/types/interfaces/ContractInterface"; | ||
|
||
export const fetchContractCount = async ( | ||
payload?: Record<string, any> | ||
): Promise<ContractCount> => { | ||
return await httpRequest<ContractCount>({ | ||
method: "get", | ||
url: pathToUrl(apiRoutes.getContractCount), | ||
searchParams: payload, | ||
}); | ||
}; | ||
|
||
export const fetchVerifiedContracts = async ( | ||
payload?: Record<string, any> | ||
): Promise<ResponseDataInterface<any>> => { | ||
return await httpRequest<ResponseDataInterface<any>>({ | ||
method: "get", | ||
url: pathToUrl(apiRoutes.getVerifiedContracts), | ||
searchParams: payload, | ||
}); | ||
}; |
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,90 @@ | ||
import { apiHost } from "@/src/lib/constants"; | ||
import axios, { AxiosInstance, AxiosRequestConfig } from "axios"; | ||
|
||
type HttpMethod = "get" | "post" | "put" | "patch" | "delete"; | ||
|
||
interface HttpOptions { | ||
method?: HttpMethod; | ||
url: string; | ||
data?: Record<string, any>; | ||
params?: Record<string, any>; | ||
headers?: Record<string, any>; | ||
timeout?: number; | ||
responseType?: | ||
| "json" | ||
| "arraybuffer" | ||
| "blob" | ||
| "document" | ||
| "text" | ||
| undefined; | ||
download?: boolean; | ||
searchParams?: Record<string, any>; | ||
} | ||
|
||
const baseConfig: AxiosRequestConfig = { | ||
baseURL: apiHost, | ||
timeout: 10000, | ||
}; | ||
|
||
const https: AxiosInstance = axios.create(baseConfig); | ||
|
||
export const httpRequest = async <ResponseData>( | ||
options: HttpOptions, | ||
config: AxiosRequestConfig = {} | ||
): Promise<ResponseData> => { | ||
const { | ||
method = "get", | ||
url, | ||
data, | ||
params, | ||
headers, | ||
timeout, | ||
responseType, | ||
searchParams, | ||
} = options; | ||
let query = ""; | ||
if (searchParams) { | ||
const filteredParams = Object.fromEntries( | ||
Object.entries(searchParams).filter( | ||
([, value]) => value !== undefined && value !== null && value !== "" | ||
) | ||
); | ||
if (Object.keys(filteredParams).length) { | ||
query = new URLSearchParams(filteredParams).toString(); | ||
} | ||
} | ||
|
||
const httpConfig: AxiosRequestConfig = { | ||
method, | ||
url: query ? `${url}?${query}` : url, | ||
data, | ||
params, | ||
headers: { ...(headers || {}) }, | ||
timeout, | ||
responseType: responseType, | ||
...config, | ||
}; | ||
try { | ||
const response = await https(httpConfig); | ||
return response.data as ResponseData; | ||
} catch (error) { | ||
handleHttpError(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
// Centralized error handling function | ||
const handleHttpError = (error: any) => { | ||
// if the error is a server error (status code 5xx) before handling | ||
if (isAxiosError(error) && error.response && error.response.status >= 500) { | ||
console.error("Server error:", error); | ||
} else { | ||
// other errors | ||
console.error("An error occurred:", error); | ||
} | ||
}; | ||
|
||
// Type guard to check if the error is an AxiosError | ||
const isAxiosError = (error: any): error is import("axios").AxiosError => { | ||
return error.isAxiosError === true; | ||
}; |
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,26 @@ | ||
import { httpRequest } from "."; | ||
import { apiRoutes } from "@/src/routes"; | ||
import { pathToUrl } from "@/src/routes/router"; | ||
import { ResponseDataInterface } from "@/src/types/interfaces"; | ||
|
||
export const fetchRollups = async ( | ||
payload?: Record<string, any> | ||
): Promise<ResponseDataInterface<any>> => { | ||
return await httpRequest<ResponseDataInterface<any>>({ | ||
method: "get", | ||
url: pathToUrl(apiRoutes.getRollups), | ||
searchParams: payload, | ||
}); | ||
}; | ||
|
||
export const decryptEncryptedRollup = async ({ | ||
StrData, | ||
}: { | ||
StrData: string; | ||
}): Promise<ResponseDataInterface<any>> => { | ||
return await httpRequest<ResponseDataInterface<any>>({ | ||
method: "post", | ||
url: pathToUrl(apiRoutes.decryptEncryptedRollup), | ||
data: { StrData }, | ||
}); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this dns so it doesnt collide with the existing one