Skip to content

Commit

Permalink
Merge pull request #1 from notrustverify/example/exchange
Browse files Browse the repository at this point in the history
Example/exchange
  • Loading branch information
sven-hash authored Oct 21, 2023
2 parents 290c567 + d773a39 commit 146a7be
Show file tree
Hide file tree
Showing 23 changed files with 160 additions and 93 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: GitHub Pages

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "16"
cache: "npm"

- run: yarn
#- run: |
# echo 'module.exports.basePath = "/nextjs-template"' >> next.config.js
- run: yarn run build
env:
UPLOAD_SENTRY_SOURCEMAPS: false

#- run: npm run export
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./build

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
File renamed without changes.
88 changes: 0 additions & 88 deletions exchange/src/App.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
109 changes: 109 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React, { useCallback, useEffect, useState } from 'react';
import './App.css';
import { SetupMixFetchOps, mixFetch } from '@nymproject/mix-fetch-full-fat';
import TableContainer from '@mui/material/TableContainer';
import Table from '@mui/material/Table';
import TableRow from '@mui/material/TableRow';
import TableCell from '@mui/material/TableCell';
import TableHead from '@mui/material/TableHead';
import TableBody from '@mui/material/TableBody';
import { Box, CssBaseline, Typography } from '@mui/material';

const defaultUrl =
'https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin,ethereum,nym,monero&order=market_cap_desc&per_page=100&page=1&sparkline=false&locale=en';
//const defaultUrl = 'https://nymtech.net/favicon.svg'
const args = { mode: 'unsafe-ignore-cors' };
const mixFetchOptions: SetupMixFetchOps = {
preferredGateway: '3B7PsbXFuqq6rerYFLw5HPbQb4UmBqAhfWURRovMmWoj',
preferredNetworkRequester:
'AQRRAs9oc8QWXAFBs44YhCKUny7AyLsfLy91pwmGgxuf.CWUKoKA1afSKyw5BnFJJg19UDgnaVATupsFhQpyTEBHJ@EBT8jTD8o4tKng2NXrrcrzVhJiBnKpT1bJy5CMeArt2w',
mixFetchOverride: {
requestTimeoutMs: 60_000
},
extra: {},
forceTls: false
};

let alreadyRun = false;

function App() {
const [url, setUrl] = useState<string>(defaultUrl);
const [data, setData] = useState<any>();

const handleFetch = useCallback(async () => {
try {
setData(undefined);
const response = await mixFetch(url, args, mixFetchOptions);
console.log(response);
const resHtml = await response.text();
setData(JSON.parse(resHtml));
} catch (err) {
setData({"error": err})
console.log(JSON.stringify(err))
console.log(err);
}
}, [url]);

useEffect(() => {
if (!alreadyRun) {
handleFetch();
alreadyRun = true;
}
}, []);


return (
<>
<br/>
<Typography variant="h4">Privacy preserved Cryptocurrency Prices</Typography>
<div>
{
data && data.hasOwnProperty("error") && <>Error with application: {JSON.stringify(data.error)}</>
}
{
<TableContainer>
<Table>
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>Price</TableCell>
<TableCell>High (24h)</TableCell>
<TableCell>Low (24h)</TableCell>
<TableCell>Price Change (24h)</TableCell>

</TableRow>
</TableHead>
<TableBody>
{data && !data.hasOwnProperty("error") &&
data.map(ticker => {
return (
<TableRow key={ticker.id}>
<TableCell>{ticker.id.charAt(0).toUpperCase() + ticker.id.slice(1)}</TableCell>
<TableCell>${ticker.current_price}</TableCell>
<TableCell>${ticker.high_24h}</TableCell>
<TableCell>${ticker.low_24h}</TableCell>
<TableCell>{ticker.price_change_percentage_24h}%</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
}
</div>
<Box
sx={{
position: 'fixed',
bottom: 0,
width: '100%',
height: 60,
textAlign: 'center',
}}
>
<Typography align="center">Developed by <a href='https://notrustverify.ch'>No Trust Verify</a>, powered by <a href="https://nymtech.net/">Nym</a></Typography>
</Box>
</>
);
}

export default App;
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions exchange/yarn.lock → yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2087,11 +2087,6 @@
resolved "https://registry.yarnpkg.com/@nymproject/mix-fetch-full-fat/-/mix-fetch-full-fat-1.2.0.tgz#3942ea3a8d360b244034194d25f404210f8e2408"
integrity sha512-WH2+sBCRk6NMJdRgjlgDwaIk72g6Evlu2rsmmoCvMlqYDWDS5xUMA0vYaNGBjRSROXDWNPW2OIgZ98OFTa0EFw==

"@nymproject/mix-fetch@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@nymproject/mix-fetch/-/mix-fetch-1.2.0.tgz#0f09248328d3661cfb4a0cd3bcdfef4ed503205b"
integrity sha512-lvokm7Fh9/cyzOtovgjgbfgRjAL8YQXDGZt8wLTkos7FJFc1u0DZbUESSc14Mz+ZoShMvKbiocq3lgZCgnplzg==

"@octokit/auth-token@^2.4.4":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36"
Expand Down

0 comments on commit 146a7be

Please sign in to comment.