Skip to content

Commit

Permalink
fix: build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yvesfracari committed Aug 2, 2023
1 parent 9e1834c commit 8133458
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const pin = async (json: Record<string, string>) => {
new Blob([JSON.stringify(json)], {
type: "application/json",
}),
"metadata.json",
"metadata.json"
);

const projectId = process.env.INFURA_IPFS_PROJECT_ID;
Expand All @@ -18,15 +18,14 @@ const pin = async (json: Record<string, string>) => {
method: "POST",
headers: {
Authorization: `Basic ${Buffer.from(
`${projectId}:${projectSecret}`,
`${projectId}:${projectSecret}`
).toString("base64")}`,
},
body: formData,
})
.then((res) => res.json())
.then((res) => res.Hash as string)
.catch((error) => {
console.error(error);
return { error: error };
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ const inputMapper = {
label: "Swap Fee",
placeholder: "Enter swap fee",
unit: "%",
transformFromDataToForm: (n) => (n ? n * 100 : undefined),
transformFromFormToData: (n) => (n ? n / 100 : undefined),
transformFromDataToForm: (n?: number) => (n ? n * 100 : undefined),
transformFromFormToData: (n?: number) => (n ? n / 100 : undefined),
},
{
name: "ampFactor",
label: "Amplification Factor",
placeholder: "Enter amplification factor",
unit: "",
transformFromDataToForm: (n) => n,
transformFromFormToData: (n) => n,
transformFromDataToForm: (n?: number) => n,
transformFromFormToData: (n?: number) => n,
},
],
[PoolTypeEnum.GyroE]: [
Expand All @@ -45,61 +45,61 @@ const inputMapper = {
label: "Swap Fee",
placeholder: "Enter swap fee",
unit: "%",
transformFromDataToForm: (n) => (n ? n * 100 : undefined),
transformFromFormToData: (n) => (n ? n / 100 : undefined),
transformFromDataToForm: (n?: number) => (n ? n * 100 : undefined),
transformFromFormToData: (n?: number) => (n ? n / 100 : undefined),
},
{
name: "alpha",
label: "Alpha",
placeholder: "Enter alpha",
unit: "",
transformFromDataToForm: (n) => n,
transformFromFormToData: (n) => n,
transformFromDataToForm: (n?: number) => n,
transformFromFormToData: (n?: number) => n,
},
{
name: "beta",
label: "Beta",
placeholder: "Enter beta",
unit: "",
transformFromDataToForm: (n) => n,
transformFromFormToData: (n) => n,
transformFromDataToForm: (n?: number) => n,
transformFromFormToData: (n?: number) => n,
},
{
name: "lambda",
label: "Lambda",
placeholder: "Enter lambda",
unit: "",
transformFromDataToForm: (n) => n,
transformFromFormToData: (n) => n,
transformFromDataToForm: (n?: number) => n,
transformFromFormToData: (n?: number) => n,
},
{
name: "c",
label: "C",
placeholder: "Enter c",
unit: "",
transformFromDataToForm: (n) => n,
transformFromFormToData: (n) => n,
transformFromDataToForm: (n?: number) => n,
transformFromFormToData: (n?: number) => n,
},
{
name: "s",
label: "S",
placeholder: "Enter s",
unit: "",
transformFromDataToForm: (n) => n,
transformFromFormToData: (n) => n,
transformFromDataToForm: (n?: number) => n,
transformFromFormToData: (n?: number) => n,
},
],
} as const;

const createPayload = (
poolType: keyof typeof inputMapper,
fieldData: FieldValues,
fieldData: FieldValues
): AnalysisData => ({
poolParams: Object.fromEntries(
inputMapper[poolType].map((input) => [
input.name,
input.transformFromFormToData(fieldData[input.name]),
]),
])
),
tokens: fieldData.tokens,
poolType: poolType,
Expand Down Expand Up @@ -131,7 +131,7 @@ export const PoolParamsForm = forwardRef<unknown, PoolParamsFormProps>(

useImperativeHandle(ref, () => ({
triggerValidation: () => {
trigger(); // Calls validation
trigger();
},
}));

Expand Down Expand Up @@ -166,10 +166,6 @@ export const PoolParamsForm = forwardRef<unknown, PoolParamsFormProps>(
onTabChanged(createPayload(poolType, data));
}, [currentTab]);

// useEffect(()=> {
// if (errors.length) {setChangeTabAllowed(false)} else {setChangeTabAllowed(true)}
// },[errors])

return (
<Form
{...form}
Expand All @@ -192,7 +188,7 @@ export const PoolParamsForm = forwardRef<unknown, PoolParamsFormProps>(
value: data.poolParams?.[input.name],
}}
defaultValue={input.transformFromDataToForm(
data.poolParams?.[input.name],
data.poolParams?.[input.name]
)}
placeholder={input.placeholder}
/>
Expand Down Expand Up @@ -223,5 +219,5 @@ export const PoolParamsForm = forwardRef<unknown, PoolParamsFormProps>(
</div>
</Form>
);
},
}
);
5 changes: 3 additions & 2 deletions apps/balancer-tools/src/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ type TabContextType<T> = {
setValue: (value: T) => void;
};

// tslint:disable-next-line: no-any
const TabContext = createContext<TabContextType<any> | undefined>(undefined);

export function useTabContext<T>() {
const context = useContext<TabContextType<T> | undefined>(TabContext);

if (!context) {
throw new Error(
"Child components of Tab cannot be rendered outside the Tab component!",
"Child components of Tab cannot be rendered outside the Tab component!"
);
}

Expand Down Expand Up @@ -86,7 +87,7 @@ function TabItemTrigger({
return (
<TabsPrimitive.Trigger
className={cn(
"px-5 h-[45px] flex-1 flex items-center justify-center text-[15px] hover:text-white hover:bg-blue4 data-[state=active]:text-white outline-none cursor-defaul} data-[state=active]:shadow-[inset_0_-1px_0_0,0_1px_0_0]",
"px-5 h-[45px] flex-1 flex items-center justify-center text-[15px] hover:text-white hover:bg-blue4 data-[state=active]:text-white outline-none cursor-defaul} data-[state=active]:shadow-[inset_0_-1px_0_0,0_1px_0_0]"
)}
value={tabName}
onClick={(e) => {
Expand Down

0 comments on commit 8133458

Please sign in to comment.