Compare commits

..

13 Commits

Author SHA1 Message Date
muzam1l
b08b66529c Fix split error 2022-07-05 17:31:49 +05:30
Valtteri Karesto
3af2bad536 Make ping interval longer (#232)
* Make ping interval 45s

Co-authored-by: Vaclav Barta <vbarta@mangrove.cz>
2022-07-04 12:22:06 +02:00
muzamil
0289d64f5e Merge pull request #233 from XRPLF/fix/tab-names
Fix tab names
2022-07-01 19:29:33 +05:30
muzamil
868a0bcf78 Merge pull request #234 from XRPLF/feat/account-in-deploy-dialog
Add account selectable in deploy dialog.
2022-07-01 18:51:04 +05:30
muzam1l
aab2476a05 Add account selectable in deploy dialog. 2022-07-01 18:06:01 +05:30
muzam1l
cb25986d72 update transaction tab labels 2022-07-01 17:30:57 +05:30
muzam1l
309ad57173 Skip auto appneding test file extension. 2022-07-01 17:26:10 +05:30
Valtteri Karesto
25c5b9c015 Merge pull request #229 from XRPLF/feat/links-to-explorer
Link from hashes/addresses to Hook Explorer
2022-06-30 15:40:57 +03:00
Valtteri Karesto
407e3946ce Added underline on hover to links 2022-06-30 15:30:43 +03:00
Valtteri Karesto
dc5b0d71eb Simplified hook state, since endpoint now works with hookhashes 2022-06-30 08:54:43 +03:00
Valtteri Karesto
3fd6c3f50e Remove debug code 2022-06-29 18:03:26 +03:00
Valtteri Karesto
ec8bfc5eee Add links to account modal 2022-06-29 15:26:33 +03:00
Valtteri Karesto
b4a0bcb90d Merge pull request #227 from XRPLF/feat/remember-deploy-values
Remember deploy values / Add feedback button
2022-06-29 14:08:47 +03:00
6 changed files with 88 additions and 33 deletions

View File

@@ -116,9 +116,16 @@ export const AccountDialog = ({
<Text <Text
css={{ css={{
fontFamily: "$monospace", fontFamily: "$monospace",
a: { "&:hover": { textDecoration: "underline" } },
}} }}
>
<a
href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${activeAccount?.address}`}
target="_blank"
rel="noopener noreferrer"
> >
{activeAccount?.address} {activeAccount?.address}
</a>
</Text> </Text>
</Flex> </Flex>
<Flex css={{ marginLeft: "auto", color: "$mauve12" }}> <Flex css={{ marginLeft: "auto", color: "$mauve12" }}>
@@ -215,7 +222,11 @@ export const AccountDialog = ({
</Button> </Button>
</Text> </Text>
</Flex> </Flex>
<Flex css={{ marginLeft: "auto" }}> <Flex
css={{
marginLeft: "auto",
}}
>
<a <a
href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${activeAccount?.address}`} href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${activeAccount?.address}`}
target="_blank" target="_blank"
@@ -237,10 +248,22 @@ export const AccountDialog = ({
<Text <Text
css={{ css={{
fontFamily: "$monospace", fontFamily: "$monospace",
a: { "&:hover": { textDecoration: "underline" } },
}} }}
> >
{activeAccount && activeAccount.hooks.length > 0 {activeAccount && activeAccount.hooks.length > 0
? activeAccount.hooks.map((i) => truncate(i, 12)).join(",") ? activeAccount.hooks.map((i) => {
return (
<a
key={i}
href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${i}`}
target="_blank"
rel="noopener noreferrer"
>
{truncate(i, 12)}
</a>
);
})
: ""} : ""}
</Text> </Text>
</Flex> </Flex>

View File

@@ -87,7 +87,7 @@ const addListeners = (account: ISelect | null) => {
if (streamState.socket) { if (streamState.socket) {
interval = setInterval(() => { interval = setInterval(() => {
streamState.socket?.send(""); streamState.socket?.send("");
}, 10000); }, 45000);
} }
streamState.socket.addEventListener("open", () => onOpen(account)); streamState.socket.addEventListener("open", () => onOpen(account));

View File

@@ -22,12 +22,12 @@ import {
import { TTS, tts } from "../utils/hookOnCalculator"; import { TTS, tts } from "../utils/hookOnCalculator";
import { deployHook } from "../state/actions"; import { deployHook } from "../state/actions";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import state from "../state"; import state, { SelectOption } from "../state";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { prepareDeployHookTx, sha256 } from "../state/actions/deployHook"; import { prepareDeployHookTx, sha256 } from "../state/actions/deployHook";
import estimateFee from "../utils/estimateFee"; import estimateFee from "../utils/estimateFee";
const transactionOptions = Object.keys(tts).map((key) => ({ const transactionOptions = Object.keys(tts).map(key => ({
label: key, label: key,
value: key as keyof TTS, value: key as keyof TTS,
})); }));
@@ -56,11 +56,22 @@ export type SetHookData = {
export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo( export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
({ accountAddress }) => { ({ accountAddress }) => {
const snap = useSnapshot(state); const snap = useSnapshot(state);
const account = snap.accounts.find((acc) => acc.address === accountAddress);
const activeFile = snap.files[snap.active]?.compiledContent const activeFile = snap.files[snap.active]?.compiledContent
? snap.files[snap.active] ? snap.files[snap.active]
: snap.files.filter((file) => file.compiledContent)[0]; : snap.files.filter(file => file.compiledContent)[0];
const [isSetHookDialogOpen, setIsSetHookDialogOpen] = useState(false); const [isSetHookDialogOpen, setIsSetHookDialogOpen] = useState(false);
const accountOptions: SelectOption[] = snap.accounts.map(acc => ({
label: acc.name,
value: acc.address,
}));
const [selectedAccount, setSelectedAccount] = useState(
accountOptions.find(acc => acc.value === accountAddress)
);
const account = snap.accounts.find(
acc => acc.address === selectedAccount?.value
);
const { const {
register, register,
handleSubmit, handleSubmit,
@@ -75,7 +86,7 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
: { : {
HookNamespace: HookNamespace:
snap.files?.[snap.activeWat]?.name?.split(".")?.[0] || "", snap.files?.[snap.activeWat]?.name?.split(".")?.[0] || "",
Invoke: transactionOptions.filter((to) => to.label === "ttPAYMENT"), Invoke: transactionOptions.filter(to => to.label === "ttPAYMENT"),
}, },
}); });
const { fields, append, remove } = useFieldArray({ const { fields, append, remove } = useFieldArray({
@@ -149,14 +160,10 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [formInitialized]); }, [formInitialized]);
if (!account) {
return null;
}
const tooLargeFile = () => { const tooLargeFile = () => {
const activeFile = snap.files[snap.active].compiledContent const activeFile = snap.files[snap.active].compiledContent
? snap.files[snap.active] ? snap.files[snap.active]
: snap.files.filter((file) => file.compiledContent)[0]; : snap.files.filter(file => file.compiledContent)[0];
return Boolean( return Boolean(
activeFile?.compiledContent?.byteLength && activeFile?.compiledContent?.byteLength &&
activeFile?.compiledContent?.byteLength >= 64000 activeFile?.compiledContent?.byteLength >= 64000
@@ -165,8 +172,9 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
const onSubmit: SubmitHandler<SetHookData> = async (data) => { const onSubmit: SubmitHandler<SetHookData> = async (data) => {
const currAccount = state.accounts.find( const currAccount = state.accounts.find(
(acc) => acc.address === account.address (acc) => acc.address === account?.address
); );
if (!account) return;
if (currAccount) currAccount.isLoading = true; if (currAccount) currAccount.isLoading = true;
const res = await deployHook(account, data); const res = await deployHook(account, data);
if (currAccount) currAccount.isLoading = false; if (currAccount) currAccount.isLoading = false;
@@ -186,8 +194,9 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
uppercase uppercase
variant={"secondary"} variant={"secondary"}
disabled={ disabled={
!account ||
account.isLoading || account.isLoading ||
!snap.files.filter((file) => file.compiledWatContent).length || !snap.files.filter(file => file.compiledWatContent).length ||
tooLargeFile() tooLargeFile()
} }
> >
@@ -199,6 +208,17 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
<DialogTitle>Deploy configuration</DialogTitle> <DialogTitle>Deploy configuration</DialogTitle>
<DialogDescription as="div"> <DialogDescription as="div">
<Stack css={{ width: "100%", flex: 1 }}> <Stack css={{ width: "100%", flex: 1 }}>
<Box css={{ width: "100%" }}>
<Label>Account</Label>
<Select
instanceId="deploy-account"
placeholder="Select account"
hideSelectedOptions
options={accountOptions}
value={selectedAccount}
onChange={(acc: any) => setSelectedAccount(acc)}
/>
</Box>
<Box css={{ width: "100%" }}> <Box css={{ width: "100%" }}>
<Label>Invoke on transactions</Label> <Label>Invoke on transactions</Label>
<Controller <Controller
@@ -282,7 +302,7 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
type="number" type="number"
{...register("Fee", { required: true })} {...register("Fee", { required: true })}
autoComplete={"off"} autoComplete={"off"}
onKeyPress={(e) => { onKeyPress={e => {
if (e.key === "." || e.key === ",") { if (e.key === "." || e.key === ",") {
e.preventDefault(); e.preventDefault();
} }
@@ -314,8 +334,9 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
alignContent: "center", alignContent: "center",
display: "flex", display: "flex",
}} }}
onClick={async (e) => { onClick={async e => {
e.preventDefault(); e.preventDefault();
if (!account) return;
setEstimateLoading(true); setEstimateLoading(true);
const formValues = getValues(); const formValues = getValues();
try { try {
@@ -414,7 +435,7 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
<Button <Button
variant="primary" variant="primary"
type="submit" type="submit"
isLoading={account.isLoading} isLoading={account?.isLoading}
> >
Set Hook Set Hook
</Button> </Button>

View File

@@ -31,13 +31,15 @@ interface TabProps {
// TODO customise messages shown // TODO customise messages shown
interface Props { interface Props {
label?: string;
activeIndex?: number; activeIndex?: number;
activeHeader?: string; activeHeader?: string;
headless?: boolean; headless?: boolean;
children: ReactElement<TabProps>[]; children: ReactElement<TabProps>[];
keepAllAlive?: boolean; keepAllAlive?: boolean;
defaultExtension?: string; defaultExtension?: string;
forceDefaultExtension?: boolean; appendDefaultExtension?: boolean;
allowedExtensions?: string[];
onCreateNewTab?: (name: string) => any; onCreateNewTab?: (name: string) => any;
onCloseTab?: (index: number, header?: string) => any; onCloseTab?: (index: number, header?: string) => any;
onChangeActive?: (index: number, header?: string) => any; onChangeActive?: (index: number, header?: string) => any;
@@ -46,6 +48,7 @@ interface Props {
export const Tab = (props: TabProps) => null; export const Tab = (props: TabProps) => null;
export const Tabs = ({ export const Tabs = ({
label = "Tab",
children, children,
activeIndex, activeIndex,
activeHeader, activeHeader,
@@ -55,7 +58,8 @@ export const Tabs = ({
onCloseTab, onCloseTab,
onChangeActive, onChangeActive,
defaultExtension = "", defaultExtension = "",
forceDefaultExtension, appendDefaultExtension = false,
allowedExtensions,
}: Props) => { }: Props) => {
const [active, setActive] = useState(activeIndex || 0); const [active, setActive] = useState(activeIndex || 0);
const tabs: TabProps[] = children.map(elem => elem.props); const tabs: TabProps[] = children.map(elem => elem.props);
@@ -86,9 +90,13 @@ export const Tabs = ({
if (tabs.find(tab => tab.header === tabname)) { if (tabs.find(tab => tab.header === tabname)) {
return { error: "Name already exists." }; return { error: "Name already exists." };
} }
const ext = tabname.split(".").pop() || "";
if (allowedExtensions && !allowedExtensions.includes(ext)) {
return { error: "This file extension is not allowed!" };
}
return { error: null }; return { error: null };
}, },
[tabs] [allowedExtensions, tabs]
); );
const handleActiveChange = useCallback( const handleActiveChange = useCallback(
@@ -101,9 +109,11 @@ export const Tabs = ({
const handleCreateTab = useCallback(() => { const handleCreateTab = useCallback(() => {
// add default extension in case omitted // add default extension in case omitted
let _tabname = tabname.includes(".") ? tabname : tabname + defaultExtension; let _tabname = tabname.includes(".")
if (forceDefaultExtension && !_tabname.endsWith(defaultExtension)) { ? tabname
_tabname = _tabname + defaultExtension; : `${tabname}.${defaultExtension}`;
if (appendDefaultExtension && !_tabname.endsWith(defaultExtension)) {
_tabname = `${_tabname}.${defaultExtension}`;
} }
const chk = validateTabname(_tabname); const chk = validateTabname(_tabname);
@@ -122,7 +132,7 @@ export const Tabs = ({
}, [ }, [
tabname, tabname,
defaultExtension, defaultExtension,
forceDefaultExtension, appendDefaultExtension,
validateTabname, validateTabname,
onCreateNewTab, onCreateNewTab,
handleActiveChange, handleActiveChange,
@@ -206,13 +216,13 @@ export const Tabs = ({
size="sm" size="sm"
css={{ alignItems: "center", px: "$2", mr: "$3" }} css={{ alignItems: "center", px: "$2", mr: "$3" }}
> >
<Plus size="16px" /> {tabs.length === 0 && "Add new tab"} <Plus size="16px" /> {tabs.length === 0 && `Add new ${label.toLocaleLowerCase()}`}
</Button> </Button>
</DialogTrigger> </DialogTrigger>
<DialogContent> <DialogContent>
<DialogTitle>Create new tab</DialogTitle> <DialogTitle>Create new {label.toLocaleLowerCase()}</DialogTitle>
<DialogDescription> <DialogDescription>
<Label>Tabname</Label> <Label>{label} name</Label>
<Input <Input
value={tabname} value={tabname}
onChange={e => setTabname(e.target.value)} onChange={e => setTabname(e.target.value)}

View File

@@ -45,7 +45,7 @@ const Test = () => {
? [50, 20, 30] ? [50, 20, 30]
: hasScripts : hasScripts
? [50, 20, 50] ? [50, 20, 50]
: [50, 50] : [50, 50, 0]
} }
gutterSize={4} gutterSize={4}
gutterAlign="center" gutterAlign="center"
@@ -76,14 +76,15 @@ const Test = () => {
> >
<Box css={{ width: "55%", px: "$2" }}> <Box css={{ width: "55%", px: "$2" }}>
<Tabs <Tabs
label='Transaction'
activeHeader={activeHeader} activeHeader={activeHeader}
// TODO make header a required field // TODO make header a required field
onChangeActive={(idx, header) => { onChangeActive={(idx, header) => {
if (header) transactionsState.activeHeader = header; if (header) transactionsState.activeHeader = header;
}} }}
keepAllAlive keepAllAlive
forceDefaultExtension defaultExtension="json"
defaultExtension=".json" allowedExtensions={['json']}
onCreateNewTab={(header) => modifyTransaction(header, {})} onCreateNewTab={(header) => modifyTransaction(header, {})}
onCloseTab={(idx, header) => onCloseTab={(idx, header) =>
header && modifyTransaction(header, undefined) header && modifyTransaction(header, undefined)

View File

@@ -3480,7 +3480,7 @@ react-select@^5.2.1:
react-split@^2.0.14: react-split@^2.0.14:
version "2.0.14" version "2.0.14"
resolved "https://registry.npmjs.org/react-split/-/react-split-2.0.14.tgz" resolved "https://registry.yarnpkg.com/react-split/-/react-split-2.0.14.tgz#ef198259bf43264d605f792fb3384f15f5b34432"
integrity sha512-bKWydgMgaKTg/2JGQnaJPg51T6dmumTWZppFgEbbY0Fbme0F5TuatAScCLaqommbGQQf/ZT1zaejuPDriscISA== integrity sha512-bKWydgMgaKTg/2JGQnaJPg51T6dmumTWZppFgEbbY0Fbme0F5TuatAScCLaqommbGQQf/ZT1zaejuPDriscISA==
dependencies: dependencies:
prop-types "^15.5.7" prop-types "^15.5.7"