Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
iainnash committed Jan 30, 2024
1 parent b9639b6 commit d30442a
Show file tree
Hide file tree
Showing 16 changed files with 2,804 additions and 72 deletions.
2,744 changes: 2,741 additions & 3 deletions src/app.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/app/CreateSafe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function CreateSafe() {
const address = await signer.getAddress();
setSignerInfo({ signer, address });
},
[setSignerInfo]
[setSignerInfo],
);

useEffect(() => {
Expand Down Expand Up @@ -86,7 +86,7 @@ export function CreateSafe() {
});
}
},
[provider, signerInfo]
[provider, signerInfo],
);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/app/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const Error = () => {
return <div>ERR</div>
}
return <div>ERR</div>;
};
6 changes: 3 additions & 3 deletions src/app/NewSafeProposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ const EditProposal = ({
}
setIsEditing(false);
},
[setIsEditing, setProposal]
[setIsEditing, setProposal],
);

const defaultActions = proposal || DEFAULT_PROPOSAL;
Expand Down Expand Up @@ -444,7 +444,7 @@ const EditProposal = ({

export const NewSafeProposal = () => {
const [proposal, setProposal] = useState<undefined | Proposal>(
DEFAULT_PROPOSAL
DEFAULT_PROPOSAL,
);
const [isEditing, setIsEditing] = useState(true);

Expand All @@ -462,7 +462,7 @@ export const NewSafeProposal = () => {
setIsEditing(true);
evt.preventDefault();
},
[setIsEditing]
[setIsEditing],
);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/app/ViewSafe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const ViewSafe = () => {
const setupSafe = useCallback(async () => {
if (params.safeAddress && providerContext) {
setSafeData(
await getSafeSDK(params.safeAddress, await providerContext.getSigner())
await getSafeSDK(params.safeAddress, await providerContext.getSigner()),
);
}
}, [params.safeAddress, providerContext]);
Expand Down
2 changes: 1 addition & 1 deletion src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Object.keys(contractNetworks).map((network) => {
return;
}
const viemChain = Object.values(chains).find(
(chain) => chain.id.toString() === network
(chain) => chain.id.toString() === network,
);

if (!viemChain) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/DataActionPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ export const DataActionPreview = ({ to, data }: { to: Address; data: Hex }) => {
let json;
try {
const response = await fetch(
`https://${networkToEtherActor[Number(currentNetwork)]}.ether.actor/decode/${to}/${data}`
`https://${networkToEtherActor[Number(currentNetwork)]}.ether.actor/decode/${to}/${data}`,
);
if (!response.ok) {
throw new Error();
}
json = await response.json();
} catch (err: any) {

const response = await fetch(`https://ether.actor/decode/${data}`);
json = await response.json();
}
Expand Down
8 changes: 1 addition & 7 deletions src/components/InfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import { Info } from "react-feather";
export const InfoBox = ({ children }: { children: React.ReactNode }) => {
return (
<Tooltip text={children}>
{(attributes) => (
<Icon
size={4}
attributes={attributes}
svg={<Info />}
/>
)}
{(attributes) => <Icon size={4} attributes={attributes} svg={<Info />} />}
</Tooltip>
);
};
2 changes: 1 addition & 1 deletion src/components/NetworkSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const NetworkSwitcher = ({
},
]);
},
[provider]
[provider],
);

useEffect(() => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/SetOwnerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ const AddOwnerModalContent = ({ onClose }: { onClose: () => void }) => {
],
}),
});

} catch (err: any) {
toast.show({title: "Error Updating Safe", text: err.toString()});
toast.show({ title: "Error Updating Safe", text: err.toString() });
}
onClose();
}}
Expand Down
56 changes: 28 additions & 28 deletions src/hooks/useLoadProposalFromQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ import { useSearchParams } from "react-router-dom";
import { Proposal } from "../schemas/proposal";

export const useLoadProposalFromQuery = () => {
const [proposal, setProposal] = useState<undefined | Proposal>();
const [params] = useSearchParams();

useEffect(() => {
const targets = params.get("targets")?.split("|");
const calldatas = params.get("calldatas")?.split("|");
const values = params.get("values")?.split("|");
if (targets && calldatas) {
// ensure the 3 lengths are the same. check if values also has the same length if its not empty
// check the inverse of the above, if inverse is true, return:
if (
targets.length !== calldatas.length ||
(values?.length && values?.length !== targets.length)
) {
console.log("invalid lengths");
return;
}

const actions = targets.map((target, index) => ({
to: target,
data: calldatas[index]!,
value: (values && values[index]) || "0",
}));
setProposal({ actions });
const [proposal, setProposal] = useState<undefined | Proposal>();
const [params] = useSearchParams();

useEffect(() => {
const targets = params.get("targets")?.split("|");
const calldatas = params.get("calldatas")?.split("|");
const values = params.get("values")?.split("|");
if (targets && calldatas) {
// ensure the 3 lengths are the same. check if values also has the same length if its not empty
// check the inverse of the above, if inverse is true, return:
if (
targets.length !== calldatas.length ||
(values?.length && values?.length !== targets.length)
) {
console.log("invalid lengths");
return;
}
}, [params, setProposal]);

return proposal;
};

const actions = targets.map((target, index) => ({
to: target,
data: calldatas[index]!,
value: (values && values[index]) || "0",
}));
setProposal({ actions });
}
}, [params, setProposal]);

return proposal;
};
23 changes: 13 additions & 10 deletions src/hooks/useSetParamsFromQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import { useSearchParams } from "react-router-dom";
import { Proposal } from "../schemas/proposal";

export const useSetParamsFromQuery = () => {
const [_, setParams] = useSearchParams();

return useCallback((proposal: Proposal) => {
const [_, setParams] = useSearchParams();

return useCallback(
(proposal: Proposal) => {
if (!proposal.actions?.length) {
return;
}
console.log('setting params', proposal.actions);
console.log("setting params", proposal.actions);
setParams({
targets: proposal.actions!.map((action) => action.to).join('|'),
data: proposal.actions!.map((action) => action.data).join('|'),
value: proposal.actions!.map((action) => action.value).join('|'),
})
}, [setParams]);
}
targets: proposal.actions!.map((action) => action.to).join("|"),
data: proposal.actions!.map((action) => action.data).join("|"),
value: proposal.actions!.map((action) => action.value).join("|"),
});
},
[setParams],
);
};
6 changes: 3 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { Wrapper } from "./app/Wrapper";
import "reshaped/themes/reshaped/theme.css";
import { Buffer } from 'buffer'
globalThis.Buffer = Buffer
import { Buffer } from "buffer";
globalThis.Buffer = Buffer;

const container = document.getElementById("app");
const root = createRoot(container!);
root.render(
<StrictMode>
<Wrapper />
</StrictMode>
</StrictMode>,
);
6 changes: 3 additions & 3 deletions src/schemas/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ export const proposalSchema = object({
.default("0")
.matches(
/^[0-9]+(\.[0-9]+)?$/,
"Needs to be a ETH price (0, 1, or 0.23)"
"Needs to be a ETH price (0, 1, or 0.23)",
)
.required(),
data: string()
.default("0x")
.matches(
/^0x(?:[0-9A-Za-z][0-9A-Za-z])*$/,
"Data is required to match hex format"
"Data is required to match hex format",
)
.required(),
})
}),
),
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const get = (obj: any, path: string, defValue?: any) => {
// Find value
const result = pathArray.reduce(
(prevObj, key) => prevObj && prevObj[key],
obj
obj,
);
// If found value is undefined return default value; otherwise return the value
return result === undefined ? defValue : result;
Expand Down
5 changes: 2 additions & 3 deletions src/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const validateETH = (value: string) => {
}
};


export const yupAddress = string()
.matches(/^0x[a-fA-F0-9]{40}$/, "Needs to be a valid address")
.required()
.matches(/^0x[a-fA-F0-9]{40}$/, "Needs to be a valid address")
.required();

0 comments on commit d30442a

Please sign in to comment.