Compare commits
2 Commits
feature/re
...
feat/strea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04e2274dbf | ||
|
|
842b8a5226 |
@@ -2,7 +2,6 @@ NEXTAUTH_URL=https://example.com
|
|||||||
GITHUB_SECRET=""
|
GITHUB_SECRET=""
|
||||||
GITHUB_ID=""
|
GITHUB_ID=""
|
||||||
NEXT_PUBLIC_COMPILE_API_ENDPOINT="http://localhost:9000/api/build"
|
NEXT_PUBLIC_COMPILE_API_ENDPOINT="http://localhost:9000/api/build"
|
||||||
NEXT_PUBLIC_COMPILE_API_BASE_URL="http://localhost:9000"
|
|
||||||
NEXT_PUBLIC_LANGUAGE_SERVER_API_ENDPOINT="ws://localhost:9000/language-server/c"
|
NEXT_PUBLIC_LANGUAGE_SERVER_API_ENDPOINT="ws://localhost:9000/language-server/c"
|
||||||
NEXT_PUBLIC_TESTNET_URL="hooks-testnet-v2.xrpl-labs.com"
|
NEXT_PUBLIC_TESTNET_URL="hooks-testnet-v2.xrpl-labs.com"
|
||||||
NEXT_PUBLIC_DEBUG_STREAM_URL="hooks-testnet-v2-debugstream.xrpl-labs.com"
|
NEXT_PUBLIC_DEBUG_STREAM_URL="hooks-testnet-v2-debugstream.xrpl-labs.com"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ interface ISelect<T = string> {
|
|||||||
value: T;
|
value: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
const streamState = proxy({
|
export const streamState = proxy({
|
||||||
selectedAccount: null as ISelect | null,
|
selectedAccount: null as ISelect | null,
|
||||||
logs: [] as ILog[],
|
logs: [] as ILog[],
|
||||||
socket: undefined as WebSocket | undefined,
|
socket: undefined as WebSocket | undefined,
|
||||||
|
|||||||
@@ -226,22 +226,6 @@ const HooksEditor = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hacky way to hide Peek menu
|
|
||||||
editor.onContextMenu((e) => {
|
|
||||||
const host =
|
|
||||||
document.querySelector<HTMLElement>(".shadow-root-host");
|
|
||||||
|
|
||||||
const contextMenuItems =
|
|
||||||
host?.shadowRoot?.querySelectorAll("li.action-item");
|
|
||||||
contextMenuItems?.forEach((k) => {
|
|
||||||
// If menu item contains "Peek" lets hide it
|
|
||||||
if (k.querySelector(".action-label")?.textContent === "Peek") {
|
|
||||||
// @ts-expect-error
|
|
||||||
k["style"].display = "none";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
validateWritability(editor);
|
validateWritability(editor);
|
||||||
}}
|
}}
|
||||||
theme={theme === "dark" ? "dark" : "light"}
|
theme={theme === "dark" ? "dark" : "light"}
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ export const Input = styled("input", {
|
|||||||
},
|
},
|
||||||
"&:read-only": {
|
"&:read-only": {
|
||||||
backgroundColor: "$mauve2",
|
backgroundColor: "$mauve2",
|
||||||
color: "$text",
|
|
||||||
opacity: 0.8,
|
|
||||||
"&:focus": {
|
"&:focus": {
|
||||||
boxShadow: "inset 0px 0px 0px 1px $colors$mauve7",
|
boxShadow: "inset 0px 0px 0px 1px $colors$mauve7",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Plus, Trash, X } from "phosphor-react";
|
import { Plus, Trash, X } from "phosphor-react";
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
import Box from "./Box";
|
import Box from "./Box";
|
||||||
@@ -25,7 +25,6 @@ import type { IAccount } from "../state";
|
|||||||
import { useSnapshot } from "valtio";
|
import { useSnapshot } from "valtio";
|
||||||
import state from "../state";
|
import state from "../state";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { sha256 } from "../state/actions/deployHook";
|
|
||||||
|
|
||||||
const transactionOptions = Object.keys(tts).map((key) => ({
|
const transactionOptions = Object.keys(tts).map((key) => ({
|
||||||
label: key,
|
label: key,
|
||||||
@@ -37,7 +36,6 @@ export type SetHookData = {
|
|||||||
value: keyof TTS;
|
value: keyof TTS;
|
||||||
label: string;
|
label: string;
|
||||||
}[];
|
}[];
|
||||||
HookNamespace: string;
|
|
||||||
HookParameters: {
|
HookParameters: {
|
||||||
HookParameter: {
|
HookParameter: {
|
||||||
HookParameterName: string;
|
HookParameterName: string;
|
||||||
@@ -59,13 +57,8 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
|
|||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
control,
|
control,
|
||||||
watch,
|
// formState: { errors },
|
||||||
formState: { errors },
|
} = useForm<SetHookData>();
|
||||||
} = useForm<SetHookData>({
|
|
||||||
defaultValues: {
|
|
||||||
HookNamespace: snap.files?.[snap.active]?.name?.split(".")?.[0] || "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { fields, append, remove } = useFieldArray({
|
const { fields, append, remove } = useFieldArray({
|
||||||
control,
|
control,
|
||||||
name: "HookParameters", // unique name for your Field Array
|
name: "HookParameters", // unique name for your Field Array
|
||||||
@@ -78,19 +71,6 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
|
|||||||
// control,
|
// control,
|
||||||
// name: "HookGrants", // unique name for your Field Array
|
// name: "HookGrants", // unique name for your Field Array
|
||||||
// });
|
// });
|
||||||
const [hashedNamespace, setHashedNamespace] = useState("");
|
|
||||||
const namespace = watch(
|
|
||||||
"HookNamespace",
|
|
||||||
snap.files?.[snap.active]?.name?.split(".")?.[0] || ""
|
|
||||||
);
|
|
||||||
const calculateHashedValue = useCallback(async () => {
|
|
||||||
const hashedVal = await sha256(namespace);
|
|
||||||
setHashedNamespace(hashedVal.toUpperCase());
|
|
||||||
}, [namespace]);
|
|
||||||
useEffect(() => {
|
|
||||||
calculateHashedValue();
|
|
||||||
}, [namespace, calculateHashedValue]);
|
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -109,7 +89,6 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
|
|||||||
}
|
}
|
||||||
toast.error(`Transaction failed! (${res?.engine_result_message})`);
|
toast.error(`Transaction failed! (${res?.engine_result_message})`);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={isSetHookDialogOpen} onOpenChange={setIsSetHookDialogOpen}>
|
<Dialog open={isSetHookDialogOpen} onOpenChange={setIsSetHookDialogOpen}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
@@ -150,25 +129,6 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box css={{ width: "100%" }}>
|
|
||||||
<label>Hook Namespace Seed</label>
|
|
||||||
<Input
|
|
||||||
{...register("HookNamespace", { required: true })}
|
|
||||||
autoComplete={"off"}
|
|
||||||
defaultValue={
|
|
||||||
snap.files?.[snap.active]?.name?.split(".")?.[0] || ""
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{errors.HookNamespace?.type === "required" && (
|
|
||||||
<Box css={{ display: "inline", color: "$red11" }}>
|
|
||||||
Namespace is required
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
<Box css={{ mt: "$3" }}>
|
|
||||||
<label>Hook Namespace (sha256)</label>
|
|
||||||
<Input readOnly value={hashedNamespace} />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Box css={{ width: "100%" }}>
|
<Box css={{ width: "100%" }}>
|
||||||
<label style={{ marginBottom: "10px", display: "block" }}>
|
<label style={{ marginBottom: "10px", display: "block" }}>
|
||||||
Hook parameters
|
Hook parameters
|
||||||
@@ -184,7 +144,7 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Value (hex-quoted)"
|
placeholder="Parameter value"
|
||||||
{...register(
|
{...register(
|
||||||
`HookParameters.${index}.HookParameter.HookParameterValue`
|
`HookParameters.${index}.HookParameter.HookParameterValue`
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codingame/monaco-jsonrpc": "^0.3.1",
|
"@codingame/monaco-jsonrpc": "^0.3.1",
|
||||||
"@codingame/monaco-languageclient": "^0.17.0",
|
"@codingame/monaco-languageclient": "^0.17.0",
|
||||||
"@monaco-editor/react": "^4.4.1",
|
"@monaco-editor/react": "^4.3.1",
|
||||||
"@octokit/core": "^3.5.1",
|
"@octokit/core": "^3.5.1",
|
||||||
"@radix-ui/colors": "^0.1.7",
|
"@radix-ui/colors": "^0.1.7",
|
||||||
"@radix-ui/react-alert-dialog": "^0.1.1",
|
"@radix-ui/react-alert-dialog": "^0.1.1",
|
||||||
@@ -29,10 +29,10 @@
|
|||||||
"jszip": "^3.7.1",
|
"jszip": "^3.7.1",
|
||||||
"lodash.uniqby": "^4.7.0",
|
"lodash.uniqby": "^4.7.0",
|
||||||
"lodash.xor": "^4.5.0",
|
"lodash.xor": "^4.5.0",
|
||||||
"monaco-editor": "^0.33.0",
|
"monaco-editor": "^0.30.1",
|
||||||
"next": "^12.0.4",
|
"next": "^12.0.4",
|
||||||
"next-auth": "^4.0.0-beta.5",
|
"next-auth": "^4.0.0-beta.5",
|
||||||
"next-themes": "^0.1.1",
|
"next-themes": "^0.0.15",
|
||||||
"normalize-url": "^7.0.2",
|
"normalize-url": "^7.0.2",
|
||||||
"octokit": "^1.7.0",
|
"octokit": "^1.7.0",
|
||||||
"pako": "^2.0.4",
|
"pako": "^2.0.4",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import en from "javascript-time-ago/locale/en.json";
|
|||||||
import { useSnapshot } from "valtio";
|
import { useSnapshot } from "valtio";
|
||||||
|
|
||||||
TimeAgo.setDefaultLocale(en.locale);
|
TimeAgo.setDefaultLocale(en.locale);
|
||||||
TimeAgo.addLocale(en);
|
TimeAgo.addLocale(en)
|
||||||
|
|
||||||
function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
|
function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import transactionsData from "../../content/transactions.json";
|
|||||||
import state from "../../state";
|
import state from "../../state";
|
||||||
import { sendTransaction } from "../../state/actions";
|
import { sendTransaction } from "../../state/actions";
|
||||||
import { getSplit, saveSplit } from "../../state/actions/persistSplits";
|
import { getSplit, saveSplit } from "../../state/actions/persistSplits";
|
||||||
|
import { streamState } from "../../components/DebugStream";
|
||||||
|
|
||||||
const DebugStream = dynamic(() => import("../../components/DebugStream"), {
|
const DebugStream = dynamic(() => import("../../components/DebugStream"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
@@ -37,6 +38,11 @@ type TxFields = Omit<
|
|||||||
>;
|
>;
|
||||||
type OtherFields = (keyof Omit<TxFields, "Destination">)[];
|
type OtherFields = (keyof Omit<TxFields, "Destination">)[];
|
||||||
|
|
||||||
|
interface AccountOption {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
header?: string;
|
header?: string;
|
||||||
}
|
}
|
||||||
@@ -44,7 +50,7 @@ interface Props {
|
|||||||
const Transaction: FC<Props> = ({ header, ...props }) => {
|
const Transaction: FC<Props> = ({ header, ...props }) => {
|
||||||
const snap = useSnapshot(state);
|
const snap = useSnapshot(state);
|
||||||
|
|
||||||
const transactionsOptions = transactionsData.map((tx) => ({
|
const transactionsOptions = transactionsData.map(tx => ({
|
||||||
value: tx.TransactionType,
|
value: tx.TransactionType,
|
||||||
label: tx.TransactionType,
|
label: tx.TransactionType,
|
||||||
}));
|
}));
|
||||||
@@ -52,23 +58,24 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
typeof transactionsOptions[0] | null
|
typeof transactionsOptions[0] | null
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
const accountOptions = snap.accounts.map((acc) => ({
|
const accountOptions: AccountOption[] = snap.accounts.map(acc => ({
|
||||||
label: acc.name,
|
label: acc.name,
|
||||||
value: acc.address,
|
value: acc.address,
|
||||||
}));
|
}));
|
||||||
const [selectedAccount, setSelectedAccount] = useState<
|
|
||||||
typeof accountOptions[0] | null
|
|
||||||
>(null);
|
|
||||||
|
|
||||||
const destAccountOptions = snap.accounts
|
const [selectedAccount, setSelectedAccount] = useState<AccountOption | null>(
|
||||||
.map((acc) => ({
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
const destAccountOptions: AccountOption[] = snap.accounts
|
||||||
|
.map(acc => ({
|
||||||
label: acc.name,
|
label: acc.name,
|
||||||
value: acc.address,
|
value: acc.address,
|
||||||
}))
|
}))
|
||||||
.filter((acc) => acc.value !== selectedAccount?.value);
|
.filter(acc => acc.value !== selectedAccount?.value);
|
||||||
const [selectedDestAccount, setSelectedDestAccount] = useState<
|
|
||||||
typeof destAccountOptions[0] | null
|
const [selectedDestAccount, setSelectedDestAccount] =
|
||||||
>(null);
|
useState<AccountOption | null>(null);
|
||||||
|
|
||||||
const [txIsLoading, setTxIsLoading] = useState(false);
|
const [txIsLoading, setTxIsLoading] = useState(false);
|
||||||
const [txIsDisabled, setTxIsDisabled] = useState(false);
|
const [txIsDisabled, setTxIsDisabled] = useState(false);
|
||||||
@@ -77,7 +84,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const transactionType = selectedTransaction?.value;
|
const transactionType = selectedTransaction?.value;
|
||||||
const account = snap.accounts.find(
|
const account = snap.accounts.find(
|
||||||
(acc) => acc.address === selectedAccount?.value
|
acc => acc.address === selectedAccount?.value
|
||||||
);
|
);
|
||||||
if (!account || !transactionType || txIsLoading) {
|
if (!account || !transactionType || txIsLoading) {
|
||||||
setTxIsDisabled(true);
|
setTxIsDisabled(true);
|
||||||
@@ -88,7 +95,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let _txFields: TxFields | undefined = transactionsData.find(
|
let _txFields: TxFields | undefined = transactionsData.find(
|
||||||
(tx) => tx.TransactionType === selectedTransaction?.value
|
tx => tx.TransactionType === selectedTransaction?.value
|
||||||
);
|
);
|
||||||
if (!_txFields) return setTxFields({});
|
if (!_txFields) return setTxFields({});
|
||||||
_txFields = { ..._txFields } as TxFields;
|
_txFields = { ..._txFields } as TxFields;
|
||||||
@@ -105,7 +112,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
|
|
||||||
const submitTest = useCallback(async () => {
|
const submitTest = useCallback(async () => {
|
||||||
const account = snap.accounts.find(
|
const account = snap.accounts.find(
|
||||||
(acc) => acc.address === selectedAccount?.value
|
acc => acc.address === selectedAccount?.value
|
||||||
);
|
);
|
||||||
const TransactionType = selectedTransaction?.value;
|
const TransactionType = selectedTransaction?.value;
|
||||||
if (!account || !TransactionType || txIsDisabled) return;
|
if (!account || !TransactionType || txIsDisabled) return;
|
||||||
@@ -116,7 +123,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
let options = { ...txFields };
|
let options = { ...txFields };
|
||||||
|
|
||||||
options.Destination = selectedDestAccount?.value;
|
options.Destination = selectedDestAccount?.value;
|
||||||
(Object.keys(options) as (keyof TxFields)[]).forEach((field) => {
|
(Object.keys(options) as (keyof TxFields)[]).forEach(field => {
|
||||||
let _value = options[field];
|
let _value = options[field];
|
||||||
// convert currency
|
// convert currency
|
||||||
if (typeof _value === "object" && _value.type === "currency") {
|
if (typeof _value === "object" && _value.type === "currency") {
|
||||||
@@ -182,9 +189,14 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
setTxIsLoading(false);
|
setTxIsLoading(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const handleSetAccount = (acc: AccountOption) => {
|
||||||
|
setSelectedAccount(acc);
|
||||||
|
streamState.selectedAccount = acc;
|
||||||
|
};
|
||||||
|
|
||||||
const usualFields = ["TransactionType", "Amount", "Account", "Destination"];
|
const usualFields = ["TransactionType", "Amount", "Account", "Destination"];
|
||||||
const otherFields = Object.keys(txFields).filter(
|
const otherFields = Object.keys(txFields).filter(
|
||||||
(k) => !usualFields.includes(k)
|
k => !usualFields.includes(k)
|
||||||
) as OtherFields;
|
) as OtherFields;
|
||||||
return (
|
return (
|
||||||
<Box css={{ position: "relative", height: "calc(100% - 28px)" }} {...props}>
|
<Box css={{ position: "relative", height: "calc(100% - 28px)" }} {...props}>
|
||||||
@@ -217,7 +229,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
hideSelectedOptions
|
hideSelectedOptions
|
||||||
css={{ width: "70%" }}
|
css={{ width: "70%" }}
|
||||||
value={selectedTransaction}
|
value={selectedTransaction}
|
||||||
onChange={(tt) => setSelectedTransaction(tt as any)}
|
onChange={(tt: any) => setSelectedTransaction(tt)}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex
|
<Flex
|
||||||
@@ -239,7 +251,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
css={{ width: "70%" }}
|
css={{ width: "70%" }}
|
||||||
options={accountOptions}
|
options={accountOptions}
|
||||||
value={selectedAccount}
|
value={selectedAccount}
|
||||||
onChange={(acc) => setSelectedAccount(acc as any)}
|
onChange={(acc: any) => handleSetAccount(acc)} // TODO make react-select have correct types for acc
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
{txFields.Amount !== undefined && (
|
{txFields.Amount !== undefined && (
|
||||||
@@ -258,7 +270,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
</Text>
|
</Text>
|
||||||
<Input
|
<Input
|
||||||
value={txFields.Amount.value}
|
value={txFields.Amount.value}
|
||||||
onChange={(e) =>
|
onChange={e =>
|
||||||
setTxFields({
|
setTxFields({
|
||||||
...txFields,
|
...txFields,
|
||||||
Amount: { type: "currency", value: e.target.value },
|
Amount: { type: "currency", value: e.target.value },
|
||||||
@@ -289,11 +301,11 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
options={destAccountOptions}
|
options={destAccountOptions}
|
||||||
value={selectedDestAccount}
|
value={selectedDestAccount}
|
||||||
isClearable
|
isClearable
|
||||||
onChange={(acc) => setSelectedDestAccount(acc as any)}
|
onChange={(acc: any) => setSelectedDestAccount(acc)}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
{otherFields.map((field) => {
|
{otherFields.map(field => {
|
||||||
let _value = txFields[field];
|
let _value = txFields[field];
|
||||||
let value = typeof _value === "object" ? _value.value : _value;
|
let value = typeof _value === "object" ? _value.value : _value;
|
||||||
value =
|
value =
|
||||||
@@ -319,7 +331,7 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
</Text>
|
</Text>
|
||||||
<Input
|
<Input
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) =>
|
onChange={e =>
|
||||||
setTxFields({
|
setTxFields({
|
||||||
...txFields,
|
...txFields,
|
||||||
[field]:
|
[field]:
|
||||||
@@ -376,7 +388,7 @@ const Test = () => {
|
|||||||
gutterSize={4}
|
gutterSize={4}
|
||||||
gutterAlign="center"
|
gutterAlign="center"
|
||||||
style={{ height: "calc(100vh - 60px)" }}
|
style={{ height: "calc(100vh - 60px)" }}
|
||||||
onDragEnd={(e) => saveSplit("testVertical", e)}
|
onDragEnd={e => saveSplit("testVertical", e)}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
row
|
row
|
||||||
@@ -398,21 +410,19 @@ const Test = () => {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
}}
|
}}
|
||||||
onDragEnd={(e) => saveSplit("testHorizontal", e)}
|
onDragEnd={e => saveSplit("testHorizontal", e)}
|
||||||
>
|
>
|
||||||
<Box css={{ width: "55%", px: "$2" }}>
|
<Box css={{ width: "55%", px: "$2" }}>
|
||||||
<Tabs
|
<Tabs
|
||||||
keepAllAlive
|
keepAllAlive
|
||||||
forceDefaultExtension
|
forceDefaultExtension
|
||||||
defaultExtension=".json"
|
defaultExtension=".json"
|
||||||
onCreateNewTab={(name) =>
|
onCreateNewTab={name => setTabHeaders(tabHeaders.concat(name))}
|
||||||
setTabHeaders(tabHeaders.concat(name))
|
onCloseTab={index =>
|
||||||
}
|
|
||||||
onCloseTab={(index) =>
|
|
||||||
setTabHeaders(tabHeaders.filter((_, idx) => idx !== index))
|
setTabHeaders(tabHeaders.filter((_, idx) => idx !== index))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{tabHeaders.map((header) => (
|
{tabHeaders.map(header => (
|
||||||
<Tab key={header} header={header}>
|
<Tab key={header} header={header}>
|
||||||
<Transaction header={header} />
|
<Transaction header={header} />
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import state, { IAccount } from "../index";
|
|||||||
import calculateHookOn, { TTS } from "../../utils/hookOnCalculator";
|
import calculateHookOn, { TTS } from "../../utils/hookOnCalculator";
|
||||||
import { SetHookData } from "../../components/SetHookDialog";
|
import { SetHookData } from "../../components/SetHookDialog";
|
||||||
|
|
||||||
export const sha256 = async (string: string) => {
|
const hash = async (string: string) => {
|
||||||
const utf8 = new TextEncoder().encode(string);
|
const utf8 = new TextEncoder().encode(string);
|
||||||
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
|
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
|
||||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||||
@@ -66,10 +66,12 @@ export const deployHook = async (account: IAccount & { name?: string }, data: Se
|
|||||||
if (!state.client) {
|
if (!state.client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const HookNamespace = (await sha256(data.HookNamespace)).toUpperCase();
|
const HookNamespace = await hash(arrayBufferToHex(
|
||||||
|
state.files?.[state.active]?.compiledContent
|
||||||
|
).toUpperCase());
|
||||||
const hookOnValues: (keyof TTS)[] = data.Invoke.map(tt => tt.value);
|
const hookOnValues: (keyof TTS)[] = data.Invoke.map(tt => tt.value);
|
||||||
const { HookParameters } = data;
|
const { HookParameters } = data;
|
||||||
const filteredHookParameters = HookParameters.filter(hp => hp.HookParameter.HookParameterName && hp.HookParameter.HookParameterValue)?.map(aa => ({ HookParameter: { HookParameterName: toHex(aa.HookParameter.HookParameterName || ''), HookParameterValue: aa.HookParameter.HookParameterValue || '' } }));
|
const filteredHookParameters = HookParameters.filter(hp => hp.HookParameter.HookParameterName && hp.HookParameter.HookParameterValue)?.map(aa => ({ HookParameter: { HookParameterName: toHex(aa.HookParameter.HookParameterName || ''), HookParameterValue: toHex(aa.HookParameter.HookParameterValue || '') } }));
|
||||||
// const filteredHookGrants = HookGrants.filter(hg => hg.HookGrant.Authorize || hg.HookGrant.HookHash).map(hg => {
|
// const filteredHookGrants = HookGrants.filter(hg => hg.HookGrant.Authorize || hg.HookGrant.HookHash).map(hg => {
|
||||||
// return {
|
// return {
|
||||||
// HookGrant: {
|
// HookGrant: {
|
||||||
@@ -218,4 +220,4 @@ export const deleteHook = async (account: IAccount & { name?: string }) => {
|
|||||||
}
|
}
|
||||||
return submitRes;
|
return submitRes;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2,6 +2,8 @@ import { Octokit } from "@octokit/core";
|
|||||||
import Router from "next/router";
|
import Router from "next/router";
|
||||||
import state from '../index';
|
import state from '../index';
|
||||||
import { templateFileIds } from '../constants';
|
import { templateFileIds } from '../constants';
|
||||||
|
import { hookapiH, hookmacroH, sfcodesH } from '../constants/headerTemplates';
|
||||||
|
|
||||||
|
|
||||||
const octokit = new Octokit();
|
const octokit = new Octokit();
|
||||||
|
|
||||||
@@ -18,30 +20,18 @@ export const fetchFiles = (gistId: string) => {
|
|||||||
|
|
||||||
octokit
|
octokit
|
||||||
.request("GET /gists/{gist_id}", { gist_id: gistId })
|
.request("GET /gists/{gist_id}", { gist_id: gistId })
|
||||||
.then(async res => {
|
.then(res => {
|
||||||
if (!Object.values(templateFileIds).includes(gistId)) {
|
if (!Object.values(templateFileIds).includes(gistId)) {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
// in case of templates, fetch header file(s) and append to res
|
// in case of templates, fetch header file(s) and append to res
|
||||||
let resHeaderJson;
|
const files = {
|
||||||
try {
|
...res.data.files,
|
||||||
const resHeader = await fetch(`${process.env.NEXT_PUBLIC_COMPILE_API_BASE_URL}/api/header-files`);
|
'hookapi.h': res.data.files?.['hookapi.h'] || { filename: 'hookapi.h', content: hookapiH, language: 'C' },
|
||||||
if (resHeader.ok) {
|
'hookmacro.h': res.data.files?.['hookmacro.h'] || { filename: 'hookmacro.h', content: hookmacroH, language: 'C' },
|
||||||
resHeaderJson = await resHeader.json();
|
'sfcodes.h': res.data.files?.['sfcodes.h'] || { filename: 'sfcodes.h', content: sfcodesH, language: 'C' },
|
||||||
const files = {
|
};
|
||||||
...res.data.files,
|
res.data.files = files;
|
||||||
'hookapi.h': res.data.files?.['hookapi.h'] || { filename: 'hookapi.h', content: resHeaderJson.hookapi, language: 'C' },
|
|
||||||
'hookmacro.h': res.data.files?.['hookmacro.h'] || { filename: 'hookmacro.h', content: resHeaderJson.hookmacro, language: 'C' },
|
|
||||||
'sfcodes.h': res.data.files?.['sfcodes.h'] || { filename: 'sfcodes.h', content: resHeaderJson.sfcodes, language: 'C' },
|
|
||||||
};
|
|
||||||
res.data.files = files;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
// If you want to load templates from GIST instad, uncomment the code below and comment the code above.
|
// If you want to load templates from GIST instad, uncomment the code below and comment the code above.
|
||||||
// return octokit.request("GET /gists/{gist_id}", { gist_id: templateFileIds.headers }).then(({ data: { files: headerFiles } }) => {
|
// return octokit.request("GET /gists/{gist_id}", { gist_id: templateFileIds.headers }).then(({ data: { files: headerFiles } }) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { derive, XRPL_Account } from "xrpl-accountlib";
|
import { derive } from "xrpl-accountlib";
|
||||||
|
|
||||||
import state from '../index';
|
import state from '../index';
|
||||||
import { names } from './addFaucetAccount';
|
import { names } from './addFaucetAccount';
|
||||||
@@ -12,18 +12,8 @@ export const importAccount = (secret: string) => {
|
|||||||
if (state.accounts.find((acc) => acc.secret === secret)) {
|
if (state.accounts.find((acc) => acc.secret === secret)) {
|
||||||
return toast.error("Account already added!");
|
return toast.error("Account already added!");
|
||||||
}
|
}
|
||||||
let account: XRPL_Account | null = null;
|
const account = derive.familySeed(secret);
|
||||||
try {
|
if (!account.secret.familySeed) {
|
||||||
account = derive.familySeed(secret);
|
|
||||||
} catch (err: any) {
|
|
||||||
if (err?.message) {
|
|
||||||
toast.error(err.message)
|
|
||||||
} else {
|
|
||||||
toast.error('Error occured while importing account')
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!account || !account.secret.familySeed) {
|
|
||||||
return toast.error(`Couldn't create account!`);
|
return toast.error(`Couldn't create account!`);
|
||||||
}
|
}
|
||||||
state.accounts.push({
|
state.accounts.push({
|
||||||
|
|||||||
1383
state/constants/headerTemplates.ts
Normal file
1383
state/constants/headerTemplates.ts
Normal file
File diff suppressed because it is too large
Load Diff
34
yarn.lock
34
yarn.lock
@@ -202,19 +202,19 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
|
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
|
||||||
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
|
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
|
||||||
|
|
||||||
"@monaco-editor/loader@^1.3.0":
|
"@monaco-editor/loader@^1.2.0":
|
||||||
version "1.3.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@monaco-editor/loader/-/loader-1.3.0.tgz#659fbaf1d612ea67b2a0519a18612d1c4813e444"
|
resolved "https://registry.yarnpkg.com/@monaco-editor/loader/-/loader-1.2.0.tgz#373fad69973384624e3d9b60eefd786461a76acd"
|
||||||
integrity sha512-N3mGq1ktC3zh7WUx3NGO+PSDdNq9Vspk/41rEmRdrCqV9vNbBTRzAOplmUpNQsi+hmTs++ERMBobMERb8Kb+3g==
|
integrity sha512-cJVCG/T/KxXgzYnjKqyAgsKDbH9mGLjcXxN6AmwumBwa2rVFkwvGcUj1RJtD0ko4XqLqJxwqsN/Z/KURB5f1OQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
state-local "^1.0.6"
|
state-local "^1.0.6"
|
||||||
|
|
||||||
"@monaco-editor/react@^4.4.1":
|
"@monaco-editor/react@^4.3.1":
|
||||||
version "4.4.1"
|
version "4.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/@monaco-editor/react/-/react-4.4.1.tgz#2e2b9b369f3082b0e14f47cdbe35658fd56c7c7d"
|
resolved "https://registry.yarnpkg.com/@monaco-editor/react/-/react-4.3.1.tgz#d65bcbf174c39b6d4e7fec43d0cddda82b70a12a"
|
||||||
integrity sha512-95E/XPC4dbm/7qdkhSsU/a1kRgcn2PYhRTVIc+/cixWCZrwRURW1DRPaIZ2lOawBJ6kAOLywxuD4A4UmbT0ZIw==
|
integrity sha512-f+0BK1PP/W5I50hHHmwf11+Ea92E5H1VZXs+wvKplWUWOfyMa1VVwqkJrXjRvbcqHL+XdIGYWhWNdi4McEvnZg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@monaco-editor/loader" "^1.3.0"
|
"@monaco-editor/loader" "^1.2.0"
|
||||||
prop-types "^15.7.2"
|
prop-types "^15.7.2"
|
||||||
|
|
||||||
"@next/env@12.1.0":
|
"@next/env@12.1.0":
|
||||||
@@ -2867,10 +2867,10 @@ minimist@^1.2.0, minimist@^1.2.5:
|
|||||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||||
|
|
||||||
monaco-editor@^0.33.0:
|
monaco-editor@^0.30.1:
|
||||||
version "0.33.0"
|
version "0.30.1"
|
||||||
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.33.0.tgz#842e244f3750a2482f8a29c676b5684e75ff34af"
|
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.30.1.tgz#47f8d18a0aa2264fc5654581741ab8d7bec01689"
|
||||||
integrity sha512-VcRWPSLIUEgQJQIE0pVT8FcGBIgFoxz7jtqctE+IiCxWugD0DwgyQBcZBhdSrdMC84eumoqMZsGl2GTreOzwqw==
|
integrity sha512-B/y4+b2O5G2gjuxIFtCE2EkM17R2NM7/3F8x0qcPsqy4V83bitJTIO4TIeZpYlzu/xy6INiY/+84BEm6+7Cmzg==
|
||||||
|
|
||||||
ms@2.0.0:
|
ms@2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
@@ -2917,10 +2917,10 @@ next-auth@^4.0.0-beta.5:
|
|||||||
preact-render-to-string "^5.1.19"
|
preact-render-to-string "^5.1.19"
|
||||||
uuid "^8.3.2"
|
uuid "^8.3.2"
|
||||||
|
|
||||||
next-themes@^0.1.1:
|
next-themes@^0.0.15:
|
||||||
version "0.1.1"
|
version "0.0.15"
|
||||||
resolved "https://registry.yarnpkg.com/next-themes/-/next-themes-0.1.1.tgz#122113a458bf1d1be5ffed66778ab924c106f82a"
|
resolved "https://registry.yarnpkg.com/next-themes/-/next-themes-0.0.15.tgz#ab0cee69cd763b77d41211f631e108beab39bf7d"
|
||||||
integrity sha512-Iqxt6rhS/KfK/iHJ0tfFjTcdLEAI0AgwFuAFrMwLOPK5e+MI3I+fzyvBoS+VaOS+NldUiazurhgwYhrfV0VXsQ==
|
integrity sha512-LTmtqYi03c4gMTJmWwVK9XkHL7h0/+XrtR970Ujvtu3s0kZNeJN24aJsi4rkZOI8i19+qq6f8j+8Duwy5jqcrQ==
|
||||||
|
|
||||||
next-tick@^1.1.0:
|
next-tick@^1.1.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user