Skip to content

Commit 00bca96

Browse files
committed
change code style to better match repo
1 parent 2235463 commit 00bca96

File tree

13 files changed

+92
-93
lines changed

13 files changed

+92
-93
lines changed

src/components/AccountBottomBar.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, { useState, useEffect } from 'react';
22
import { ResultType } from 'api/apollo/generated/graphql';
3-
import TemplatePopup from "components/TemplatePopup"
3+
import { Badge, Flex, Box, Divider } from 'theme-ui';
44
import { GoChevronDown, GoChevronUp } from 'react-icons/go';
55
import { IoMdAddCircleOutline } from "react-icons/io";
66
import { useProject } from 'providers/Project/projectHooks';
77
import useMousePosition from '../hooks/useMousePosition';
8+
import TemplatePopup from "components/TemplatePopup";
89
import { Feedback as FeedbackRoot } from 'layout/Feedback';
910
import { FeedbackActions } from 'layout/FeedbackActions';
1011
import { SidebarItemInsert } from 'layout/SidebarItemInsert';
1112
import { BottomBarItemInsert } from 'layout/BottomBarItemInsert';
1213
import styled from '@emotion/styled';
13-
import { Badge, Flex, Box, Divider } from 'theme-ui'
1414
import { storageMap } from '../util/accounts';
1515
import { getStorageData } from '../util/storage';
1616
import theme from '../theme';
@@ -94,15 +94,15 @@ const StorageBadge: React.FC<StorageBadgeProps> = ({
9494
case "Link":
9595
return theme.colors.badgeCapability;
9696
case "null":
97-
return theme.colors.badgeNull
97+
return theme.colors.badgeNull;
9898
}
9999
},
100100
}}
101101
>
102102
{type === "Link" ? "Capability" : type}
103103
</Badge>
104-
)
105-
}
104+
);
105+
};
106106

107107
interface IdentifierTypeListProps {
108108
types: { [identifier: string]: string };
@@ -120,7 +120,7 @@ const IdentifierTypeList: React.FC<IdentifierTypeListProps> = ({
120120
resize,
121121
}) => {
122122

123-
const [showTemplatePopup, toggleShowTemplatePopup] = useState<boolean>(false)
123+
const [showTemplatePopup, toggleShowTemplatePopup] = useState<boolean>(false);
124124

125125
const { selectedResourceAccount } = useProject();
126126

@@ -141,7 +141,7 @@ const IdentifierTypeList: React.FC<IdentifierTypeListProps> = ({
141141
>
142142
<ul>
143143
{Object.keys(types).map((key) => {
144-
const identifierType = types[key]
144+
const identifierType = types[key];
145145
return(
146146
<TypeListItem
147147
key={key}
@@ -177,11 +177,11 @@ const IdentifierTypeList: React.FC<IdentifierTypeListProps> = ({
177177
visible={showTemplatePopup}
178178
triggerClose={() => {
179179
toggleShowTemplatePopup(false)
180-
}}
180+
}}
181181
/>
182182
</>
183183
);
184-
}
184+
};
185185

186186
const StateContainer: React.FC<{
187187
value?: any
@@ -268,7 +268,7 @@ const AccountState: React.FC<{
268268
renderDeployButton: () => JSX.Element;
269269
}> = ({ state, selectedResourcesAccount }) => {
270270

271-
const { storage, paths, types } = getStorageData(state)
271+
const { storage, paths, types } = getStorageData(state);
272272

273273
const identifiers = Object.keys(storage);
274274

src/components/Arguments/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import { FaRegCheckCircle, FaRegTimesCircle, FaSpinner } from 'react-icons/fa';
3-
import { AiFillCloseCircle } from 'react-icons/ai'
3+
import { AiFillCloseCircle } from 'react-icons/ai';
44
import { motion, AnimatePresence } from "framer-motion";
55
import { EntityType } from 'providers/Project';
66
import { useProject } from 'providers/Project/projectHooks';
@@ -174,12 +174,12 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
174174

175175
const removeNotification = (set: any, id: number) => {
176176
set((prev: any[]) => {
177-
delete prev[id]
177+
delete prev[id];
178178
return {
179179
...prev
180-
}
181-
})
182-
}
180+
};
181+
});
182+
};
183183

184184
const numberOfErrors = Object.keys(errors).length;
185185
const notEnoughSigners = needSigners && selected.length < signers;
@@ -227,6 +227,7 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
227227

228228
const [notifications, setNotifications] = useState< { [identifier: string]: string[] } >({});
229229

230+
// compare 'state' field for each account, set 'notifications' state for new data
230231
// @ts-ignore: this state is used to compare and render notifications
231232
const [_, setProjectAccts] = useState(project.accounts);
232233
const [counter, setCounter] = useState(0);
@@ -333,6 +334,7 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
333334
console.error(e);
334335
rawResult = e.toString();
335336
}
337+
336338
setProcessingStatus(false);
337339

338340
// Display result in the bottom area
@@ -402,6 +404,7 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
402404

403405
<ErrorsList list={problems.error} {...actions} />
404406
<Hints problems={problems} {...actions} />
407+
405408
<ControlContainer isOk={isOk} progress={progress}>
406409
<StatusMessage>
407410
{statusIcon}
@@ -415,7 +418,6 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
415418
<ul>
416419
<AnimatePresence initial={true}>
417420
{Object.keys(notifications).map((id) => {
418-
419421
const updatedAccounts = notifications[id];
420422

421423
let updatedStorageAccts: string[] = [];
@@ -426,6 +428,7 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
426428
updatedStorageAccts.push(acctHex);
427429
});
428430

431+
// render a new list item for each new id in 'notifications' state
429432
return (
430433
<motion.li
431434
key={id}

src/components/Arguments/styles.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ interface ControlContainerProps {
112112
isOk: boolean;
113113
progress: boolean;
114114
}
115-
116115
export const ControlContainer = styled.div<ControlContainerProps>`
117116
display: flex;
118117
align-items: center;

src/components/MenuList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const MenuList: React.FC<MenuListProps> = ({
3737
onDelete
3838
}) => {
3939
const { active } = useProject()
40-
4140
const isEditing = useRef<HTMLInputElement>();
4241
const [editing, setEditing] = useState([]);
4342
const enterPressed = useKeyPress("Enter");

src/components/ResourcesExplorerButton.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {navigate, useLocation} from "@reach/router"
2+
import {navigate, useLocation} from "@reach/router";
33
import { FaDatabase } from 'react-icons/fa';
44
import { SidebarItemToggleResources } from 'layout/SidebarItemToggleResources';
55
import { useProject } from 'providers/Project/projectHooks';
@@ -13,7 +13,7 @@ export const ResourcesExplorerButton = (props: ResourcesExplorerButtonProps) =>
1313
const { project, setSelectedResourceAccount } = useProject();
1414
const { addr } = props;
1515

16-
const projectPath = isUUUID(project.id) ? project.id : "local"
16+
const projectPath = isUUUID(project.id) ? project.id : "local";
1717

1818
const location = useLocation();
1919
const params = getParams(location.search);
@@ -23,11 +23,11 @@ export const ResourcesExplorerButton = (props: ResourcesExplorerButtonProps) =>
2323
<SidebarItemToggleResources
2424
onClick={() => {
2525
if (addr === storage) {
26-
setSelectedResourceAccount('none')
27-
navigate(`/${projectPath}?type=${type}&id=${id}&storage=${'none'}`)
26+
setSelectedResourceAccount('none');
27+
navigate(`/${projectPath}?type=${type}&id=${id}&storage=${'none'}`);
2828
} else {
29-
setSelectedResourceAccount(addr)
30-
navigate(`/${projectPath}?type=${type}&id=${id}&storage=${addr}`)
29+
setSelectedResourceAccount(addr);
30+
navigate(`/${projectPath}?type=${type}&id=${id}&storage=${addr}`);
3131
}
3232
}}
3333
title={'Open the resources explorer'}

src/components/Sidebar.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const Sidebar: React.FC = () => {
2424
if (isLoading) return <p>Loading...</p>;
2525

2626
const projectPath = isUUUID(project.id) ? project.id : "local"
27-
2827

2928
return (
3029
<SidebarRoot>
@@ -48,12 +47,6 @@ const Sidebar: React.FC = () => {
4847
}}
4948
onInsert={async () => {
5049
const res = await mutator.createTransactionTemplate("", `New Transaction`)
51-
52-
console.log("PROJECT PATH:", projectPath);
53-
console.log("RES FROM CREATE TX MUTATE:", res);
54-
console.log("SELECTED RESOURCE ACCOUNT OR NONE:", selectedResourceAccount || 'none');
55-
56-
5750
navigate(`/${projectPath}?type=tx&id=${res.data?.createTransactionTemplate?.id}&storage=${selectedResourceAccount || 'none'}`)
5851
}}
5952
/>

src/components/TemplatePopup.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Select, Spinner } from '@theme-ui/components';
66
import { useProject } from 'providers/Project/projectHooks';
77
import { isUUUID } from "../util/url";
88
import { getInterpolatedTemplate } from '../util/templates';
9-
import { getStorageData } from "../util/storage"
9+
import { getStorageData } from "../util/storage";
1010
import { storageMap } from '../util/accounts';
1111

1212
import {
@@ -30,19 +30,19 @@ const TemplatePopup: React.FC<{
3030

3131
const { project, mutator, selectedResourceAccount } = useProject();
3232

33-
const selectedAcctState = project.accounts[storageMap[selectedResourceAccount] || 0].state
33+
const selectedAcctState = project.accounts[storageMap[selectedResourceAccount] || 0].state;
3434

35-
const { types, capabilities } = getStorageData(selectedAcctState)
35+
const { types, capabilities } = getStorageData(selectedAcctState);
3636

37-
const capabilitiesKeys = Object.keys(capabilities || [])
37+
const capabilitiesKeys = Object.keys(capabilities || []);
3838

3939
const [processing, setProcessing] = useState(false);
4040
const [templateName, setTemplateName] = useState("My amazing script or transaction");
41-
const [templateType, setTemplateType] = useState("Script")
41+
const [templateType, setTemplateType] = useState("Script");
4242

43-
const [selectedCapability, setSelectedCapability] = useState< string | null >(capabilitiesKeys[0] || null)
43+
const [selectedCapability, setSelectedCapability] = useState< string | null >(capabilitiesKeys[0] || null);
4444

45-
const projectPath = isUUUID(project.id) ? project.id : "local"
45+
const projectPath = isUUUID(project.id) ? project.id : "local";
4646

4747
const firstInput = useRef<HTMLInputElement>(null!);
4848

@@ -173,19 +173,35 @@ const TemplatePopup: React.FC<{
173173
className="green modal"
174174
onClick={async () => {
175175
setProcessing(true);
176-
177-
const capData = capabilities[selectedCapability]
176+
const capData = capabilities[selectedCapability];
178177

179178
if (templateType=== "Transaction") {
180-
const res = await mutator.createTransactionTemplate(getInterpolatedTemplate("tx", capData.contractAddr, capData.path, `${capData.resourceContract}.${capData.resource}`, capData.contractImplementedInterfaces.join(",")), templateName)
179+
const res = await mutator.createTransactionTemplate(
180+
getInterpolatedTemplate(
181+
"tx",
182+
capData.contractAddr,
183+
capData.path,
184+
`${capData.resourceContract}.${capData.resource}`,
185+
capData.contractImplementedInterfaces.join(",")
186+
),
187+
templateName
188+
)
181189
navigate(`/${projectPath}?type=tx&id=${res.data?.createTransactionTemplate?.id}&storage=${selectedResourceAccount || 'none'}`)
182190
} else if (templateType === "Script") {
183-
const res = await mutator.createScriptTemplate(getInterpolatedTemplate("script", capData.contractAddr, capData.path, `${capData.resourceContract}.${capData.resource}`, capData.contractImplementedInterfaces.join(",")), templateName)
191+
const res = await mutator.createScriptTemplate(
192+
getInterpolatedTemplate(
193+
"script",
194+
capData.contractAddr,
195+
capData.path,
196+
`${capData.resourceContract}.${capData.resource}`,
197+
capData.contractImplementedInterfaces.join(",")
198+
),
199+
templateName
200+
)
184201
navigate(`/${projectPath}?type=script&id=${res.data?.createScriptTemplate?.id}&storage=${selectedResourceAccount || 'none'}`)
185202
}
186203

187204
triggerClose(null);
188-
// setProcessing(false);
189205
}}
190206
>
191207
{processing ?

src/containers/Editor/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useState, useEffect } from "react";
2+
import { useLocation} from "@reach/router";
23
import { Button, Flex, Text } from "theme-ui";
34
import { motion, AnimatePresence } from "framer-motion";
45
import { FaCloudUploadAlt } from "react-icons/fa";
56
import { FaCodeBranch, FaDiscord, FaTwitter, FaArrowAltCircleDown } from "react-icons/fa";
6-
import { useLocation} from "@reach/router"
77
import { getParams } from "../../util/url";
88

99
import { Header as HeaderRoot } from "layout/Header";

src/providers/Project/index.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,10 @@ export interface ProjectContextValue {
5252
createScriptExecution: (args?: string[]) => Promise<any>;
5353
active: ActiveEditor;
5454
setActive: (type: EntityType, index: number) => void;
55-
5655
selectedResourceAccount: string;
5756
setSelectedResourceAccount: (account: string) => void;
58-
5957
lastTxSigners: string[];
6058
setLastTxSigners: (signers: string[]) => void;
61-
6259
transactionAccounts: number[];
6360
isSavingCode: boolean;
6461
}
@@ -219,16 +216,16 @@ export const ProjectProvider: React.FC<ProjectProviderProps> = ({
219216
args,
220217
);
221218

222-
let signers: string[] = []
219+
let signers: string[] = [];
223220

224221
signingAccounts?.map((acct: any) => {
225-
const addr = acct.address
226-
const acctNum = addr.charAt(addr.length - 1)
227-
const acctHex = `0x0${acctNum}`
228-
signers.push(acctHex)
229-
})
222+
const addr = acct.address;
223+
const acctNum = addr.charAt(addr.length - 1);
224+
const acctHex = `0x0${acctNum}`;
225+
signers.push(acctHex);
226+
});
230227

231-
setLastTxSigners(signers)
228+
setLastTxSigners(signers);
232229

233230
timeout = setTimeout(() => {
234231
setIsSaving(false);
@@ -313,7 +310,7 @@ export const ProjectProvider: React.FC<ProjectProviderProps> = ({
313310

314311
const params = getParams(location.search || '');
315312
const { type, id, storage: storageParam } = params;
316-
const storage = storageParam || 'none'
313+
const storage = storageParam || 'none';
317314

318315
// TODO: check if that project is local
319316
// TODO: check that active item have the same id

src/providers/Project/projectMutator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export default class ProjectMutator {
9090

9191
async saveProject(isFork: boolean) {
9292
if (this.isLocal) {
93-
console.log("IS LOCAL:", this.isLocal);
9493
await this.createProject();
9594
unregisterOnCloseSaveMessage();
9695
}

0 commit comments

Comments
 (0)