Skip to content

Commit

Permalink
Improve publish reliability (#2202)
Browse files Browse the repository at this point in the history
* Take name out of the object

* All of this makes sense to me
  • Loading branch information
nachoiacovino authored Feb 12, 2024
1 parent 538c2b8 commit 157f3cd
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ export const LandingFieldset: React.FC<LandingFieldsetProps> = ({
<TabPanels pt={2}>
<TabPanel px={0} pb={0}>
<Textarea
value={form.watch("readme")}
onChange={(e) => form.setValue("readme", e.target.value)}
{...form.register("readme")}
rows={12}
placeholder="Describe how users can use this contract. Add links if relevant."
/>
Expand Down Expand Up @@ -209,8 +208,8 @@ export const LandingFieldset: React.FC<LandingFieldsetProps> = ({
)}
</Flex>
<Input
value={form.watch("version")}
placeholder={placeholderVersion}
value={form.watch("version")}
onChange={handleVersionChange}
/>
<FormErrorMessage>
Expand All @@ -236,10 +235,7 @@ export const LandingFieldset: React.FC<LandingFieldsetProps> = ({
<TabPanels pt={2}>
<TabPanel px={0} pb={0}>
<Textarea
value={form.watch("changelog")}
onChange={(e) =>
form.setValue("changelog", e.target.value)
}
{...form.register("changelog")}
placeholder="Mention what is new in this version of your contract."
/>
<FormErrorMessage>
Expand Down
5 changes: 3 additions & 2 deletions contract-ui/components/solidity-inputs/address-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const SolidityAddressInput: React.FC<SolidityInputProps> = ({
formContext: form,
...inputProps
}) => {
const inputName = inputProps.name as string;
const { name, ...restOfInputProps } = inputProps;
const inputName = name as string;
const inputNameWatch = form.watch(inputName);
const [localInput, setLocalInput] = useState(inputNameWatch);
const address = useAddress();
Expand Down Expand Up @@ -98,7 +99,7 @@ export const SolidityAddressInput: React.FC<SolidityInputProps> = ({
placeholder="address"
// probably OK but obviously can be longer if ens name is passed?
maxLength={42}
{...inputProps}
{...restOfInputProps}
onChange={(e) => handleChange(e.target.value)}
// if we don't have a value from the form, use the local input (but if value is empty string then that's valid)
value={(localInput ?? inputNameWatch) || ""}
Expand Down
12 changes: 4 additions & 8 deletions contract-ui/components/solidity-inputs/array-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ export const SolidityArrayInput: React.FC<SolidityInputWithTypeProps> = ({
solidityType,
...inputProps
}) => {
const inputName = inputProps.name as string;
const { name, ...restOfInputProps } = inputProps;
const inputName = name as string;
const [showRawInput, setShowRawInput] = useState(false);
const localForm = useForm({ defaultValues: { array: [{ value: "" }] } });
const { fields, append, remove } = useFieldArray({
name: "array",
control: localForm.control,
});

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const val = e.target.value;
form.setValue(inputName, val);
};

const typeWithoutArray = solidityType.replace("[]", "");

if (showRawInput) {
Expand All @@ -34,8 +30,8 @@ export const SolidityArrayInput: React.FC<SolidityInputWithTypeProps> = ({
<SolidityRawInput
formContext={form}
solidityType={solidityType}
{...inputProps}
onChange={handleChange}
{...restOfInputProps}
name={inputName}
/>
<Text
size="label.sm"
Expand Down
3 changes: 2 additions & 1 deletion contract-ui/components/solidity-inputs/bool-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export const SolidityBoolInput: React.FC<SolidityInputProps> = ({
formContext: form,
...inputProps
}) => {
const inputName = inputProps.name as string;
const { name } = inputProps;
const inputName = name as string;
const watchInput = form.watch(inputName);
return (
<Flex>
Expand Down
10 changes: 8 additions & 2 deletions contract-ui/components/solidity-inputs/bytes-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const SolidityBytesInput: React.FC<SolidityInputWithTypeProps> = ({
solidityType,
...inputProps
}) => {
const inputName = inputProps.name as string;
const { name, ...restOfInputProps } = inputProps;
const inputName = name as string;

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { value } = e.target;
Expand All @@ -23,6 +24,11 @@ export const SolidityBytesInput: React.FC<SolidityInputWithTypeProps> = ({
};

return (
<Input placeholder={solidityType} {...inputProps} onChange={handleChange} />
<Input
placeholder={solidityType}
{...restOfInputProps}
value={form.watch(inputName)}
onChange={handleChange}
/>
);
};
5 changes: 3 additions & 2 deletions contract-ui/components/solidity-inputs/int-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const SolidityIntInput: React.FC<SolidityInputWithTypeProps> = ({
solidityType,
...inputProps
}) => {
const inputName = inputProps.name as string;
const { name, ...restOfInputProps } = inputProps;
const inputName = name as string;

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { value } = e.target;
Expand Down Expand Up @@ -49,7 +50,7 @@ export const SolidityIntInput: React.FC<SolidityInputWithTypeProps> = ({
<InputGroup>
<Input
placeholder={solidityType}
{...inputProps}
{...restOfInputProps}
value={form.watch(inputName)}
onChange={handleChange}
/>
Expand Down
7 changes: 4 additions & 3 deletions contract-ui/components/solidity-inputs/raw-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export const SolidityRawInput: React.FC<SolidityInputWithTypeProps> = ({
solidityComponents,
...inputProps
}) => {
const inputName = inputProps.name as string;
const { name, ...restOfInputProps } = inputProps;
const inputName = name as string;

const typeWithoutArray = solidityType.replace("[]", "");

const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const { value } = e.target;

form.setValue(inputName, value);

const invalidInputError = {
Expand Down Expand Up @@ -50,7 +51,7 @@ export const SolidityRawInput: React.FC<SolidityInputWithTypeProps> = ({
<Textarea
fontFamily="mono"
placeholder={solidityType}
{...(inputProps as TextareaProps)}
{...(restOfInputProps as TextareaProps)}
value={form.watch(inputName)}
onChange={handleChange}
/>
Expand Down
7 changes: 4 additions & 3 deletions contract-ui/components/solidity-inputs/string-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const SolidityStringInput: React.FC<SolidityInputWithTypeProps> = ({
}) => {
const storageUpload = useStorageUpload();
const queryClient = useQueryClient();
const inputName = inputProps.name as string;
const { name, ...restOfInputProps } = inputProps;
const inputName = name as string;
const nameOrInput = (solidityName as string) || inputName;

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand All @@ -33,10 +34,10 @@ export const SolidityStringInput: React.FC<SolidityInputWithTypeProps> = ({
<Input
placeholder="string"
isDisabled={storageUpload.isLoading}
pr={{ base: "90px", md: "160px" }}
{...restOfInputProps}
value={form.watch(inputName)}
{...inputProps}
onChange={handleChange}
pr={{ base: "90px", md: "160px" }}
/>
{showButton && (
<InputRightElement mx={1} width={{ base: "75px", md: "145px" }}>
Expand Down
6 changes: 4 additions & 2 deletions contract-ui/components/solidity-inputs/tuple-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const SolidityTupleInput: React.FC<SolidityInputWithTypeProps> = ({
solidityComponents,
...inputProps
}) => {
const inputName = inputProps.name as string;
const { name, ...restOfInputProps } = inputProps;
const inputName = name as string;

const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const { value } = e.target;
Expand Down Expand Up @@ -52,7 +53,8 @@ export const SolidityTupleInput: React.FC<SolidityInputWithTypeProps> = ({
<Textarea
fontFamily="mono"
placeholder={solidityType}
{...(inputProps as TextareaProps)}
{...(restOfInputProps as TextareaProps)}
value={form.watch(inputName)}
onChange={handleChange}
/>
<FormHelperText>
Expand Down

0 comments on commit 157f3cd

Please sign in to comment.