Skip to content

Commit

Permalink
conflict solve
Browse files Browse the repository at this point in the history
  • Loading branch information
raunak-dev-edu committed Dec 10, 2023
2 parents 32ab7d5 + 6740897 commit 2e36429
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 21 deletions.
72 changes: 71 additions & 1 deletion packages/site/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useContext } from 'react';

Check failure on line 1 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

'/home/runner/work/Aptos-snap/Aptos-snap/node_modules/react/index.js' imported multiple times
import styled, { useTheme } from 'styled-components';

import Menu from '@mui/material/Menu';

Check failure on line 3 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

'@mui/material' should be listed in the project's dependencies. Run 'npm i -S @mui/material' to add it

Check failure on line 3 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

`@mui/material/Menu` import should occur before import of `react`
import MenuItem from '@mui/material/MenuItem';

Check failure on line 4 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

'@mui/material' should be listed in the project's dependencies. Run 'npm i -S @mui/material' to add it

Check failure on line 4 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

`@mui/material/MenuItem` import should occur before import of `react`
import { useState, useEffect } from 'react';

Check failure on line 5 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

`react` import should occur before import of `styled-components`

Check failure on line 5 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

'useEffect' is defined but never used

Check failure on line 5 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

'/home/runner/work/Aptos-snap/Aptos-snap/node_modules/react/index.js' imported multiple times
import ArrowDropDownCircleOutlinedIcon from '@mui/icons-material/ArrowDropDownCircleOutlined';

Check failure on line 6 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

'@mui/icons-material' should be listed in the project's dependencies. Run 'npm i -S @mui/icons-material' to add it

Check failure on line 6 in packages/site/src/components/Header.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

There should be at least one empty line between import groups
import { MetamaskActions, MetaMaskContext } from '../hooks';
import { connectSnap, getThemePreference, getSnap } from '../utils';
import { HeaderButtons } from './Buttons';
Expand Down Expand Up @@ -60,13 +63,80 @@ export const Header = ({
dispatch({ type: MetamaskActions.SetError, payload: error });
}
};
const [anchorEl, setAnchorEl] = useState(null);
const [selectedNetwork, setSelectedNetwork] = useState('mainnet');

const handleDropdownClick = (event) => {
setAnchorEl(event.currentTarget);
};

const handleDropdownClose = () => {
setAnchorEl(null);
};

const handleNetworkSelect = (network) => {
setSelectedNetwork(network);
handleDropdownClose();
};
return (
<HeaderWrapper>
<LogoWrapper>
<SnapLogo color={theme.colors.icon?.default} size={36} />
<Title>SNAPTOS</Title>
</LogoWrapper>
<RightContainer>
<div
style={{
font: 'Roboto',
fontSize: '1.6rem',
border: '1px solid #000',

borderRadius: '10px',
width: '10rem',
height: '3.4rem',
textAlign: 'center',
lineHeight: '3rem',
display: 'inline-block',
}}
>
{selectedNetwork.toUpperCase()}{' '}
{/* Display the selected network in uppercase */}
<ArrowDropDownCircleOutlinedIcon
style={{
fontSize: 15,
color: '#434343',
lineHeight: '3rem',
display: 'inline-block'
}}
onClick={handleDropdownClick}
/>
</div>
<Menu
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={handleDropdownClose}
>
<MenuItem
onClick={() => handleNetworkSelect('mainnet')}
sx={{ fontSize: '15px', font: 'Roboto' }}
>
Mainnet
</MenuItem>
<MenuItem
onClick={() => handleNetworkSelect('testnet')}
sx={{ fontSize: '15px', font: 'Roboto' }}
>
Testnet
</MenuItem>
<MenuItem
onClick={() => handleNetworkSelect('devnet')}
sx={{ fontSize: '15px', font: 'Roboto' }}
>
Devnet
</MenuItem>

</Menu>{' '}
<div style={{ marginRight: '20px' }} />
<Toggle
onToggle={handleToggleClick}
defaultChecked={getThemePreference()}
Expand Down
27 changes: 10 additions & 17 deletions packages/site/src/components/SnapLogo.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/site/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ const Index = () => {
return (
<Container>
<Heading>
Welcome to <Span>SnapTos</Span>
Welcome to <Span>SNAPTOS</Span>
</Heading>
<Typography
variant="h5"
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/template-snap-monorepo.git"
},
"source": {
"shasum": "DR9ISZ2H+H7PTHXOTUVWXrDureyEs9nKyTxeDE7HueI=",
"shasum": "KJGGeGKviLkzhaQiDzbSZaZLug31ccvF0N+kCXgDwE0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 4 additions & 1 deletion packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,18 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
pvtKey,
address,
password, // tip: use hashed password here
network,
}: {
pvtKey: string;
address: string;
password: string;
network: string;
} = request.params;
await snap.request({
method: 'snap_manageState',
params: {
operation: 'update',
newState: { pvtKey, address, password },
newState: { pvtKey, address, password, network },
},
});
break;
Expand All @@ -182,6 +184,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
pvtKey: string;
address: string;
password: string;
network: string;
} = await snap.request({
method: 'snap_manageState',
params: {
Expand Down
5 changes: 5 additions & 0 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { genTxn } from './src/GenTxn';
import { fundMe } from './src/Faucet';
import { getTransByHash } from './src/GetTransByHash';
import { getGasPriceEstimation } from './src/gasPrice';
import { convertAptToUsd } from './src/aptToUsd';

import { AptosConfig, Network} from '@aptos-labs/ts-sdk';

Expand Down Expand Up @@ -67,6 +68,10 @@ app.post('/getTransByHash', async (req: Request, res: Response) => {
res.json(await getTransByHash(req.body));
});

app.get('/aptToUsd', async (req:Request,res: Response) => {
res.json({APT : await convertAptToUsd()});
});

app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
Expand Down
32 changes: 32 additions & 0 deletions server/src/aptToUsd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable */


export async function convertAptToUsd() {
const response1 = await fetch('https://www.binance.com/api/v3/ticker/price?symbol=APTUSDT')
const data1 = await response1.json();
const price1 = parseFloat(data1.price);
console.log(price1)

const response2 = await fetch('https://api-pub.bitfinex.com/v2/tickers?symbols=tAPTUSD')
const data2 = await response2.json();
const price2 = (data2[0][1] + data2[0][3] + data2[0][7])/3;
console.log(price2)

const response3 = await fetch('https://api.coinbase.com/v2/prices/APT-USD/spot');
const data3 = await response3.json();
const price3 = parseFloat(data3.data.amount);
console.log(price3);

const response4 = await fetch('https://api.huobi.pro/market/detail/merged?symbol=aptusdt');
const data4 = await response4.json();
const price4 = (data4.tick.bid[0] + data4.tick.ask[0])/2;
console.log(price4);

const response5 = await fetch('https://www.mexc.com/open/api/v2/market/ticker?symbol=APT_USDT');
const data5 = await response5.json();
const price5 = (parseFloat(data5.data[0].ask) + parseFloat(data5.data[0].bid) + parseFloat(data5.data[0].last))/3;
console.log(price5)

return (price1 + price2 + price3 + price4 + price5)/5;

}

0 comments on commit 2e36429

Please sign in to comment.