Skip to content

Commit 6abe35b

Browse files
fix: prettier for tezos-provider
1 parent 22097ed commit 6abe35b

File tree

8 files changed

+464
-225
lines changed

8 files changed

+464
-225
lines changed

dapps/tezos-provider/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.changeset
2+
coverage
3+
.idea
4+
.next
5+
node_modules

dapps/tezos-provider/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite --port 5176",
7+
"dev": "vite",
88
"build": "tsc && vite build",
99
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10-
"preview": "vite preview"
10+
"preview": "vite preview",
11+
"prettier": "prettier --check '**/*.{js,ts,jsx,tsx}'",
12+
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
1113
},
1214
"dependencies": {
15+
"@airgap/beacon-types": "^4.2.2",
1316
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
1417
"@solana/web3.js": "^1.78.4",
1518
"@taquito/taquito": "^20.0.1",
16-
"@airgap/beacon-types": "^4.2.2",
1719
"@walletconnect/modal": "^2.6.2",
1820
"@walletconnect/universal-provider": "^2.14.0",
1921
"bs58": "^5.0.0",
@@ -28,9 +30,11 @@
2830
"@typescript-eslint/parser": "^6.4.1",
2931
"@vitejs/plugin-react-swc": "^3.3.2",
3032
"eslint": "^8.48.0",
33+
"eslint-config-prettier": "8.5.0",
3134
"eslint-plugin-react": "^7.33.2",
3235
"eslint-plugin-react-hooks": "^4.6.0",
3336
"eslint-plugin-react-refresh": "^0.4.3",
37+
"prettier": "^3.3.3",
3438
"typescript": "^5.2.2",
3539
"vite": "^4.4.9"
3640
}

dapps/tezos-provider/src/App.tsx

Lines changed: 152 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { WalletConnectModal } from "@walletconnect/modal";
22
import { useEffect, useState, useCallback } from "react";
33
import { SAMPLES, SAMPLE_KINDS } from "./utils/samples";
4-
import TezosProvider, { TezosChainDataMainnet, TezosChainDataTestnet } from "@walletconnect/tezos-provider";
4+
import TezosProvider, {
5+
TezosChainDataMainnet,
6+
TezosChainDataTestnet,
7+
} from "@walletconnect/tezos-provider";
58

69
const projectId = import.meta.env.VITE_PROJECT_ID;
710

@@ -13,7 +16,9 @@ const App = () => {
1316
const [lastKind, setLastKind] = useState<SAMPLE_KINDS | null>(null);
1417
const [result, setResult] = useState<any>(null);
1518
const [description, setDescription] = useState<any>(null);
16-
const [contractAddress, setContractAddress] = useState("[click Origination to get contract address]");
19+
const [contractAddress, setContractAddress] = useState(
20+
"[click Origination to get contract address]",
21+
);
1722
const [balance, setBalance] = useState("");
1823

1924
// Initialize WalletConnect Modal and TezosProvider
@@ -36,28 +41,43 @@ const App = () => {
3641
await modal.openModal({ uri });
3742
});
3843

39-
signer?.on("session_ping", ({ id, topic }: { id: string; topic: string }) =>
40-
console.log("Session Ping:", id, topic));
41-
signer?.on("session_event", ({ event, chainId }: { event: any; chainId: string }) =>
42-
console.log("Session Event:", event, chainId));
43-
signer?.on("session_update", ({ event, chainId }: { event: any; chainId: string }) =>
44-
console.log("Session Update:", event, chainId));
44+
signer?.on(
45+
"session_ping",
46+
({ id, topic }: { id: string; topic: string }) =>
47+
console.log("Session Ping:", id, topic),
48+
);
49+
signer?.on(
50+
"session_event",
51+
({ event, chainId }: { event: any; chainId: string }) =>
52+
console.log("Session Event:", event, chainId),
53+
);
54+
signer?.on(
55+
"session_update",
56+
({ event, chainId }: { event: any; chainId: string }) =>
57+
console.log("Session Update:", event, chainId),
58+
);
4559

46-
signer?.on("session_delete", ({ id, topic }: { id: string; topic: string }) => {
47-
console.log("Session Delete:", id, topic);
48-
setIsConnected(false);
49-
setProvider(null);
50-
});
60+
signer?.on(
61+
"session_delete",
62+
({ id, topic }: { id: string; topic: string }) => {
63+
console.log("Session Delete:", id, topic);
64+
setIsConnected(false);
65+
setProvider(null);
66+
},
67+
);
5168

5269
signer?.on("connect", ({ id, topic }: { id: string; topic: string }) => {
5370
console.log("Connected:", id, topic);
5471
setIsConnected(true);
5572
});
5673

57-
signer?.on("disconnect", ({ id, topic }: { id: string; topic: string }) => {
58-
console.log("Disconnected:", id, topic);
59-
setIsConnected(false);
60-
});
74+
signer?.on(
75+
"disconnect",
76+
({ id, topic }: { id: string; topic: string }) => {
77+
console.log("Disconnected:", id, topic);
78+
setIsConnected(false);
79+
},
80+
);
6181
};
6282
initProvider();
6383
}, []);
@@ -67,7 +87,9 @@ const App = () => {
6787
if (!provider) return;
6888

6989
try {
70-
await provider.connect({ chains: [TezosChainDataTestnet, TezosChainDataMainnet] });
90+
await provider.connect({
91+
chains: [TezosChainDataTestnet, TezosChainDataMainnet],
92+
});
7193
setIsConnected(true);
7294
console.log("Connected to Tezos");
7395
const balance = await provider.getBalance();
@@ -109,21 +131,32 @@ const App = () => {
109131
res = await provider.tezosSign("05010000004254");
110132
break;
111133
case SAMPLE_KINDS.SEND_TRANSACTION:
112-
res = await provider.tezosSendTransaction(SAMPLES[SAMPLE_KINDS.SEND_TRANSACTION]);
134+
res = await provider.tezosSendTransaction(
135+
SAMPLES[SAMPLE_KINDS.SEND_TRANSACTION],
136+
);
113137
break;
114138
case SAMPLE_KINDS.SEND_DELEGATION:
115-
res = await provider.tezosSendDelegation(SAMPLES[SAMPLE_KINDS.SEND_DELEGATION]);
139+
res = await provider.tezosSendDelegation(
140+
SAMPLES[SAMPLE_KINDS.SEND_DELEGATION],
141+
);
116142
break;
117143
case SAMPLE_KINDS.SEND_UNDELEGATION:
118144
res = await provider.tezosSendUndelegation();
119145
break;
120146
case SAMPLE_KINDS.SEND_ORGINATION:
121-
res = await provider.tezosSendOrigination(SAMPLES[SAMPLE_KINDS.SEND_ORGINATION]);
147+
res = await provider.tezosSendOrigination(
148+
SAMPLES[SAMPLE_KINDS.SEND_ORGINATION],
149+
);
122150
for (let attempt = 0; attempt < 5; attempt++) {
123-
const contractAddressList = await provider.getContractAddress(res.hash);
151+
const contractAddressList = await provider.getContractAddress(
152+
res.hash,
153+
);
124154
if (contractAddressList.length > 0) {
125155
setContractAddress(contractAddressList[0]);
126-
console.log("TezosRpc stored contract:", contractAddressList[0]);
156+
console.log(
157+
"TezosRpc stored contract:",
158+
contractAddressList[0],
159+
);
127160
break;
128161
}
129162
console.log("Waiting for contract address...");
@@ -141,13 +174,19 @@ const App = () => {
141174
});
142175
break;
143176
case SAMPLE_KINDS.SEND_STAKE:
144-
res = await provider.tezosSendStake(SAMPLES[SAMPLE_KINDS.SEND_STAKE]);
177+
res = await provider.tezosSendStake(
178+
SAMPLES[SAMPLE_KINDS.SEND_STAKE],
179+
);
145180
break;
146181
case SAMPLE_KINDS.SEND_UNSTAKE:
147-
res = await provider.tezosSendUnstake(SAMPLES[SAMPLE_KINDS.SEND_UNSTAKE]);
182+
res = await provider.tezosSendUnstake(
183+
SAMPLES[SAMPLE_KINDS.SEND_UNSTAKE],
184+
);
148185
break;
149186
case SAMPLE_KINDS.SEND_FINALIZE:
150-
res = await provider.tezosSendFinalizeUnstake(SAMPLES[SAMPLE_KINDS.SEND_FINALIZE]);
187+
res = await provider.tezosSendFinalizeUnstake(
188+
SAMPLES[SAMPLE_KINDS.SEND_FINALIZE],
189+
);
151190
break;
152191
case SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE:
153192
res = await provider.tezosSendIncreasePaidStorage({
@@ -171,7 +210,7 @@ const App = () => {
171210
}
172211
}
173212
},
174-
[provider, contractAddress]
213+
[provider, contractAddress],
175214
);
176215

177216
// Provide operation descriptions
@@ -200,7 +239,7 @@ const App = () => {
200239
setDescription("No description available");
201240
}
202241
},
203-
[contractAddress, provider?.address]
242+
[contractAddress, provider?.address],
204243
);
205244

206245
const describeClear = useCallback(() => {
@@ -211,29 +250,98 @@ const App = () => {
211250
<div className="App">
212251
<h1>TezosProvider</h1>
213252
<h2>WalletConnect for Tezos</h2>
214-
{(!projectId || projectId === "YOUR_PROJECT_ID") ? (
253+
{!projectId || projectId === "YOUR_PROJECT_ID" ? (
215254
<div className="warning">
216-
<p><b>The project is not initialized</b></p>
255+
<p>
256+
<b>The project is not initialized</b>
257+
</p>
217258
<p>Set your project ID in the .env file</p>
218259
</div>
219260
) : isConnected ? (
220261
<>
221-
<p><b>Public Key: </b>{provider?.address ?? "No account connected"}</p>
222-
<p><b>Balance: </b>{balance}</p>
262+
<p>
263+
<b>Public Key: </b>
264+
{provider?.address ?? "No account connected"}
265+
</p>
266+
<p>
267+
<b>Balance: </b>
268+
{balance}
269+
</p>
223270
<div className="layout-container">
224271
<div className="btn-container">
225-
<button onClick={disconnect} onMouseEnter={describeClear}>Disconnect</button>
226-
<button onClick={() => handleOp(SAMPLE_KINDS.GET_ACCOUNTS)} onMouseEnter={describeClear}>Get Accounts</button>
227-
<button onClick={() => handleOp(SAMPLE_KINDS.SIGN)} onMouseEnter={describeClear}>Sign</button>
228-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_TRANSACTION)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_TRANSACTION)}>Send Transaction</button>
229-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_DELEGATION)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_DELEGATION)}>Delegate</button>
230-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_UNDELEGATION)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_UNDELEGATION)}>Undelegate</button>
231-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_ORGINATION)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_ORGINATION)}>Originate</button>
232-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_CONTRACT_CALL)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_CONTRACT_CALL)}>Contract call</button>
233-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_STAKE)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_STAKE)}>Stake</button>
234-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_UNSTAKE)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_UNSTAKE)}>Unstake</button>
235-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_FINALIZE)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_FINALIZE)}>Finalize</button>
236-
<button onClick={() => handleOp(SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE)} onMouseEnter={() => describe(SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE)}>Increase paid storage</button>
272+
<button onClick={disconnect} onMouseEnter={describeClear}>
273+
Disconnect
274+
</button>
275+
<button
276+
onClick={() => handleOp(SAMPLE_KINDS.GET_ACCOUNTS)}
277+
onMouseEnter={describeClear}
278+
>
279+
Get Accounts
280+
</button>
281+
<button
282+
onClick={() => handleOp(SAMPLE_KINDS.SIGN)}
283+
onMouseEnter={describeClear}
284+
>
285+
Sign
286+
</button>
287+
<button
288+
onClick={() => handleOp(SAMPLE_KINDS.SEND_TRANSACTION)}
289+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_TRANSACTION)}
290+
>
291+
Send Transaction
292+
</button>
293+
<button
294+
onClick={() => handleOp(SAMPLE_KINDS.SEND_DELEGATION)}
295+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_DELEGATION)}
296+
>
297+
Delegate
298+
</button>
299+
<button
300+
onClick={() => handleOp(SAMPLE_KINDS.SEND_UNDELEGATION)}
301+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_UNDELEGATION)}
302+
>
303+
Undelegate
304+
</button>
305+
<button
306+
onClick={() => handleOp(SAMPLE_KINDS.SEND_ORGINATION)}
307+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_ORGINATION)}
308+
>
309+
Originate
310+
</button>
311+
<button
312+
onClick={() => handleOp(SAMPLE_KINDS.SEND_CONTRACT_CALL)}
313+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_CONTRACT_CALL)}
314+
>
315+
Contract call
316+
</button>
317+
<button
318+
onClick={() => handleOp(SAMPLE_KINDS.SEND_STAKE)}
319+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_STAKE)}
320+
>
321+
Stake
322+
</button>
323+
<button
324+
onClick={() => handleOp(SAMPLE_KINDS.SEND_UNSTAKE)}
325+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_UNSTAKE)}
326+
>
327+
Unstake
328+
</button>
329+
<button
330+
onClick={() => handleOp(SAMPLE_KINDS.SEND_FINALIZE)}
331+
onMouseEnter={() => describe(SAMPLE_KINDS.SEND_FINALIZE)}
332+
>
333+
Finalize
334+
</button>
335+
<button
336+
onClick={() =>
337+
handleOp(SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE)
338+
}
339+
onMouseEnter={() =>
340+
describe(SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE)
341+
}
342+
>
343+
Increase paid storage
344+
</button>
237345
</div>
238346
<div className="result-column">
239347
{result && (

dapps/tezos-provider/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import "./styles/index.css";
66
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
77
<React.StrictMode>
88
<App />
9-
</React.StrictMode>
9+
</React.StrictMode>,
1010
);

0 commit comments

Comments
 (0)