Skip to content

Commit 77c9121

Browse files
fix: prettier for react-dapp-v2
1 parent a219cd0 commit 77c9121

File tree

7 files changed

+86
-60
lines changed

7 files changed

+86
-60
lines changed

advanced/dapps/react-dapp-v2/src/components/Asset.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function getAssetIcon(asset: AssetData): JSX.Element {
5656
}
5757
}
5858

59-
function getDecimals(asset: AssetData) : number {
59+
function getDecimals(asset: AssetData): number {
6060
switch (asset?.symbol?.toLowerCase()) {
6161
case "xtz":
6262
return 6;

advanced/dapps/react-dapp-v2/src/components/Blockchain.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const SPre = styled.div`
8585
background-color: #f4f4f4;
8686
width: 100%;
8787
min-width: 700px;
88-
textAlign: 'left';
88+
textalign: "left";
8989
padding: 10px;
9090
border-radius: 5px;
9191
overflow-x: auto;
@@ -136,7 +136,9 @@ const Blockchain: FC<PropsWithChildren<BlockchainProps>> = (
136136
balances,
137137
actions,
138138
} = props;
139-
const [hoveredDescription, setHoveredDescription] = React.useState<string | null>(null);
139+
const [hoveredDescription, setHoveredDescription] = React.useState<
140+
string | null
141+
>(null);
140142

141143
if (!Object.keys(chainData).length) return null;
142144

@@ -215,7 +217,7 @@ const Blockchain: FC<PropsWithChildren<BlockchainProps>> = (
215217
</SAccount>
216218
{hoveredDescription && (
217219
<SPre>
218-
<pre style={{ textAlign: 'left' }}>{hoveredDescription}</pre>
220+
<pre style={{ textAlign: "left" }}>{hoveredDescription}</pre>
219221
</SPre>
220222
)}
221223
</React.Fragment>

advanced/dapps/react-dapp-v2/src/constants/default.ts

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
PartialTezosIncreasePaidStorageOperation,
55
PartialTezosOriginationOperation as PartialTezosOriginationOperationOriginal,
66
PartialTezosTransactionOperation,
7-
TezosOperationType }
8-
from "@airgap/beacon-types";
7+
TezosOperationType,
8+
} from "@airgap/beacon-types";
99
import { ScriptedContracts } from "@taquito/rpc";
1010

1111
if (!process.env.NEXT_PUBLIC_PROJECT_ID)
@@ -283,50 +283,54 @@ export enum TEZOS_SAMPLE_KINDS {
283283
const tezosTransactionOperation: PartialTezosTransactionOperation = {
284284
kind: TezosOperationType.TRANSACTION,
285285
destination: "tz3ZmB8oWUmi8YZXgeRpgAcPnEMD8VgUa4Ve", // Tezos Foundation Ghost Baker
286-
amount: "100000"
286+
amount: "100000",
287287
};
288288

289289
const tezosOriginationOperation: PartialTezosOriginationOperation = {
290290
kind: TezosOperationType.ORIGINATION,
291-
balance: '1',
292-
script: { // This contract adds the parameter to the storage value
291+
balance: "1",
292+
script: {
293+
// This contract adds the parameter to the storage value
293294
code: [
294295
{ prim: "parameter", args: [{ prim: "int" }] },
295296
{ prim: "storage", args: [{ prim: "int" }] },
296-
{ prim: "code",
297-
args: [[
298-
{ prim: "DUP" }, // Duplicate the parameter (parameter is pushed onto the stack)
299-
{ prim: "CAR" }, // Access the parameter from the stack (parameter is on top)
300-
{ prim: "DIP", args: [[{ prim: "CDR" }]] }, // Access the storage value (storage is on the stack)
301-
{ prim: "ADD" }, // Add the parameter to the storage value
297+
{
298+
prim: "code",
299+
args: [
300+
[
301+
{ prim: "DUP" }, // Duplicate the parameter (parameter is pushed onto the stack)
302+
{ prim: "CAR" }, // Access the parameter from the stack (parameter is on top)
303+
{ prim: "DIP", args: [[{ prim: "CDR" }]] }, // Access the storage value (storage is on the stack)
304+
{ prim: "ADD" }, // Add the parameter to the storage value
302305
{ prim: "NIL", args: [{ prim: "operation" }] }, // Create an empty list of operations
303-
{ prim: "PAIR" } // Pair the updated storage with the empty list of operations
304-
]]
305-
}
306+
{ prim: "PAIR" }, // Pair the updated storage with the empty list of operations
307+
],
308+
],
309+
},
306310
],
307-
storage: { int: "10" }
311+
storage: { int: "10" },
308312
},
309313
};
310314

311315
const tezosContractCallOperation: PartialTezosTransactionOperation = {
312316
kind: TezosOperationType.TRANSACTION,
313317
destination: "[contract address]",
314318
amount: "0",
315-
parameters: { entrypoint: "default", value: { int: "20" } } // Add 20 to the current storage value
319+
parameters: { entrypoint: "default", value: { int: "20" } }, // Add 20 to the current storage value
316320
};
317321

318322
const tezosDelegationOperation: PartialTezosDelegationOperation = {
319323
kind: TezosOperationType.DELEGATION,
320-
delegate: "tz3ZmB8oWUmi8YZXgeRpgAcPnEMD8VgUa4Ve" // Tezos Foundation Ghost Baker. Cannot delegate to ourself as that would block undelegation
324+
delegate: "tz3ZmB8oWUmi8YZXgeRpgAcPnEMD8VgUa4Ve", // Tezos Foundation Ghost Baker. Cannot delegate to ourself as that would block undelegation
321325
};
322326

323327
const tezosUndelegationOperation: PartialTezosDelegationOperation = {
324-
kind: TezosOperationType.DELEGATION
328+
kind: TezosOperationType.DELEGATION,
325329
};
326330

327331
const tezosStakeOperation: PartialTezosTransactionOperation = {
328332
kind: TezosOperationType.TRANSACTION,
329-
destination:"[own adress]",
333+
destination: "[own adress]",
330334
amount: "1000000",
331335
parameters: {
332336
entrypoint: "stake",
@@ -336,7 +340,7 @@ const tezosStakeOperation: PartialTezosTransactionOperation = {
336340

337341
const tezosUnstakeOperation: PartialTezosTransactionOperation = {
338342
kind: TezosOperationType.TRANSACTION,
339-
destination:"[own adress]",
343+
destination: "[own adress]",
340344
amount: "1000000",
341345
parameters: {
342346
entrypoint: "unstake",
@@ -346,19 +350,20 @@ const tezosUnstakeOperation: PartialTezosTransactionOperation = {
346350

347351
const tezosFinalizeOperation: PartialTezosTransactionOperation = {
348352
kind: TezosOperationType.TRANSACTION,
349-
destination:"[own adress]",
353+
destination: "[own adress]",
350354
amount: "0",
351355
parameters: {
352356
entrypoint: "finalize_unstake",
353357
value: { prim: "Unit" },
354358
},
355359
};
356360

357-
const TezosIncreasePaidStorageOperation: PartialTezosIncreasePaidStorageOperation = {
358-
kind: TezosOperationType.INCREASE_PAID_STORAGE,
359-
amount: "10",
360-
destination: "[contract address]"
361-
};
361+
const TezosIncreasePaidStorageOperation: PartialTezosIncreasePaidStorageOperation =
362+
{
363+
kind: TezosOperationType.INCREASE_PAID_STORAGE,
364+
amount: "10",
365+
destination: "[contract address]",
366+
};
362367

363368
export const TEZOS_SAMPLES = {
364369
"tezos_send:transaction": tezosTransactionOperation,

advanced/dapps/react-dapp-v2/src/contexts/JsonRpcContext.tsx

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ export function JsonRpcContextProvider({
173173
const [kadenaAccount, setKadenaAccount] = useState<KadenaAccount | null>(
174174
null
175175
);
176-
const [contractAddress, setContractAddress] = useState("[Run Origination to get contract address]");
176+
const [contractAddress, setContractAddress] = useState(
177+
"[Run Origination to get contract address]"
178+
);
177179

178180
const { client, session, accounts, balances, solanaPublicKeys } =
179181
useWalletConnectClient();
@@ -883,7 +885,7 @@ export function JsonRpcContextProvider({
883885
})),
884886
transaction: transaction
885887
.serialize({ verifySignatures: false })
886-
.toString('base64'),
888+
.toString("base64"),
887889
},
888890
},
889891
});
@@ -1416,9 +1418,7 @@ export function JsonRpcContextProvider({
14161418

14171419
// -------- TEZOS RPC METHODS --------
14181420

1419-
const signTransaction = (
1420-
method: TEZOS_SAMPLE_KINDS
1421-
) => {
1421+
const signTransaction = (method: TEZOS_SAMPLE_KINDS) => {
14221422
return _createJsonRpcRequestHandler(
14231423
async (
14241424
chainId: string,
@@ -1431,36 +1431,41 @@ export function JsonRpcContextProvider({
14311431
break;
14321432

14331433
case TEZOS_SAMPLE_KINDS.SEND_DELEGATION:
1434-
operation = TEZOS_SAMPLES[method]
1434+
operation = TEZOS_SAMPLES[method];
14351435
break;
14361436

14371437
case TEZOS_SAMPLE_KINDS.SEND_UNDELEGATION:
1438-
operation = TEZOS_SAMPLES[method]
1438+
operation = TEZOS_SAMPLES[method];
14391439
break;
14401440

14411441
case TEZOS_SAMPLE_KINDS.SEND_ORGINATION:
1442-
operation = TEZOS_SAMPLES[method]
1442+
operation = TEZOS_SAMPLES[method];
14431443
break;
14441444

14451445
case TEZOS_SAMPLE_KINDS.SEND_CONTRACT_CALL:
1446-
operation = {...TEZOS_SAMPLES[method], destination: contractAddress};
1446+
operation = {
1447+
...TEZOS_SAMPLES[method],
1448+
destination: contractAddress,
1449+
};
14471450
break;
14481451

14491452
case TEZOS_SAMPLE_KINDS.SEND_STAKE:
1450-
operation = {...TEZOS_SAMPLES[method], destination: address};
1453+
operation = { ...TEZOS_SAMPLES[method], destination: address };
14511454
break;
14521455

14531456
case TEZOS_SAMPLE_KINDS.SEND_UNSTAKE:
1454-
operation = {...TEZOS_SAMPLES[method], destination: address};
1457+
operation = { ...TEZOS_SAMPLES[method], destination: address };
14551458
break;
14561459

14571460
case TEZOS_SAMPLE_KINDS.SEND_FINALIZE:
1458-
operation = {...TEZOS_SAMPLES[method], destination: address};
1461+
operation = { ...TEZOS_SAMPLES[method], destination: address };
14591462
break;
14601463

14611464
case TEZOS_SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE:
14621465
operation = {
1463-
...TEZOS_SAMPLES[method], destination: contractAddress};
1466+
...TEZOS_SAMPLES[method],
1467+
destination: contractAddress,
1468+
};
14641469
break;
14651470

14661471
default:
@@ -1481,12 +1486,17 @@ export function JsonRpcContextProvider({
14811486

14821487
// Get the contract ID if it's an origination
14831488
if (method === TEZOS_SAMPLE_KINDS.SEND_ORGINATION) {
1484-
const contractAddressList = await apiGetContractAddress(chainId, result.hash);
1489+
const contractAddressList = await apiGetContractAddress(
1490+
chainId,
1491+
result.hash
1492+
);
14851493
if (contractAddressList.length > 0) {
14861494
setContractAddress(contractAddressList[0]);
14871495
console.log("TezosRpc stored contract: ", contractAddressList[0]);
14881496
} else {
1489-
console.error("TezosRpc could not find contract address in origination operation.");
1497+
console.error(
1498+
"TezosRpc could not find contract address in origination operation."
1499+
);
14901500
}
14911501
}
14921502

@@ -1506,7 +1516,7 @@ export function JsonRpcContextProvider({
15061516
chainId: string,
15071517
address: string
15081518
): Promise<IFormattedRpcResponse> => {
1509-
const result = await client!.request<Array<{ address: string}>>({
1519+
const result = await client!.request<Array<{ address: string }>>({
15101520
chainId,
15111521
topic: session!.topic,
15121522
request: {
@@ -1525,13 +1535,17 @@ export function JsonRpcContextProvider({
15251535
),
15261536
testSignTransaction: signTransaction(TEZOS_SAMPLE_KINDS.SEND_TRANSACTION),
15271537
testSignOrigination: signTransaction(TEZOS_SAMPLE_KINDS.SEND_ORGINATION),
1528-
testSignContractCall: signTransaction(TEZOS_SAMPLE_KINDS.SEND_CONTRACT_CALL),
1538+
testSignContractCall: signTransaction(
1539+
TEZOS_SAMPLE_KINDS.SEND_CONTRACT_CALL
1540+
),
15291541
testSignDelegation: signTransaction(TEZOS_SAMPLE_KINDS.SEND_DELEGATION),
15301542
testSignUndelegation: signTransaction(TEZOS_SAMPLE_KINDS.SEND_UNDELEGATION),
15311543
testSignStake: signTransaction(TEZOS_SAMPLE_KINDS.SEND_STAKE),
15321544
testSignUnstake: signTransaction(TEZOS_SAMPLE_KINDS.SEND_UNSTAKE),
15331545
testSignFinalize: signTransaction(TEZOS_SAMPLE_KINDS.SEND_FINALIZE),
1534-
testSignIncreasePaidStorage: signTransaction(TEZOS_SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE),
1546+
testSignIncreasePaidStorage: signTransaction(
1547+
TEZOS_SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE
1548+
),
15351549
testSignMessage: _createJsonRpcRequestHandler(
15361550
async (
15371551
chainId: string,

advanced/dapps/react-dapp-v2/src/helpers/api.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ export async function apiGetAccountBalance(
157157
}
158158

159159
if (namespace === "tezos") {
160-
return apiGetTezosAccountBalance(
161-
address, networkId
162-
);
160+
return apiGetTezosAccountBalance(address, networkId);
163161
}
164162

165163
if (namespace !== "eip155") {

advanced/dapps/react-dapp-v2/src/helpers/tezos.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { TezosToolkit } from '@taquito/taquito';
1+
import { TezosToolkit } from "@taquito/taquito";
22
import { TezosChainData } from "../chains/tezos";
33

44
// Singleton class to manage TezosToolkit instances
55
class TezosInstanceManager {
66
private static instances: Map<string, TezosToolkit> = new Map();
77

8-
private constructor() { }
8+
private constructor() {}
99

1010
public static getTezosInstance(networkId: string): TezosToolkit {
1111
if (!TezosChainData[networkId]) {
@@ -22,7 +22,6 @@ class TezosInstanceManager {
2222
}
2323
export default TezosInstanceManager;
2424

25-
2625
export async function apiGetTezosAccountBalance(
2726
address: string,
2827
networkId: string
@@ -33,7 +32,7 @@ export async function apiGetTezosAccountBalance(
3332
console.log(`Got balance: ${balanceInTez} ꜩ`);
3433

3534
return {
36-
balance: (balanceInTez).toString(),
35+
balance: balanceInTez.toString(),
3736
symbol: "XTZ",
3837
name: "XTZ",
3938
};
@@ -56,9 +55,13 @@ export async function apiGetContractAddress(
5655
.then((data) => {
5756
return data
5857
.map((op: any) => {
59-
const address = op?.status === 'applied' && op?.originatedContract?.kind === "smart_contract" ? op.originatedContract.address : '';
58+
const address =
59+
op?.status === "applied" &&
60+
op?.originatedContract?.kind === "smart_contract"
61+
? op.originatedContract.address
62+
: "";
6063
if (address) {
61-
console.log('Got contract address:', address);
64+
console.log("Got contract address:", address);
6265
}
6366
return address;
6467
})

advanced/dapps/react-dapp-v2/src/pages/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,13 @@ const Home: NextPage = () => {
454454
openRequestModal();
455455
await tezosRpc.testSignFinalize(chainId, address);
456456
};
457-
const onSignIncreasePaidStorage = async (chainId: string, address: string) => {
457+
const onSignIncreasePaidStorage = async (
458+
chainId: string,
459+
address: string
460+
) => {
458461
openRequestModal();
459462
await tezosRpc.testSignIncreasePaidStorage(chainId, address);
460-
}
463+
};
461464
const onSignMessage = async (chainId: string, address: string) => {
462465
openRequestModal();
463466
await tezosRpc.testSignMessage(chainId, address);
@@ -511,7 +514,8 @@ const Home: NextPage = () => {
511514
{
512515
method: TEZOS_SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE,
513516
callback: onSignIncreasePaidStorage,
514-
description: TEZOS_SAMPLES[TEZOS_SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE],
517+
description:
518+
TEZOS_SAMPLES[TEZOS_SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE],
515519
},
516520
{
517521
method: TEZOS_SAMPLE_KINDS.SIGN,

0 commit comments

Comments
 (0)