Compare commits
26 Commits
hotfix/fix
...
feat/c-hig
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6be19db6c | ||
|
|
6e39b90c1e | ||
|
|
f186a807c1 | ||
|
|
5ad9ed1688 | ||
|
|
234832138f | ||
|
|
28d94a1475 | ||
|
|
594aee6cd2 | ||
|
|
d75910972f | ||
|
|
589c604a12 | ||
|
|
8394a11705 | ||
|
|
4ad329882c | ||
|
|
ee86b91e82 | ||
|
|
d2addf782e | ||
|
|
51f7bd509b | ||
|
|
e064251ff9 | ||
|
|
5aeed7c246 | ||
|
|
8d03edc299 | ||
|
|
95022ef121 | ||
|
|
4519906b78 | ||
|
|
88a47c49a4 | ||
|
|
1ab03f9bed | ||
|
|
84ff667135 | ||
|
|
0d10e782f3 | ||
|
|
84e6763495 | ||
|
|
7ffcfd694d | ||
|
|
77e4917d38 |
@@ -2,6 +2,7 @@ NEXTAUTH_URL=https://example.com
|
||||
GITHUB_SECRET=""
|
||||
GITHUB_ID=""
|
||||
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_TESTNET_URL="hooks-testnet-v2.xrpl-labs.com"
|
||||
NEXT_PUBLIC_DEBUG_STREAM_URL="hooks-testnet-v2-debugstream.xrpl-labs.com"
|
||||
|
||||
@@ -249,6 +249,7 @@ export const AccountDialog = ({
|
||||
<Button
|
||||
size="xs"
|
||||
outline
|
||||
disabled={activeAccount.isLoading}
|
||||
css={{ mt: "$3", mr: "$1", ml: "auto" }}
|
||||
onClick={() => {
|
||||
deleteHook(activeAccount);
|
||||
|
||||
@@ -171,6 +171,16 @@ export const StyledButton = styled("button", {
|
||||
color: "$textMuted",
|
||||
},
|
||||
},
|
||||
isDisabled: {
|
||||
true: {
|
||||
opacity: 0.6,
|
||||
// pointerEvents: "none",
|
||||
cursor: "auto",
|
||||
"&:hover": {
|
||||
boxShadow: "inherit",
|
||||
},
|
||||
},
|
||||
},
|
||||
outline: {
|
||||
true: {
|
||||
backgroundColor: "transparent",
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
import NewWindow from "react-new-window";
|
||||
import { signOut, useSession } from "next-auth/react";
|
||||
import { useSnapshot } from "valtio";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import {
|
||||
createNewFile,
|
||||
@@ -48,7 +49,7 @@ import Flex from "./Flex";
|
||||
import Stack from "./Stack";
|
||||
import Input from "./Input";
|
||||
import Text from "./Text";
|
||||
import toast from "react-hot-toast";
|
||||
import Tooltip from "./Tooltip";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogContent,
|
||||
@@ -367,44 +368,65 @@ const EditorNavigation = ({ showWat }: { showWat?: boolean }) => {
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
isLoading={snap.zipLoading}
|
||||
onClick={downloadAsZip}
|
||||
outline
|
||||
size="sm"
|
||||
css={{ alignItems: "center" }}
|
||||
<Tooltip content="Download as ZIP">
|
||||
<Button
|
||||
isLoading={snap.zipLoading}
|
||||
onClick={downloadAsZip}
|
||||
outline
|
||||
size="sm"
|
||||
css={{ alignItems: "center" }}
|
||||
>
|
||||
<DownloadSimple size="16px" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip content="Copy share link to clipboard">
|
||||
<Button
|
||||
outline
|
||||
size="sm"
|
||||
css={{ alignItems: "center" }}
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(
|
||||
`${window.location.origin}/develop/${snap.gistId}`
|
||||
);
|
||||
toast.success("Copied share link to clipboard!");
|
||||
}}
|
||||
>
|
||||
<Share size="16px" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
content={
|
||||
session && session.user
|
||||
? snap.gistOwner === session?.user.username
|
||||
? "Sync to Gist"
|
||||
: "Create as a new Gist"
|
||||
: "You need to be logged in to sync with Gist"
|
||||
}
|
||||
>
|
||||
<DownloadSimple size="16px" />
|
||||
</Button>
|
||||
<Button
|
||||
outline
|
||||
size="sm"
|
||||
css={{ alignItems: "center" }}
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(
|
||||
`${window.location.origin}/develop/${snap.gistId}`
|
||||
);
|
||||
toast.success("Copied share link to clipboard!");
|
||||
}}
|
||||
>
|
||||
<Share size="16px" />
|
||||
</Button>
|
||||
<Button
|
||||
outline
|
||||
size="sm"
|
||||
disabled={!session || !session.user}
|
||||
isLoading={snap.gistLoading}
|
||||
css={{ alignItems: "center" }}
|
||||
onClick={() => {
|
||||
if (snap.gistOwner === session?.user.username) {
|
||||
syncToGist(session);
|
||||
} else {
|
||||
setCreateNewAlertOpen(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<CloudArrowUp size="16px" />
|
||||
</Button>
|
||||
<Button
|
||||
outline
|
||||
size="sm"
|
||||
isDisabled={!session || !session.user}
|
||||
isLoading={snap.gistLoading}
|
||||
css={{ alignItems: "center" }}
|
||||
onClick={() => {
|
||||
if (!session || !session.user) {
|
||||
return;
|
||||
}
|
||||
if (snap.gistOwner === session?.user.username) {
|
||||
syncToGist(session);
|
||||
} else {
|
||||
setCreateNewAlertOpen(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{snap.gistOwner === session?.user.username ? (
|
||||
<CloudArrowUp size="16px" />
|
||||
) : (
|
||||
<FilePlus size="16px" />
|
||||
)}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
|
||||
@@ -215,6 +215,7 @@ export const Log: FC<ILog> = ({
|
||||
)}
|
||||
{expanded && jsonData && <Pre block>{jsonData}</Pre>}
|
||||
</LogText>
|
||||
<br />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -228,7 +228,7 @@ const Navigation = () => {
|
||||
as="a"
|
||||
rel="noreferrer noopener"
|
||||
target="_blank"
|
||||
href="https://xrpl-hooks.readme.io/docs"
|
||||
href="https://xrpl-hooks.readme.io/v2.0/docs"
|
||||
>
|
||||
<ArrowUpRight size="15px" /> Hooks documentation
|
||||
</Text>
|
||||
@@ -400,7 +400,7 @@ const Navigation = () => {
|
||||
</Button>
|
||||
</Link>
|
||||
</ButtonGroup>
|
||||
<Link href="https://xrpl-hooks.readme.io/" passHref>
|
||||
<Link href="https://xrpl-hooks.readme.io/v2.0" passHref>
|
||||
<a target="_blank" rel="noreferrer noopener">
|
||||
<Button outline>
|
||||
<BookOpen size="15px" />
|
||||
|
||||
89
components/Tooltip.tsx
Normal file
89
components/Tooltip.tsx
Normal file
@@ -0,0 +1,89 @@
|
||||
import React from "react";
|
||||
import { styled, keyframes } from "../stitches.config";
|
||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
||||
|
||||
const slideUpAndFade = keyframes({
|
||||
"0%": { opacity: 0, transform: "translateY(2px)" },
|
||||
"100%": { opacity: 1, transform: "translateY(0)" },
|
||||
});
|
||||
|
||||
const slideRightAndFade = keyframes({
|
||||
"0%": { opacity: 0, transform: "translateX(-2px)" },
|
||||
"100%": { opacity: 1, transform: "translateX(0)" },
|
||||
});
|
||||
|
||||
const slideDownAndFade = keyframes({
|
||||
"0%": { opacity: 0, transform: "translateY(-2px)" },
|
||||
"100%": { opacity: 1, transform: "translateY(0)" },
|
||||
});
|
||||
|
||||
const slideLeftAndFade = keyframes({
|
||||
"0%": { opacity: 0, transform: "translateX(2px)" },
|
||||
"100%": { opacity: 1, transform: "translateX(0)" },
|
||||
});
|
||||
|
||||
const StyledContent = styled(TooltipPrimitive.Content, {
|
||||
borderRadius: 4,
|
||||
padding: "$2 $3",
|
||||
fontSize: 12,
|
||||
lineHeight: 1,
|
||||
color: "$text",
|
||||
backgroundColor: "$background",
|
||||
boxShadow:
|
||||
"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
||||
"@media (prefers-reduced-motion: no-preference)": {
|
||||
animationDuration: "400ms",
|
||||
animationTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)",
|
||||
animationFillMode: "forwards",
|
||||
willChange: "transform, opacity",
|
||||
'&[data-state="delayed-open"]': {
|
||||
'&[data-side="top"]': { animationName: slideDownAndFade },
|
||||
'&[data-side="right"]': { animationName: slideLeftAndFade },
|
||||
'&[data-side="bottom"]': { animationName: slideUpAndFade },
|
||||
'&[data-side="left"]': { animationName: slideRightAndFade },
|
||||
},
|
||||
},
|
||||
".dark &": {
|
||||
boxShadow:
|
||||
"0px 0px 10px 2px rgba(255,255,255,.15), hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
||||
},
|
||||
".light &": {
|
||||
boxShadow:
|
||||
"0px 0px 10px 2px rgba(0,0,0,.15), hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
||||
},
|
||||
});
|
||||
|
||||
const StyledArrow = styled(TooltipPrimitive.Arrow, {
|
||||
fill: "$background",
|
||||
});
|
||||
|
||||
interface ITooltip {
|
||||
content: string;
|
||||
open?: boolean;
|
||||
defaultOpen?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
}
|
||||
|
||||
const Tooltip: React.FC<ITooltip> = ({
|
||||
children,
|
||||
content,
|
||||
open,
|
||||
defaultOpen = false,
|
||||
onOpenChange,
|
||||
}) => {
|
||||
return (
|
||||
<TooltipPrimitive.Root
|
||||
open={open}
|
||||
defaultOpen={defaultOpen}
|
||||
onOpenChange={onOpenChange}
|
||||
>
|
||||
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
|
||||
<StyledContent side="bottom" align="center">
|
||||
{content}
|
||||
<StyledArrow offset={5} width={11} height={5} />
|
||||
</StyledContent>
|
||||
</TooltipPrimitive.Root>
|
||||
);
|
||||
};
|
||||
|
||||
export default Tooltip;
|
||||
356
highlight/c.ts
Normal file
356
highlight/c.ts
Normal file
@@ -0,0 +1,356 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import type { languages } from '../../fillers/monaco-editor-core';
|
||||
|
||||
export const conf: languages.LanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp('^\\s*#pragma\\s+region\\b'),
|
||||
end: new RegExp('^\\s*#pragma\\s+endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const language = <languages.IMonarchLanguage>{
|
||||
defaultToken: '',
|
||||
tokenPostfix: '.c',
|
||||
|
||||
brackets: [
|
||||
{ token: 'delimiter.curly', open: '{', close: '}' },
|
||||
{ token: 'delimiter.parenthesis', open: '(', close: ')' },
|
||||
{ token: 'delimiter.square', open: '[', close: ']' },
|
||||
{ token: 'delimiter.angle', open: '<', close: '>' }
|
||||
],
|
||||
|
||||
keywords: [
|
||||
'abstract',
|
||||
'amp',
|
||||
'array',
|
||||
'asm',
|
||||
'auto',
|
||||
'break',
|
||||
'case',
|
||||
'char',
|
||||
'const',
|
||||
'continue',
|
||||
'default',
|
||||
'do',
|
||||
'double',
|
||||
'dynamic_cast',
|
||||
'else',
|
||||
'enum',
|
||||
'extern',
|
||||
'float',
|
||||
'for',
|
||||
'goto',
|
||||
'if',
|
||||
'inline',
|
||||
'int',
|
||||
'long',
|
||||
'register',
|
||||
'restrict',
|
||||
'return',
|
||||
'short',
|
||||
'signed',
|
||||
'sizeof',
|
||||
'static',
|
||||
'struct',
|
||||
'switch',
|
||||
'typedef',
|
||||
'union',
|
||||
'unsigned',
|
||||
'void',
|
||||
'volatile',
|
||||
'wchar_t',
|
||||
'where',
|
||||
'while',
|
||||
|
||||
'__abstract', // reserved word with two underscores
|
||||
'__alignof',
|
||||
'__asm',
|
||||
'__assume',
|
||||
'__based',
|
||||
'__box',
|
||||
'__builtin_alignof',
|
||||
'__cdecl',
|
||||
'__clrcall',
|
||||
'__declspec',
|
||||
'__delegate',
|
||||
'__event',
|
||||
'__except',
|
||||
'__fastcall',
|
||||
'__finally',
|
||||
'__forceinline',
|
||||
'__gc',
|
||||
'__hook',
|
||||
'__identifier',
|
||||
'__if_exists',
|
||||
'__if_not_exists',
|
||||
'__inline',
|
||||
'__int128',
|
||||
'__int16',
|
||||
'__int32',
|
||||
'__int64',
|
||||
'__int8',
|
||||
'__interface',
|
||||
'__leave',
|
||||
'__m128',
|
||||
'__m128d',
|
||||
'__m128i',
|
||||
'__m256',
|
||||
'__m256d',
|
||||
'__m256i',
|
||||
'__m64',
|
||||
'__multiple_inheritance',
|
||||
'__newslot',
|
||||
'__nogc',
|
||||
'__noop',
|
||||
'__nounwind',
|
||||
'__novtordisp',
|
||||
'__pascal',
|
||||
'__pin',
|
||||
'__pragma',
|
||||
'__property',
|
||||
'__ptr32',
|
||||
'__ptr64',
|
||||
'__raise',
|
||||
'__restrict',
|
||||
'__resume',
|
||||
'__sealed',
|
||||
'__single_inheritance',
|
||||
'__stdcall',
|
||||
'__super',
|
||||
'__thiscall',
|
||||
'__try',
|
||||
'__try_cast',
|
||||
'__typeof',
|
||||
'__unaligned',
|
||||
'__unhook',
|
||||
'__uuidof',
|
||||
'__value',
|
||||
'__virtual_inheritance',
|
||||
'__w64',
|
||||
'__wchar_t'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=',
|
||||
'>',
|
||||
'<',
|
||||
'!',
|
||||
'~',
|
||||
'?',
|
||||
':',
|
||||
'==',
|
||||
'<=',
|
||||
'>=',
|
||||
'!=',
|
||||
'&&',
|
||||
'||',
|
||||
'++',
|
||||
'--',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'&',
|
||||
'|',
|
||||
'^',
|
||||
'%',
|
||||
'<<',
|
||||
'>>',
|
||||
'+=',
|
||||
'-=',
|
||||
'*=',
|
||||
'/=',
|
||||
'&=',
|
||||
'|=',
|
||||
'^=',
|
||||
'%=',
|
||||
'<<=',
|
||||
'>>='
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
integersuffix: /([uU](ll|LL|l|L)|(ll|LL|l|L)?[uU]?)/,
|
||||
floatsuffix: /[fFlL]?/,
|
||||
encoding: /u|u8|U|L/,
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// C++ 11 Raw String
|
||||
[/@encoding?R\"(?:([^ ()\\\t]*))\(/, { token: 'string.raw.begin', next: '@raw.$1' }],
|
||||
|
||||
// identifiers and keywords
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// The preprocessor checks must be before whitespace as they check /^\s*#/ which
|
||||
// otherwise fails to match later after other whitespace has been removed.
|
||||
|
||||
// Inclusion
|
||||
[/^\s*#\s*include/, { token: 'keyword.directive.include', next: '@include' }],
|
||||
|
||||
// Preprocessor directive
|
||||
[/^\s*#\s*\w+/, 'keyword.directive'],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// [[ attributes ]].
|
||||
[/\[\s*\[/, { token: 'annotation', next: '@annotation' }],
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/, 'number.hex'],
|
||||
[/0[0-7']*[0-7](@integersuffix)/, 'number.octal'],
|
||||
[/0[bB][0-1']*[0-1](@integersuffix)/, 'number.binary'],
|
||||
[/\d[\d']*\d(@integersuffix)/, 'number'],
|
||||
[/\d(@integersuffix)/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
||||
[/'/, 'string.invalid']
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*\\$/, 'comment', '@linecomment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\*\//, 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
//For use with continuous line comments
|
||||
linecomment: [
|
||||
[/.*[^\\]$/, 'comment', '@pop'],
|
||||
[/[^]+/, 'comment']
|
||||
],
|
||||
|
||||
//Identical copy of comment above, except for the addition of .doc
|
||||
doccomment: [
|
||||
[/[^\/*]+/, 'comment.doc'],
|
||||
[/\*\//, 'comment.doc', '@pop'],
|
||||
[/[\/*]/, 'comment.doc']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
|
||||
raw: [
|
||||
[
|
||||
/(.*)(\))(?:([^ ()\\\t"]*))(\")/,
|
||||
{
|
||||
cases: {
|
||||
'$3==$S2': [
|
||||
'string.raw',
|
||||
'string.raw.end',
|
||||
'string.raw.end',
|
||||
{ token: 'string.raw.end', next: '@pop' }
|
||||
],
|
||||
'@default': ['string.raw', 'string.raw', 'string.raw', 'string.raw']
|
||||
}
|
||||
}
|
||||
],
|
||||
[/.*/, 'string.raw']
|
||||
],
|
||||
|
||||
annotation: [
|
||||
{ include: '@whitespace' },
|
||||
[/[a-zA-Z0-9_]+/, 'annotation'],
|
||||
[/[,:]/, 'delimiter'],
|
||||
[/[()]/, '@brackets'],
|
||||
[/\]\s*\]/, { token: 'annotation', next: '@pop' }]
|
||||
],
|
||||
|
||||
include: [
|
||||
[
|
||||
/(\s*)(<)([^<>]*)(>)/,
|
||||
[
|
||||
'',
|
||||
'keyword.directive.include.begin',
|
||||
|
||||
|
||||
'string.include.identifier',
|
||||
{ token: 'keyword.directive.include.end', next: '@pop' }
|
||||
]
|
||||
],
|
||||
[
|
||||
/(\s*)(")([^"]*)(")/,
|
||||
[
|
||||
'',
|
||||
'keyword.directive.include.begin',
|
||||
'string.include.identifier',
|
||||
{ token: 'keyword.directive.include.end', next: '@pop' }
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -19,6 +19,7 @@
|
||||
"@radix-ui/react-dialog": "^0.1.1",
|
||||
"@radix-ui/react-dropdown-menu": "^0.1.1",
|
||||
"@radix-ui/react-id": "^0.1.1",
|
||||
"@radix-ui/react-tooltip": "^0.1.7",
|
||||
"@stitches/react": "^1.2.6-0",
|
||||
"base64-js": "^1.5.1",
|
||||
"dinero.js": "^1.9.1",
|
||||
|
||||
@@ -68,11 +68,11 @@ export const addFaucetAccount = async (showToast: boolean = false) => {
|
||||
// fetch initial faucets
|
||||
(async function fetchFaucets() {
|
||||
if (typeof window !== 'undefined') {
|
||||
if (state.accounts.length < 2) {
|
||||
if (state.accounts.length === 0) {
|
||||
await addFaucetAccount();
|
||||
setTimeout(() => {
|
||||
addFaucetAccount();
|
||||
}, 10000);
|
||||
// setTimeout(() => {
|
||||
// addFaucetAccount();
|
||||
// }, 10000);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -15,6 +15,13 @@ const hash = async (string: string) => {
|
||||
return hashHex;
|
||||
}
|
||||
|
||||
function toHex(str: string) {
|
||||
var result = '';
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
result += str.charCodeAt(i).toString(16);
|
||||
}
|
||||
return result.toUpperCase();
|
||||
}
|
||||
|
||||
function arrayBufferToHex(arrayBuffer?: ArrayBuffer | null) {
|
||||
if (!arrayBuffer) {
|
||||
@@ -64,7 +71,7 @@ export const deployHook = async (account: IAccount & { name?: string }, data: Se
|
||||
).toUpperCase());
|
||||
const hookOnValues: (keyof TTS)[] = data.Invoke.map(tt => tt.value);
|
||||
const { HookParameters } = data;
|
||||
const filteredHookParameters = HookParameters.filter(hp => hp.HookParameter.HookParameterName && hp.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 => {
|
||||
// return {
|
||||
// HookGrant: {
|
||||
@@ -74,6 +81,7 @@ export const deployHook = async (account: IAccount & { name?: string }, data: Se
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
const tx = {
|
||||
Account: account.address,
|
||||
@@ -145,13 +153,18 @@ export const deleteHook = async (account: IAccount & { name?: string }) => {
|
||||
if (!state.client) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentAccount = state.accounts.find(
|
||||
(acc) => acc.address === account.address
|
||||
);
|
||||
if (currentAccount?.isLoading || !currentAccount?.hooks.length) {
|
||||
return
|
||||
}
|
||||
if (typeof window !== "undefined") {
|
||||
const tx = {
|
||||
Account: account.address,
|
||||
TransactionType: "SetHook",
|
||||
Sequence: account.sequence,
|
||||
Fee: "1000000",
|
||||
Fee: "100000",
|
||||
Hooks: [
|
||||
{
|
||||
Hook: {
|
||||
@@ -164,9 +177,7 @@ export const deleteHook = async (account: IAccount & { name?: string }) => {
|
||||
|
||||
const keypair = derive.familySeed(account.secret);
|
||||
const { signedTransaction } = sign(tx, keypair);
|
||||
const currentAccount = state.accounts.find(
|
||||
(acc) => acc.address === account.address
|
||||
);
|
||||
|
||||
if (currentAccount) {
|
||||
currentAccount.isLoading = true;
|
||||
}
|
||||
@@ -188,6 +199,7 @@ export const deleteHook = async (account: IAccount & { name?: string }) => {
|
||||
type: "success",
|
||||
message: `[${submitRes.engine_result}] ${submitRes.engine_result_message} Validated ledger index: ${submitRes.validated_ledger_index}`,
|
||||
});
|
||||
currentAccount.hooks = [];
|
||||
} else {
|
||||
toast.error(`${submitRes.engine_result_message || submitRes.error_exception}`, { id: toastId })
|
||||
state.deployLogs.push({
|
||||
|
||||
@@ -3,7 +3,6 @@ import Router from "next/router";
|
||||
import state from '../index';
|
||||
import { templateFileIds } from '../constants';
|
||||
|
||||
|
||||
const octokit = new Octokit();
|
||||
|
||||
/* Fetches Gist files from Githug Gists based on
|
||||
@@ -19,21 +18,42 @@ export const fetchFiles = (gistId: string) => {
|
||||
|
||||
octokit
|
||||
.request("GET /gists/{gist_id}", { gist_id: gistId })
|
||||
.then(res => {
|
||||
.then(async res => {
|
||||
if (!Object.values(templateFileIds).includes(gistId)) {
|
||||
return res
|
||||
}
|
||||
// in case of templates, fetch header file(s) and append to res
|
||||
return octokit.request("GET /gists/{gist_id}", { gist_id: templateFileIds.headers }).then(({ data: { files: headerFiles } }) => {
|
||||
const files = { ...res.data.files, ...headerFiles }
|
||||
res.data.files = files
|
||||
return res
|
||||
})
|
||||
let resHeaderJson;
|
||||
try {
|
||||
const resHeader = await fetch(`${process.env.NEXT_PUBLIC_COMPILE_API_BASE_URL}/api/header-files`);
|
||||
if (resHeader.ok) {
|
||||
resHeaderJson = await resHeader.json();
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
const files = {
|
||||
...res.data.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;
|
||||
|
||||
return res;
|
||||
// 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 } }) => {
|
||||
// const files = { ...res.data.files, ...headerFiles }
|
||||
// console.log(headerFiles)
|
||||
// res.data.files = files
|
||||
// return res
|
||||
// })
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.files && Object.keys(res.data.files).length > 0) {
|
||||
const files = Object.keys(res.data.files).map((filename) => ({
|
||||
name: res.data.files?.[filename]?.filename || "noname.c",
|
||||
name: res.data.files?.[filename]?.filename || "untitled.c",
|
||||
language: res.data.files?.[filename]?.language?.toLowerCase() || "",
|
||||
content: res.data.files?.[filename]?.content || "",
|
||||
}));
|
||||
|
||||
@@ -24,6 +24,7 @@ export const importAccount = (secret: string) => {
|
||||
sequence: 1,
|
||||
hooks: [],
|
||||
isLoading: false,
|
||||
version: '2'
|
||||
});
|
||||
return toast.success("Account imported successfully!");
|
||||
};
|
||||
@@ -14,8 +14,7 @@ export const templateFileIds = {
|
||||
'carbon': 'a9fbcaf1b816b198c7fc0f62962bebf2',
|
||||
'doubler': '56b86174aeb70b2b48eee962bad3e355',
|
||||
'peggy': 'd21298a37e1550b781682014762a567b',
|
||||
'headers': '9b448e8a55fab11ef5d1274cb59f9cf3'
|
||||
|
||||
'headers': '55f639bce59a49c58c45e663776b5138'
|
||||
}
|
||||
|
||||
export const apiHeaderFiles = ['hookapi.h', 'sfcodes.h', 'hookmacro.h']
|
||||
|
||||
@@ -121,7 +121,7 @@ if (typeof window !== "undefined") {
|
||||
initialAccounts = JSON.parse(localStorageAccounts);
|
||||
}
|
||||
// filter out old accounts (they do not have version property at all)
|
||||
initialAccounts = initialAccounts.filter(acc => acc.version === '2');
|
||||
// initialAccounts = initialAccounts.filter(acc => acc.version === '2');
|
||||
}
|
||||
|
||||
// Initialize state
|
||||
|
||||
@@ -25,6 +25,8 @@ import hooksGuardInFor from "./md/hooks-guard-in-for.md";
|
||||
import hooksGuardInWhile from "./md/hooks-guard-in-while.md";
|
||||
import hooksHashBufLen from "./md/hooks-hash-buf-len.md";
|
||||
import hooksKeyletBufLen from "./md/hooks-keylet-buf-len.md";
|
||||
import hooksParamBufLen from "./md/hooks-param-buf-len.md";
|
||||
import hooksParamSetBufLen from "./md/hooks-param-set-buf-len.md";
|
||||
import hooksRaddrConvBufLen from "./md/hooks-raddr-conv-buf-len.md";
|
||||
import hooksRaddrConvPure from "./md/hooks-raddr-conv-pure.md";
|
||||
import hooksReserveLimit from "./md/hooks-reserve-limit.md";
|
||||
@@ -69,6 +71,8 @@ const docs: { [key: string]: string; } = {
|
||||
"hooks-guard-in-while": hooksGuardInWhile,
|
||||
"hooks-hash-buf-len": hooksHashBufLen,
|
||||
"hooks-keylet-buf-len": hooksKeyletBufLen,
|
||||
"hooks-param-buf-len": hooksParamBufLen,
|
||||
"hooks-param-set-buf-len": hooksParamSetBufLen,
|
||||
"hooks-raddr-conv-buf-len": hooksRaddrConvBufLen,
|
||||
"hooks-raddr-conv-pure": hooksRaddrConvPure,
|
||||
"hooks-reserve-limit": hooksReserveLimit,
|
||||
|
||||
7
xrpl-hooks-docs/md/hooks-param-buf-len.md
Normal file
7
xrpl-hooks-docs/md/hooks-param-buf-len.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# hooks-param-buf-len
|
||||
|
||||
Function [hook_param](https://xrpl-hooks.readme.io/v2.0/reference/hook_param) expects a limited-length name input and produces fixed-size value output.
|
||||
|
||||
This check warns about invalid sizes of input and output buffers (if they're specified by constants - variable parameters are ignored).
|
||||
|
||||
[Read more](https://xrpl-hooks.readme.io/v2.0/docs/parameters)
|
||||
7
xrpl-hooks-docs/md/hooks-param-set-buf-len.md
Normal file
7
xrpl-hooks-docs/md/hooks-param-set-buf-len.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# hooks-param-set-buf-len
|
||||
|
||||
Function [hook_param_set](https://xrpl-hooks.readme.io/v2.0/reference/hook_param_set) expects limited-length name, fixed-length hash and limited-length value inputs.
|
||||
|
||||
This check warns about invalid sizes of input buffers (if they're specified by constants - variable parameters are ignored).
|
||||
|
||||
[Read more](https://xrpl-hooks.readme.io/v2.0/docs/parameters)
|
||||
36
yarn.lock
36
yarn.lock
@@ -762,6 +762,27 @@
|
||||
"@babel/runtime" "^7.13.10"
|
||||
"@radix-ui/react-compose-refs" "0.1.0"
|
||||
|
||||
"@radix-ui/react-tooltip@^0.1.7":
|
||||
version "0.1.7"
|
||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-tooltip/-/react-tooltip-0.1.7.tgz#6f8c00d6e489565d14abf209ce0fb8853c8c8ee3"
|
||||
integrity sha512-eiBUsVOHenZ0JR16tl970bB0DafJBz6mFgSGfIGIVpflFj0LIsIDiLMsYyvYdx1KwwsIUDTEZtxcPm/sWjPzqA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.13.10"
|
||||
"@radix-ui/primitive" "0.1.0"
|
||||
"@radix-ui/react-compose-refs" "0.1.0"
|
||||
"@radix-ui/react-context" "0.1.1"
|
||||
"@radix-ui/react-id" "0.1.5"
|
||||
"@radix-ui/react-popper" "0.1.4"
|
||||
"@radix-ui/react-portal" "0.1.4"
|
||||
"@radix-ui/react-presence" "0.1.2"
|
||||
"@radix-ui/react-primitive" "0.1.4"
|
||||
"@radix-ui/react-slot" "0.1.2"
|
||||
"@radix-ui/react-use-controllable-state" "0.1.0"
|
||||
"@radix-ui/react-use-escape-keydown" "0.1.0"
|
||||
"@radix-ui/react-use-previous" "0.1.1"
|
||||
"@radix-ui/react-use-rect" "0.1.1"
|
||||
"@radix-ui/react-visually-hidden" "0.1.4"
|
||||
|
||||
"@radix-ui/react-use-body-pointer-events@0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-body-pointer-events/-/react-use-body-pointer-events-0.1.1.tgz#63e7fd81ca7ffd30841deb584cd2b7f460df2597"
|
||||
@@ -807,6 +828,13 @@
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.13.10"
|
||||
|
||||
"@radix-ui/react-use-previous@0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-previous/-/react-use-previous-0.1.1.tgz#0226017f72267200f6e832a7103760e96a6db5d0"
|
||||
integrity sha512-O/ZgrDBr11dR8rhO59ED8s5zIXBRFi8MiS+CmFGfi7MJYdLbfqVOmQU90Ghf87aifEgWe6380LA69KBneaShAg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.13.10"
|
||||
|
||||
"@radix-ui/react-use-rect@0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-rect/-/react-use-rect-0.1.1.tgz#6c15384beee59c086e75b89a7e66f3d2e583a856"
|
||||
@@ -822,6 +850,14 @@
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.13.10"
|
||||
|
||||
"@radix-ui/react-visually-hidden@0.1.4":
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-visually-hidden/-/react-visually-hidden-0.1.4.tgz#6c75eae34fb5d084b503506fbfc05587ced05f03"
|
||||
integrity sha512-K/q6AEEzqeeEq/T0NPChvBqnwlp8Tl4NnQdrI/y8IOY7BRR+Ug0PEsVk6g48HJ7cA1//COugdxXXVVK/m0X1mA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.13.10"
|
||||
"@radix-ui/react-primitive" "0.1.4"
|
||||
|
||||
"@radix-ui/rect@0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-0.1.1.tgz#95b5ba51f469bea6b1b841e2d427e17e37d38419"
|
||||
|
||||
Reference in New Issue
Block a user