kopia lustrzana https://github.com/bugout-dev/moonstream
able to upload abi
rodzic
72b3e1f07f
commit
0b5a6ac188
|
@ -299,7 +299,7 @@ const NewDashboard = (props) => {
|
||||||
size="sm"
|
size="sm"
|
||||||
placeSelf="self-end"
|
placeSelf="self-end"
|
||||||
colorScheme={
|
colorScheme={
|
||||||
item.hasABI
|
item.abi
|
||||||
? "green"
|
? "green"
|
||||||
: "gray"
|
: "gray"
|
||||||
}
|
}
|
||||||
|
@ -383,10 +383,10 @@ const NewDashboard = (props) => {
|
||||||
)}
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td w="90px">
|
<Td w="90px">
|
||||||
{subscibedItem.hasABI && subscibedItem.address && (
|
{subscibedItem.abi && subscibedItem.address && (
|
||||||
<CheckCircleIcon color="green" />
|
<CheckCircleIcon color="green" />
|
||||||
)}
|
)}
|
||||||
{!subscibedItem.hasABI && (
|
{!subscibedItem.abi && (
|
||||||
<Button
|
<Button
|
||||||
colorScheme="orange"
|
colorScheme="orange"
|
||||||
size="xs"
|
size="xs"
|
||||||
|
@ -407,7 +407,7 @@ const NewDashboard = (props) => {
|
||||||
<Td w="60px">
|
<Td w="60px">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
isDisabled={
|
isDisabled={
|
||||||
!subscibedItem.address || !subscibedItem.hasABI
|
!subscibedItem.address || !subscibedItem.abi
|
||||||
}
|
}
|
||||||
isChecked={subscibedItem.isMethods}
|
isChecked={subscibedItem.isMethods}
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
|
@ -415,7 +415,7 @@ const NewDashboard = (props) => {
|
||||||
<Td w="60px">
|
<Td w="60px">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
isDisabled={
|
isDisabled={
|
||||||
!subscibedItem.address || !subscibedItem.hasABI
|
!subscibedItem.address || !subscibedItem.abi
|
||||||
}
|
}
|
||||||
isChecked={subscibedItem.isEvents}
|
isChecked={subscibedItem.isEvents}
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
|
|
|
@ -119,7 +119,10 @@ const SubscriptionsList = ({ emptyCTA }) => {
|
||||||
py={2}
|
py={2}
|
||||||
disabled={!subscription.address}
|
disabled={!subscription.address}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
overlay.toggleModal({ type: MODAL_TYPES.UPLOAD_ABI })
|
overlay.toggleModal({
|
||||||
|
type: MODAL_TYPES.UPLOAD_ABI,
|
||||||
|
props: { id: subscription.id },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Upload
|
Upload
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useContext, useEffect, useState } from "react";
|
||||||
import { Flex, ButtonGroup, Button, useToast, Spinner } from "@chakra-ui/react";
|
import { Flex, ButtonGroup, Button, useToast, Spinner } from "@chakra-ui/react";
|
||||||
import { modifySubscription } from "../core/services/subscriptions.service";
|
import { useSubscriptions } from "../core/hooks";
|
||||||
// import hljs from "highlight.js";
|
// import hljs from "highlight.js";
|
||||||
// import ReactQuill from "react-quill"; // ES6
|
// import ReactQuill from "react-quill"; // ES6
|
||||||
import AceEditor from "react-ace";
|
import AceEditor from "react-ace";
|
||||||
import "ace-builds/src-noconflict/theme-github";
|
import "ace-builds/src-noconflict/theme-github";
|
||||||
import "ace-builds/src-noconflict/mode-json";
|
import "ace-builds/src-noconflict/mode-json";
|
||||||
|
import OverlayContext from "../core/providers/OverlayProvider/context";
|
||||||
|
import { MODAL_TYPES } from "../core/providers/OverlayProvider/constants";
|
||||||
|
|
||||||
const ABIUPLoad = () => {
|
const ABIUPLoad = (props) => {
|
||||||
|
console.assert(props.id, "id not defined in ABI Upload");
|
||||||
|
const { updateSubscription } = useSubscriptions();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const [text, setText] = useState();
|
const [text, setText] = useState();
|
||||||
const [json, setJSON] = useState();
|
const [json, setJSON] = useState();
|
||||||
const [isSubmitting, setSubmitting] = useState(false);
|
const { toggleModal } = useContext(OverlayContext);
|
||||||
|
|
||||||
const handleVerify = (raw) => {
|
const handleVerify = (raw) => {
|
||||||
try {
|
try {
|
||||||
|
@ -32,6 +36,19 @@ const ABIUPLoad = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
updateSubscription.isSuccess && toggleModal({ type: MODAL_TYPES.OFF });
|
||||||
|
updateSubscription.isSuccess &&
|
||||||
|
toast({
|
||||||
|
id: "upload_abi_success",
|
||||||
|
description: "ABI was assigned to the subscription",
|
||||||
|
title: "Success!",
|
||||||
|
position: "bottom",
|
||||||
|
status: "success",
|
||||||
|
variant: "subtle",
|
||||||
|
});
|
||||||
|
}, [updateSubscription.isSuccess, toggleModal]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (json === false) {
|
if (json === false) {
|
||||||
const clearingInterval = setInterval(() => setJSON(), 200);
|
const clearingInterval = setInterval(() => setJSON(), 200);
|
||||||
|
@ -45,11 +62,14 @@ const ABIUPLoad = () => {
|
||||||
};
|
};
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (json) {
|
if (json) {
|
||||||
modifySubscription({ id: abi: json });
|
console.log("id:", props.id);
|
||||||
|
updateSubscription.mutate({
|
||||||
|
id: props.id,
|
||||||
|
abi: JSON.stringify(json),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("json", json);
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
// minH="420px"
|
// minH="420px"
|
||||||
|
@ -65,7 +85,7 @@ const ABIUPLoad = () => {
|
||||||
borderWidth={json === false ? "1px" : "0px"}
|
borderWidth={json === false ? "1px" : "0px"}
|
||||||
transition="0.1s"
|
transition="0.1s"
|
||||||
>
|
>
|
||||||
{isSubmitting && (
|
{updateSubscription.isLoading && (
|
||||||
<Spinner position="absolute" top="50%" left="50%" zIndex={1} />
|
<Spinner position="absolute" top="50%" left="50%" zIndex={1} />
|
||||||
)}
|
)}
|
||||||
{/* ABI HERE PLEASE: */}
|
{/* ABI HERE PLEASE: */}
|
||||||
|
@ -79,13 +99,13 @@ const ABIUPLoad = () => {
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
name="AbiUploadField"
|
name="AbiUploadField"
|
||||||
editorProps={{ $blockScrolling: false }}
|
editorProps={{ $blockScrolling: false }}
|
||||||
readOnly={isSubmitting}
|
readOnly={updateSubscription.isLoading}
|
||||||
showGutter={true}
|
showGutter={true}
|
||||||
/>
|
/>
|
||||||
{/* <Divider /> */}
|
{/* <Divider /> */}
|
||||||
<ButtonGroup pt={2} placeContent="flex-end">
|
<ButtonGroup pt={2} placeContent="flex-end">
|
||||||
<Button
|
<Button
|
||||||
isLoading={isSubmitting}
|
isLoading={updateSubscription.isLoading}
|
||||||
onClick={() => setJSON(handleVerify(text))}
|
onClick={() => setJSON(handleVerify(text))}
|
||||||
transition="0.3s"
|
transition="0.3s"
|
||||||
colorScheme={json ? "green" : json === false ? "red" : "blue"}
|
colorScheme={json ? "green" : json === false ? "red" : "blue"}
|
||||||
|
@ -93,7 +113,7 @@ const ABIUPLoad = () => {
|
||||||
Verify
|
Verify
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
isLoading={isSubmitting}
|
isLoading={updateSubscription.isLoading}
|
||||||
disabled={!json}
|
disabled={!json}
|
||||||
onClick={() => handleSubmit()}
|
onClick={() => handleSubmit()}
|
||||||
transition="0.3s"
|
transition="0.3s"
|
||||||
|
|
|
@ -11,9 +11,11 @@ const useToast = () => {
|
||||||
const userTitle = title ?? message?.response?.statusText ?? type;
|
const userTitle = title ?? message?.response?.statusText ?? type;
|
||||||
|
|
||||||
const userMessage =
|
const userMessage =
|
||||||
message?.response?.data?.detail ??
|
message?.response?.data?.detail ?? typeof message === "string"
|
||||||
message ??
|
? message
|
||||||
(userTitle === type ? "" : type);
|
: userTitle === type
|
||||||
|
? ""
|
||||||
|
: type;
|
||||||
|
|
||||||
if (mixpanel.get_distinct_id() && type === "error") {
|
if (mixpanel.get_distinct_id() && type === "error") {
|
||||||
mixpanel.track(`${MIXPANEL_EVENTS.TOAST_ERROR_DISPLAYED}`, {
|
mixpanel.track(`${MIXPANEL_EVENTS.TOAST_ERROR_DISPLAYED}`, {
|
||||||
|
@ -24,11 +26,12 @@ const useToast = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
chakraToast({
|
chakraToast({
|
||||||
|
id: `${userTitle}${userMessage}${type}`,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
title: userTitle,
|
title: userTitle,
|
||||||
description: userMessage,
|
description: userMessage,
|
||||||
status: type,
|
status: type,
|
||||||
duration: 3000,
|
// duration: 3000,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[chakraToast]
|
[chakraToast]
|
||||||
|
|
Ładowanie…
Reference in New Issue