Skip to content

Commit

Permalink
feat: update abi after pasting
Browse files Browse the repository at this point in the history
  • Loading branch information
xtools-at committed Oct 22, 2023
1 parent 0337366 commit e18da87
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions components/SourceBrowser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ export const SourceBrowser = ({
}
}, [chain, address]);

const onAbiChange = useCallback(async () => {
if (source.startsWith("http") || source.startsWith("/")) {
onUrlChange(source);
} else {
try {
const jsonContent = JSON.parse(source);
onJsonChange(jsonContent);
} catch (err) {
onError(err);
}
}
}, [source]);

return (
<>
<TextField
Expand Down Expand Up @@ -197,18 +210,10 @@ export const SourceBrowser = ({
}}
onKeyUp={(event) => {
if (event.key === "Enter") {
if (source.startsWith("http")) {
onUrlChange(source);
} else {
try {
const jsonContent = JSON.parse(source);
onJsonChange(jsonContent);
} catch (err) {
onError(err);
}
}
onAbiChange();
}
}}
onBlur={onAbiChange}
fullWidth
id="file"
label="ABI"
Expand Down

0 comments on commit e18da87

Please sign in to comment.