Skip to content

Commit c700aef

Browse files
authored
Apply formatting (#1704)
This PR apply prettier formatting to all files, according to TS Coding Conventions. Now that we have auto format on commit, this is one time format to reduce unnecessary changes in new PRs. Also adds 10 more seconds after graph node start, to allow enough time before creating subgraph. Also attempt to fix chart install workflow and dapp tests. --------- Signed-off-by: georgi-l95 <[email protected]>
1 parent d354eee commit c700aef

File tree

199 files changed

+17219
-13950
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+17219
-13950
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ module.exports = {
2222
"sourceType": "module"
2323
},
2424
"rules": {
25+
semi: [2, 'always']
2526
}
2627
}

dapp-example/README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
Simple implementation of React + Metamask + Hedera Hashgraph
44

55
## Prerequisite
6+
67
You must have running:
8+
79
- JSON-RPC Relay on port :7546
810
- Hedera Local Node
911

1012
## Configuration
1113

1214
Create `.env` file based on `.env.example`
15+
1316
```
1417
# example local setup
1518
HEDERA_NETWORK={"127.0.0.1:50211":"0.0.3"}
@@ -23,12 +26,14 @@ In the project directory:
2326

2427
1. Run `npm install`
2528
2. Run `npm run bootstrap` - only once to setup accounts, tokens etc.
26-
2. Run `npm run start`
29+
3. Run `npm run start`
2730

2831
Dapp should be available at [http://localhost:3000](http://localhost:3000)
2932

3033
## Integration Tests
34+
3135
1. Add additional settings to `.env` file - the settings are used by cypress to add new network and accounts to the Metamask(only in the **testing** environment, **NOT** in your real Metamask).
36+
3237
```
3338
# example local setup
3439
NETWORK_NAME='Hedera Local' # name of the network to be added in metamask
@@ -39,10 +44,12 @@ IS_TESTNET=false # is public testnet
3944
PRIVATE_KEY= # private key of the main account
4045
RECEIVER_PRIVATE_KEY= # private key of the second account
4146
```
47+
4248
2. Run `npm run bootstrap`
4349
3. Run `npm run test`
4450

4551
Available operations:
52+
4653
- [x] Connect with Metamask
4754
- [x] Show connected account's `address` & `balance`
4855
- [x] Sign custom message and extract public key
@@ -56,9 +63,10 @@ Available operations:
5663
- [x] Transfer HBAR tokens
5764

5865
## Screenshots
59-
* *Disconnected account*
60-
![alt text](./images/screenshot1.png "")
61-
* *Connected account with contract interaction*
62-
![alt text](./images/screenshot2.png "")
63-
* *Transfer HTS Tokens*
64-
![alt text](./images/screenshot3.png "")
66+
67+
- _Disconnected account_
68+
![alt text](./images/screenshot1.png)
69+
- _Connected account with contract interaction_
70+
![alt text](./images/screenshot2.png)
71+
- _Transfer HTS Tokens_
72+
![alt text](./images/screenshot3.png)

dapp-example/docker-compose.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ services:
2626
networks:
2727
- x11
2828
extra_hosts:
29-
- "host.docker.internal:host-gateway"
29+
- 'host.docker.internal:host-gateway'
3030

3131
display:
3232
container_name: display
@@ -45,14 +45,7 @@ services:
4545
image: synthetixio/ngrok:457bb48776c3b14de232d9dda620ba9188dc40ac-base
4646
ports:
4747
- '4040:4040'
48-
command:
49-
[
50-
'ngrok',
51-
'http',
52-
'display:8080',
53-
'--authtoken',
54-
'${NGROK_AUTH}'
55-
]
48+
command: ['ngrok', 'http', 'display:8080', '--authtoken', '${NGROK_AUTH}']
5649
depends_on:
5750
- display
5851
networks:

dapp-example/public/index.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
55
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
8+
<meta name="description" content="Web site created using create-react-app" />
129
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
1310
<!--
1411
manifest.json provides metadata used when your web app is installed on a

dapp-example/src/App.js

Lines changed: 67 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { useCallback, useEffect, useMemo, useState } from "react";
1+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
22
import { Button, Chip, Grid, TextField, Typography } from '@mui/material';
3-
import { Box, Container } from "@mui/system";
4-
import { ethers } from "ethers";
3+
import { Box, Container } from '@mui/system';
4+
import { ethers } from 'ethers';
55

6-
import useHederaSdk from "./hooks/useHederaSdk";
6+
import useHederaSdk from './hooks/useHederaSdk';
77

8-
import ContractInteractions from "./components/ContractInteractions";
8+
import ContractInteractions from './components/ContractInteractions';
99
import TransferHTSTokensForm from './components/TransferHTSTokensForm';
1010
import AssociateHTSTokensForm from './components/AssociateHTSTokensForm';
1111
import ActivateHollowAccountForm from './components/ActivateHollowAccountForm';
@@ -30,17 +30,17 @@ function App() {
3030

3131
setSigner(provider.getSigner());
3232

33-
window.ethereum.on("accountsChanged", changeConnectedAccount);
34-
window.ethereum.on("chainChanged", (chainId) => {
33+
window.ethereum.on('accountsChanged', changeConnectedAccount);
34+
window.ethereum.on('chainChanged', (chainId) => {
3535
setErrorMessage(null);
3636
setAddress(null);
3737
setBalance(null);
38-
setAlias('')
39-
setChain(chainId)
40-
setHbarsAmount(0)
41-
setHbarsToAddress('')
42-
setHbarsToAddress(null)
43-
setToBalanceAfterTransfer('')
38+
setAlias('');
39+
setChain(chainId);
40+
setHbarsAmount(0);
41+
setHbarsToAddress('');
42+
setHbarsToAddress(null);
43+
setToBalanceAfterTransfer('');
4444
});
4545
}
4646
}, []);
@@ -55,18 +55,18 @@ function App() {
5555

5656
const status = useMemo(() => {
5757
return {
58-
label: isAccountActivated ? "Account is active" : 'Account not created yet',
59-
color: isAccountActivated ? 'success' : 'error'
60-
}
61-
}, [isAccountActivated])
58+
label: isAccountActivated ? 'Account is active' : 'Account not created yet',
59+
color: isAccountActivated ? 'success' : 'error',
60+
};
61+
}, [isAccountActivated]);
6262

6363
const fetchAccountBalance = async (accountAddress) => {
6464
try {
6565
let formattedBalance = null;
6666
if (accountAddress) {
6767
const accountBalance = await window.ethereum.request({
68-
method: "eth_getBalance",
69-
params: [accountAddress.toString(), "latest"],
68+
method: 'eth_getBalance',
69+
params: [accountAddress.toString(), 'latest'],
7070
});
7171
formattedBalance = ethers.utils.formatEther(accountBalance);
7272
}
@@ -84,27 +84,27 @@ function App() {
8484

8585
setAddress(newAddress);
8686
setErrorMessage(null);
87-
setAlias('')
87+
setAlias('');
8888
} catch (err) {
8989
console.error(err);
90-
setErrorMessage("There was a problem connecting to MetaMask");
90+
setErrorMessage('There was a problem connecting to MetaMask');
9191
}
9292
};
9393

9494
const connectAccountHandler = useCallback(async () => {
9595
if (window.ethereum) {
9696
try {
9797
const accounts = await window.ethereum.request({
98-
method: "eth_requestAccounts",
98+
method: 'eth_requestAccounts',
9999
});
100100

101101
await changeConnectedAccount(accounts[0]);
102102
} catch (err) {
103103
console.error(err);
104-
setErrorMessage("There was a problem connecting to MetaMask");
104+
setErrorMessage('There was a problem connecting to MetaMask');
105105
}
106106
} else {
107-
setErrorMessage("Install MetaMask");
107+
setErrorMessage('Install MetaMask');
108108
}
109109
}, []);
110110

@@ -129,14 +129,18 @@ function App() {
129129
const tx = await signer.sendTransaction({
130130
to: hbarsToAddress,
131131
value: hbarsAmount,
132-
gasLimit: 600_000
132+
gasLimit: 1_000_000,
133133
});
134134
await tx.wait();
135135

136-
setToBalanceAfterTransfer(ethers.utils.formatEther(await window.ethereum.request({
137-
method: 'eth_getBalance',
138-
params: [hbarsToAddress, 'latest']
139-
})));
136+
setToBalanceAfterTransfer(
137+
ethers.utils.formatEther(
138+
await window.ethereum.request({
139+
method: 'eth_getBalance',
140+
params: [hbarsToAddress, 'latest'],
141+
}),
142+
),
143+
);
140144
setSendHbarMsg('Done');
141145
}, [signer, hbarsToAddress, hbarsAmount]);
142146

@@ -147,40 +151,44 @@ function App() {
147151
Error: {errorMessage}
148152
</Typography>
149153
) : null}
150-
<Box
151-
display="flex"
152-
justifyContent="center"
153-
alignItems="center"
154-
paddingTop={10}
155-
paddingBottom={10}
156-
>
154+
<Box display="flex" justifyContent="center" alignItems="center" paddingTop={10} paddingBottom={10}>
157155
<Button onClick={connectAccountHandler} disabled={isConnected} size="large" variant="contained" color="primary">
158156
{isConnected ? 'Connected' : 'Connect Account'}
159157
</Button>
160158
</Box>
161159

162-
163160
<Grid container spacing={2} justifyContent="center">
164161
<Grid item md={8}>
165162
{/* Account Section */}
166-
<Typography variant="h5" sx={{ textDecoration: 'underline' }}> Setup Account </Typography>
167-
<Typography variant="h6"> Address: {address} </Typography>
168-
<Typography variant="h6">
169-
Balance: {balance ? balance + " HBAR" : null}
163+
<Typography variant="h5" sx={{ textDecoration: 'underline' }}>
164+
{' '}
165+
Setup Account{' '}
170166
</Typography>
167+
<Typography variant="h6"> Address: {address} </Typography>
168+
<Typography variant="h6">Balance: {balance ? balance + ' HBAR' : null}</Typography>
171169
<Typography variant="h6" style={{ wordBreak: 'break-word' }}>
172170
Status: {isConnected ? <Chip label={status.label} color={status.color} /> : null}
173171
</Typography>
174172
<br />
175-
<Button id="showAliasBtn" onClick={showAccountIdHandler} disabled={!isConnected} size="medium" variant="contained" color="primary">
173+
<Button
174+
id="showAliasBtn"
175+
onClick={showAccountIdHandler}
176+
disabled={!isConnected}
177+
size="medium"
178+
variant="contained"
179+
color="primary"
180+
>
176181
Show alias
177182
</Button>
178183
<Typography id="aliasField" variant="h6" style={{ wordBreak: 'break-word' }}>
179184
{alias}
180185
</Typography>
181186
<br />
182187

183-
<Typography variant="h5" sx={{ textDecoration: 'underline' }}> Send HBARs </Typography>
188+
<Typography variant="h5" sx={{ textDecoration: 'underline' }}>
189+
{' '}
190+
Send HBARs{' '}
191+
</Typography>
184192
<TextField
185193
id="sendHbarsToField"
186194
fullWidth
@@ -200,12 +208,25 @@ function App() {
200208
value={hbarsAmount}
201209
onChange={(e) => setHbarsAmount(e.target.value)}
202210
/>
203-
<Typography variant="h6" id="toBalanceAfterTransfer"> Balance after transfer: {toBalanceAfterTransfer} </Typography>
204-
<Button id="sendHbarsBtn" onClick={sendHbarsBtnHandle} disabled={!isConnected} size="medium" variant="contained" color="primary">
211+
<Typography variant="h6" id="toBalanceAfterTransfer">
212+
{' '}
213+
Balance after transfer: {toBalanceAfterTransfer}{' '}
214+
</Typography>
215+
<Button
216+
id="sendHbarsBtn"
217+
onClick={sendHbarsBtnHandle}
218+
disabled={!isConnected}
219+
size="medium"
220+
variant="contained"
221+
color="primary"
222+
>
205223
Send
206224
</Button>
207225
<br />
208-
<Typography id="sendHbarMsg" variant="h6"> {sendHbarMsg} </Typography>
226+
<Typography id="sendHbarMsg" variant="h6">
227+
{' '}
228+
{sendHbarMsg}{' '}
229+
</Typography>
209230

210231
{/* Contracts Section */}
211232
<Box sx={{ mt: '2em', mb: '2em' }}>

0 commit comments

Comments
 (0)