Compare commits
3 Commits
feat/engin
...
fix/renami
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
934283976a | ||
|
|
0d9e9e7b45 | ||
|
|
2c2bf59bcd |
@@ -5,7 +5,6 @@ import { subscribeKey } from 'valtio/utils'
|
|||||||
import { Select } from '.'
|
import { Select } from '.'
|
||||||
import state, { ILog, transactionsState } from '../state'
|
import state, { ILog, transactionsState } from '../state'
|
||||||
import { extractJSON } from '../utils/json'
|
import { extractJSON } from '../utils/json'
|
||||||
import EnrichLog from './EnrichLog'
|
|
||||||
import LogBox from './LogBox'
|
import LogBox from './LogBox'
|
||||||
|
|
||||||
interface ISelect<T = string> {
|
interface ISelect<T = string> {
|
||||||
@@ -100,11 +99,6 @@ const addListeners = (account: ISelect | null) => {
|
|||||||
|
|
||||||
subscribeKey(streamState, 'selectedAccount', addListeners)
|
subscribeKey(streamState, 'selectedAccount', addListeners)
|
||||||
|
|
||||||
const clearLog = () => {
|
|
||||||
streamState.logs = []
|
|
||||||
streamState.statusChangeTimestamp = Date.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
const DebugStream = () => {
|
const DebugStream = () => {
|
||||||
const { selectedAccount, logs } = useSnapshot(streamState)
|
const { selectedAccount, logs } = useSnapshot(streamState)
|
||||||
const { activeHeader: activeTxTab } = useSnapshot(transactionsState)
|
const { activeHeader: activeTxTab } = useSnapshot(transactionsState)
|
||||||
@@ -140,6 +134,11 @@ const DebugStream = () => {
|
|||||||
streamState.selectedAccount = account
|
streamState.selectedAccount = account
|
||||||
}, [activeTxTab])
|
}, [activeTxTab])
|
||||||
|
|
||||||
|
const clearLog = () => {
|
||||||
|
streamState.logs = []
|
||||||
|
streamState.statusChangeTimestamp = Date.now()
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LogBox enhanced renderNav={renderNav} title="Debug stream" logs={logs} clearLog={clearLog} />
|
<LogBox enhanced renderNav={renderNav} title="Debug stream" logs={logs} clearLog={clearLog} />
|
||||||
)
|
)
|
||||||
@@ -158,11 +157,9 @@ export const pushLog = (str: any, opts: Partial<Pick<ILog, 'type'>> = {}): ILog
|
|||||||
const timestring = !timestamp ? tm : new Date(timestamp).toLocaleTimeString()
|
const timestring = !timestamp ? tm : new Date(timestamp).toLocaleTimeString()
|
||||||
|
|
||||||
const extracted = extractJSON(msg)
|
const extracted = extractJSON(msg)
|
||||||
const _message = !extracted ? msg : msg.slice(0, extracted.start) + msg.slice(extracted.end + 1)
|
const message = !extracted ? msg : msg.slice(0, extracted.start) + msg.slice(extracted.end + 1)
|
||||||
const message = ref(<EnrichLog str={_message} />)
|
|
||||||
|
|
||||||
const _jsonData = extracted ? JSON.stringify(extracted.result, null, 2) : undefined
|
const jsonData = extracted ? JSON.stringify(extracted.result, null, 2) : undefined
|
||||||
const jsonData = _jsonData ? ref(<EnrichLog str={_jsonData} />) : undefined
|
|
||||||
|
|
||||||
if (extracted?.result?.id?._Request?.includes('hooks-builder-req')) {
|
if (extracted?.result?.id?._Request?.includes('hooks-builder-req')) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
import { FC, useState } from 'react'
|
|
||||||
import regexifyString from 'regexify-string'
|
|
||||||
import { useSnapshot } from 'valtio'
|
|
||||||
import { Link } from '.'
|
|
||||||
import state from '../state'
|
|
||||||
import { AccountDialog } from './Accounts'
|
|
||||||
import Tooltip from './Tooltip'
|
|
||||||
import hookSetCodes from '../content/hook-set-codes.json'
|
|
||||||
import { capitalize } from '../utils/helpers'
|
|
||||||
|
|
||||||
interface EnrichLogProps {
|
|
||||||
str?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const EnrichLog: FC<EnrichLogProps> = ({ str }) => {
|
|
||||||
const { accounts } = useSnapshot(state)
|
|
||||||
const [dialogAccount, setDialogAccount] = useState<string | null>(null)
|
|
||||||
if (!str || !accounts.length) return <>{str}</>
|
|
||||||
|
|
||||||
const addrs = accounts.map(acc => acc.address)
|
|
||||||
const regex = `(${addrs.join('|')}|HookSet\\(\\d+\\))`
|
|
||||||
const res = regexifyString({
|
|
||||||
pattern: new RegExp(regex, 'gim'),
|
|
||||||
decorator: (match, idx) => {
|
|
||||||
if (match.startsWith('r')) {
|
|
||||||
// Account
|
|
||||||
const name = accounts.find(acc => acc.address === match)?.name
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={match + idx}
|
|
||||||
as="a"
|
|
||||||
onClick={() => setDialogAccount(match)}
|
|
||||||
title={match}
|
|
||||||
highlighted
|
|
||||||
>
|
|
||||||
{name || match}
|
|
||||||
</Link>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (match.startsWith('HookSet')) {
|
|
||||||
const code = match.match(/^HookSet\((\d+)\)/)?.[1]
|
|
||||||
const val = hookSetCodes.find(v => code && v.code === +code)
|
|
||||||
console.log({ code, val })
|
|
||||||
if (!val) return match
|
|
||||||
|
|
||||||
const content = capitalize(val.description) || 'No hint available!'
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
HookSet(
|
|
||||||
<Tooltip content={content}>
|
|
||||||
<Link>{val.identifier}</Link>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return match
|
|
||||||
},
|
|
||||||
input: str
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{res}
|
|
||||||
<AccountDialog
|
|
||||||
setActiveAccountAddress={setDialogAccount}
|
|
||||||
activeAccountAddress={dialogAccount}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default EnrichLog
|
|
||||||
@@ -200,15 +200,15 @@ const HooksEditor = () => {
|
|||||||
defaultValue={file?.content}
|
defaultValue={file?.content}
|
||||||
// onChange={val => (state.files[snap.active].content = val)} // Auto save?
|
// onChange={val => (state.files[snap.active].content = val)} // Auto save?
|
||||||
beforeMount={monaco => {
|
beforeMount={monaco => {
|
||||||
if (!snap.editorCtx) {
|
// if (!snap.editorCtx) {
|
||||||
snap.files.forEach(file =>
|
// snap.files.forEach(file =>
|
||||||
monaco.editor.createModel(
|
// monaco.editor.createModel(
|
||||||
file.content,
|
// file.content,
|
||||||
file.language,
|
// file.language,
|
||||||
monaco.Uri.parse(`file:///work/c/${file.name}`)
|
// monaco.Uri.parse(`file:///work/c/${file.name}`)
|
||||||
)
|
// )
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
|
|
||||||
// create the web socket
|
// create the web socket
|
||||||
if (!subscriptionRef.current) {
|
if (!subscriptionRef.current) {
|
||||||
@@ -218,6 +218,11 @@ const HooksEditor = () => {
|
|||||||
aliases: ['C', 'c', 'H', 'h'],
|
aliases: ['C', 'c', 'H', 'h'],
|
||||||
mimetypes: ['text/plain']
|
mimetypes: ['text/plain']
|
||||||
})
|
})
|
||||||
|
monaco.languages.register({
|
||||||
|
id: 'text',
|
||||||
|
extensions: ['.txt'],
|
||||||
|
mimetypes: ['text/plain'],
|
||||||
|
})
|
||||||
MonacoServices.install(monaco)
|
MonacoServices.install(monaco)
|
||||||
const webSocket = createWebSocket(
|
const webSocket = createWebSocket(
|
||||||
process.env.NEXT_PUBLIC_LANGUAGE_SERVER_API_ENDPOINT || ''
|
process.env.NEXT_PUBLIC_LANGUAGE_SERVER_API_ENDPOINT || ''
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import { useRef, useLayoutEffect, ReactNode, FC, useState } from 'react'
|
import { useRef, useLayoutEffect, ReactNode, FC, useState, useCallback } from 'react'
|
||||||
import { IconProps, Notepad, Prohibit } from 'phosphor-react'
|
import { IconProps, Notepad, Prohibit } from 'phosphor-react'
|
||||||
import useStayScrolled from 'react-stay-scrolled'
|
import useStayScrolled from 'react-stay-scrolled'
|
||||||
import NextLink from 'next/link'
|
import NextLink from 'next/link'
|
||||||
|
|
||||||
import Container from './Container'
|
import Container from './Container'
|
||||||
import LogText from './LogText'
|
import LogText from './LogText'
|
||||||
import { ILog } from '../state'
|
import state, { ILog } from '../state'
|
||||||
import { Pre, Link, Heading, Button, Text, Flex, Box } from '.'
|
import { Pre, Link, Heading, Button, Text, Flex, Box } from '.'
|
||||||
|
import regexifyString from 'regexify-string'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
import { AccountDialog } from './Accounts'
|
||||||
|
|
||||||
interface ILogBox {
|
interface ILogBox {
|
||||||
title: string
|
title: string
|
||||||
@@ -140,25 +143,70 @@ const LogBox: FC<ILogBox> = ({
|
|||||||
export const Log: FC<ILog> = ({
|
export const Log: FC<ILog> = ({
|
||||||
type,
|
type,
|
||||||
timestring,
|
timestring,
|
||||||
message,
|
message: _message,
|
||||||
link,
|
link,
|
||||||
linkText,
|
linkText,
|
||||||
defaultCollapsed,
|
defaultCollapsed,
|
||||||
jsonData
|
jsonData: _jsonData
|
||||||
}) => {
|
}) => {
|
||||||
const [expanded, setExpanded] = useState(!defaultCollapsed)
|
const [expanded, setExpanded] = useState(!defaultCollapsed)
|
||||||
|
const { accounts } = useSnapshot(state)
|
||||||
|
const [dialogAccount, setDialogAccount] = useState<string | null>(null)
|
||||||
|
|
||||||
|
const enrichAccounts = useCallback(
|
||||||
|
(str?: string): ReactNode => {
|
||||||
|
if (!str || !accounts.length) return str
|
||||||
|
|
||||||
|
const pattern = `(${accounts.map(acc => acc.address).join('|')})`
|
||||||
|
const res = regexifyString({
|
||||||
|
pattern: new RegExp(pattern, 'gim'),
|
||||||
|
decorator: (match, idx) => {
|
||||||
|
const name = accounts.find(acc => acc.address === match)?.name
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
key={match + idx}
|
||||||
|
as="a"
|
||||||
|
onClick={() => setDialogAccount(match)}
|
||||||
|
title={match}
|
||||||
|
highlighted
|
||||||
|
>
|
||||||
|
{name || match}
|
||||||
|
</Link>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
input: str
|
||||||
|
})
|
||||||
|
|
||||||
|
return <>{res}</>
|
||||||
|
},
|
||||||
|
[accounts]
|
||||||
|
)
|
||||||
|
|
||||||
|
let message: ReactNode
|
||||||
|
|
||||||
|
if (typeof _message === 'string') {
|
||||||
|
_message = _message.trim().replace(/\n /gi, '\n')
|
||||||
|
if (_message) message = enrichAccounts(_message)
|
||||||
|
else message = <Text muted>{'""'}</Text>
|
||||||
|
} else {
|
||||||
|
message = _message
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonData = enrichAccounts(_jsonData)
|
||||||
|
|
||||||
if (message === undefined) message = <Text muted>{'undefined'}</Text>
|
|
||||||
else if (message === '') message = <Text muted>{'""'}</Text>
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<AccountDialog
|
||||||
|
setActiveAccountAddress={setDialogAccount}
|
||||||
|
activeAccountAddress={dialogAccount}
|
||||||
|
/>
|
||||||
<LogText variant={type}>
|
<LogText variant={type}>
|
||||||
{timestring && (
|
{timestring && (
|
||||||
<Text muted monospace>
|
<Text muted monospace>
|
||||||
{timestring}{' '}
|
{timestring}{' '}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<Pre>{message}</Pre>
|
<Pre>{message} </Pre>
|
||||||
{link && (
|
{link && (
|
||||||
<NextLink href={link} shallow passHref>
|
<NextLink href={link} shallow passHref>
|
||||||
<Link as="a">{linkText}</Link>
|
<Link as="a">{linkText}</Link>
|
||||||
@@ -171,6 +219,7 @@ export const Log: FC<ILog> = ({
|
|||||||
)}
|
)}
|
||||||
{expanded && jsonData && <Pre block>{jsonData}</Pre>}
|
{expanded && jsonData && <Pre block>{jsonData}</Pre>}
|
||||||
</LogText>
|
</LogText>
|
||||||
|
<br />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { FC } from 'react'
|
|
||||||
import { Link } from '.'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
result?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const ResultLink: FC<Props> = ({ result }) => {
|
|
||||||
if (!result) return null
|
|
||||||
let href: string
|
|
||||||
if (result === 'tesSUCCESS') {
|
|
||||||
href = 'https://xrpl.org/tes-success.html'
|
|
||||||
} else {
|
|
||||||
// Going shortcut here because of url structure, if that changes we will do it manually
|
|
||||||
href = `https://xrpl.org/${result.slice(0, 3)}-codes.html`
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Link as="a" href={href} target="_blank" rel="noopener noreferrer">
|
|
||||||
{result}
|
|
||||||
</Link>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ResultLink
|
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from './Dialog'
|
} from './Dialog'
|
||||||
import { Plus, X } from 'phosphor-react'
|
import { Plus, X } from 'phosphor-react'
|
||||||
import { styled } from '../stitches.config'
|
import { styled } from '../stitches.config'
|
||||||
import { capitalize } from '../utils/helpers'
|
import { capitalize, getFileExtention } from '../utils/helpers'
|
||||||
import ContextMenu, { ContentMenuOption } from './ContextMenu'
|
import ContextMenu, { ContentMenuOption } from './ContextMenu'
|
||||||
|
|
||||||
const ErrorText = styled(Text, {
|
const ErrorText = styled(Text, {
|
||||||
@@ -97,7 +97,7 @@ export const Tabs = ({
|
|||||||
if (!tabname) {
|
if (!tabname) {
|
||||||
return { error: `Please enter ${label.toLocaleLowerCase()} name.` }
|
return { error: `Please enter ${label.toLocaleLowerCase()} name.` }
|
||||||
}
|
}
|
||||||
let ext = (tabname.includes('.') && tabname.split('.').pop()) || ''
|
let ext = getFileExtention(tabname)
|
||||||
|
|
||||||
if (!ext && defaultExtension) {
|
if (!ext && defaultExtension) {
|
||||||
ext = defaultExtension
|
ext = defaultExtension
|
||||||
@@ -109,7 +109,7 @@ export const Tabs = ({
|
|||||||
if (extensionRequired && !ext) {
|
if (extensionRequired && !ext) {
|
||||||
return { error: 'File extension is required!' }
|
return { error: 'File extension is required!' }
|
||||||
}
|
}
|
||||||
if (allowedExtensions && !allowedExtensions.includes(ext)) {
|
if (allowedExtensions && ext && !allowedExtensions.includes(ext)) {
|
||||||
return { error: 'This file extension is not allowed!' }
|
return { error: 'This file extension is not allowed!' }
|
||||||
}
|
}
|
||||||
if (headerExtraValidation && !tabname.match(headerExtraValidation.regex)) {
|
if (headerExtraValidation && !tabname.match(headerExtraValidation.regex)) {
|
||||||
|
|||||||
@@ -72,12 +72,7 @@ const Tooltip: React.FC<React.ComponentProps<typeof StyledContent> & ITooltip> =
|
|||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<TooltipPrimitive.Root
|
<TooltipPrimitive.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>
|
||||||
open={open}
|
|
||||||
defaultOpen={defaultOpen}
|
|
||||||
onOpenChange={onOpenChange}
|
|
||||||
delayDuration={100}
|
|
||||||
>
|
|
||||||
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
|
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
|
||||||
<StyledContent side="bottom" align="center" {...rest}>
|
<StyledContent side="bottom" align="center" {...rest}>
|
||||||
<div dangerouslySetInnerHTML={{ __html: content }} />
|
<div dangerouslySetInnerHTML={{ __html: content }} />
|
||||||
|
|||||||
@@ -1,409 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"code": 1,
|
|
||||||
"identifier": "AMENDMENT_DISABLED",
|
|
||||||
"description": "attempt to HookSet when amendment is not yet enabled."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 2,
|
|
||||||
"identifier": "API_ILLEGAL",
|
|
||||||
"description": "HookSet object contained HookApiVersion for existing HookDefinition"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 3,
|
|
||||||
"identifier": "API_INVALID",
|
|
||||||
"description": "HookSet object contained HookApiVersion for unrecognised hook API "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 4,
|
|
||||||
"identifier": "API_MISSING",
|
|
||||||
"description": "HookSet object lacked HookApiVersion"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 5,
|
|
||||||
"identifier": "BLOCK_ILLEGAL",
|
|
||||||
"description": " a block end instruction moves execution below depth 0 {{}}`}` <= like this"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 6,
|
|
||||||
"identifier": "CALL_ILLEGAL",
|
|
||||||
"description": "wasm tries to call a non-whitelisted function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 7,
|
|
||||||
"identifier": "CALL_INDIRECT",
|
|
||||||
"description": "wasm used call indirect instruction which is disallowed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 8,
|
|
||||||
"identifier": "CREATE_FLAG",
|
|
||||||
"description": "create operation requires hsoOVERRIDE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 9,
|
|
||||||
"identifier": "DELETE_FIELD",
|
|
||||||
"description": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 10,
|
|
||||||
"identifier": "DELETE_FLAG",
|
|
||||||
"description": "delete operation requires hsoOVERRIDE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 11,
|
|
||||||
"identifier": "DELETE_NOTHING",
|
|
||||||
"description": "delete operation would delete nothing"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 12,
|
|
||||||
"identifier": "EXPORTS_MISSING",
|
|
||||||
"description": "hook did not export *any* functions (should be cbak, hook)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 13,
|
|
||||||
"identifier": "EXPORT_CBAK_FUNC",
|
|
||||||
"description": "hook did not export correct func def int64_t cbak(uint32_t)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 14,
|
|
||||||
"identifier": "EXPORT_HOOK_FUNC",
|
|
||||||
"description": "hook did not export correct func def int64_t hook(uint32_t)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": 15,
|
|
||||||
"identifier": "EXPORT_MISSING",
|
|
||||||
"description": "distinct from export*S*_missing, either hook or cbak is missing"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "FLAGS_INVALID",
|
|
||||||
"code": 16,
|
|
||||||
"description": "HookSet flags were invalid for specified operation "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "FUNCS_MISSING",
|
|
||||||
"code": 17,
|
|
||||||
"description": "hook did not include function code for any functions "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "FUNC_PARAM_INVALID",
|
|
||||||
"code": 18,
|
|
||||||
"description": "parameter types may only be i32 i64 u32 u64 "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "FUNC_RETURN_COUNT",
|
|
||||||
"code": 19,
|
|
||||||
"description": "a function type is defined in the wasm which returns > 1 return value "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "FUNC_RETURN_INVALID",
|
|
||||||
"code": 20,
|
|
||||||
"description": "a function type does not return i32 i64 u32 or u64 "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "FUNC_TYPELESS",
|
|
||||||
"code": 21,
|
|
||||||
"description": "hook defined hook/cbak but their type is not defined in wasm "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "FUNC_TYPE_INVALID",
|
|
||||||
"code": 22,
|
|
||||||
"description": "malformed and illegal wasm in the func type section "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "GRANTS_EMPTY",
|
|
||||||
"code": 23,
|
|
||||||
"description": "HookSet object contained an empty grants array (you should remove it) "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "GRANTS_EXCESS",
|
|
||||||
"code": 24,
|
|
||||||
"description": "HookSet object cotnained a grants array with too many grants "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "GRANTS_FIELD",
|
|
||||||
"code": 25,
|
|
||||||
"description": "HookSet object contained a grant without Authorize or HookHash "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "GRANTS_ILLEGAL",
|
|
||||||
"code": 26,
|
|
||||||
"description": "Hookset object contained grants array which contained a non Grant object "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "GUARD_IMPORT",
|
|
||||||
"code": 27,
|
|
||||||
"description": "guard import is missing "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "GUARD_MISSING",
|
|
||||||
"code": 28,
|
|
||||||
"description": "guard call missing at top of loop "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "GUARD_PARAMETERS",
|
|
||||||
"code": 29,
|
|
||||||
"description": "guard called but did not use constant expressions for params "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HASH_OR_CODE",
|
|
||||||
"code": 30,
|
|
||||||
"description": "HookSet object can contain only one of CreateCode and HookHash "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOKON_MISSING",
|
|
||||||
"code": 31,
|
|
||||||
"description": "HookSet object did not contain HookOn but should have "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOKS_ARRAY_BAD",
|
|
||||||
"code": 32,
|
|
||||||
"description": "attempt to HookSet with a Hooks array containing a non-Hook obj "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOKS_ARRAY_BLANK",
|
|
||||||
"code": 33,
|
|
||||||
"description": "all hook set objs were blank "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOKS_ARRAY_EMPTY",
|
|
||||||
"code": 34,
|
|
||||||
"description": "attempt to HookSet with an empty Hooks array "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOKS_ARRAY_MISSING",
|
|
||||||
"code": 35,
|
|
||||||
"description": "attempt to HookSet without a Hooks array "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOKS_ARRAY_TOO_BIG",
|
|
||||||
"code": 36,
|
|
||||||
"description": "attempt to HookSet with a Hooks array beyond the chain size limit "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOK_ADD",
|
|
||||||
"code": 37,
|
|
||||||
"description": "Informational: adding ltHook to directory "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOK_DEF_MISSING",
|
|
||||||
"code": 38,
|
|
||||||
"description": "attempt to reference a hook definition (by hash) that is not on ledger "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOK_DELETE",
|
|
||||||
"code": 39,
|
|
||||||
"description": "unable to delete ltHook from owner "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOK_INVALID_FIELD",
|
|
||||||
"code": 40,
|
|
||||||
"description": "HookSetObj contained an illegal/unexpected field "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOK_PARAMS_COUNT",
|
|
||||||
"code": 41,
|
|
||||||
"description": "hookset obj would create too many hook parameters "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOK_PARAM_SIZE",
|
|
||||||
"code": 42,
|
|
||||||
"description": "hookset obj sets a parameter or value that exceeds max allowable size "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "IMPORTS_MISSING",
|
|
||||||
"code": 43,
|
|
||||||
"description": "hook must import guard, and accept/rollback "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "IMPORT_ILLEGAL",
|
|
||||||
"code": 44,
|
|
||||||
"description": "attempted import of a non-whitelisted function "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "IMPORT_MODULE_BAD",
|
|
||||||
"code": 45,
|
|
||||||
"description": "hook attempted to specify no or a bad import module "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "IMPORT_MODULE_ENV",
|
|
||||||
"code": 46,
|
|
||||||
"description": "hook attempted to specify import module not named env "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "IMPORT_NAME_BAD",
|
|
||||||
"code": 47,
|
|
||||||
"description": "import name was too short or too long "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "INSTALL_FLAG",
|
|
||||||
"code": 48,
|
|
||||||
"description": "install operation requires hsoOVERRIDE "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "INSTALL_MISSING",
|
|
||||||
"code": 49,
|
|
||||||
"description": "install operation specifies hookhash which doesn't exist on the ledger "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "INSTRUCTION_COUNT",
|
|
||||||
"code": 50,
|
|
||||||
"description": "worst case execution instruction count as computed by HookSet "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "INSTRUCTION_EXCESS",
|
|
||||||
"code": 51,
|
|
||||||
"description": "worst case execution instruction count was too large "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "MEMORY_GROW",
|
|
||||||
"code": 52,
|
|
||||||
"description": "memory.grow instruction is present but disallowed "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NAMESPACE_MISSING",
|
|
||||||
"code": 53,
|
|
||||||
"description": "HookSet object lacked HookNamespace "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE",
|
|
||||||
"code": 54,
|
|
||||||
"description": "Informational: a namespace is being deleted "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_ACCOUNT",
|
|
||||||
"code": 55,
|
|
||||||
"description": "nsdelete tried to delete ns from a non-existing account "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_COUNT",
|
|
||||||
"code": 56,
|
|
||||||
"description": "namespace state count less than 0 / overflow "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_DIR",
|
|
||||||
"code": 57,
|
|
||||||
"description": "could not delete directory node in ledger "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_DIRECTORY",
|
|
||||||
"code": 58,
|
|
||||||
"description": "nsdelete operation failed to delete ns directory "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_DIR_ENTRY",
|
|
||||||
"code": 59,
|
|
||||||
"description": "nsdelete operation failed due to bad entry in ns directory "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_ENTRY",
|
|
||||||
"code": 60,
|
|
||||||
"description": "nsdelete operation failed due to missing hook state entry "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_FIELD",
|
|
||||||
"code": 61
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_FLAGS",
|
|
||||||
"code": 62
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_NONSTATE",
|
|
||||||
"code": 63,
|
|
||||||
"description": "nsdelete operation failed due to the presence of a non-hookstate obj "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "NSDELETE_NOTHING",
|
|
||||||
"code": 64,
|
|
||||||
"description": "hsfNSDELETE provided but nothing to delete "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "OPERATION_INVALID",
|
|
||||||
"code": 65,
|
|
||||||
"description": "could not deduce an operation from the provided hookset obj "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "OVERRIDE_MISSING",
|
|
||||||
"code": 66,
|
|
||||||
"description": "HookSet object was trying to update or delete a hook but lacked hsfOVERRIDE "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "PARAMETERS_FIELD",
|
|
||||||
"code": 67,
|
|
||||||
"description": "HookParameters contained a HookParameter with an invalid key in it "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "PARAMETERS_ILLEGAL",
|
|
||||||
"code": 68,
|
|
||||||
"description": "HookParameters contained something other than a HookParameter "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "PARAMETERS_NAME",
|
|
||||||
"code": 69,
|
|
||||||
"description": "HookParameters contained a HookParameter which lacked ParameterName field "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "PARAM_HOOK_CBAK",
|
|
||||||
"code": 70,
|
|
||||||
"description": "hook and cbak must take exactly one u32 parameter "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "RETURN_HOOK_CBAK",
|
|
||||||
"code": 71,
|
|
||||||
"description": "hook and cbak must retunr i64 "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "SHORT_HOOK",
|
|
||||||
"code": 72,
|
|
||||||
"description": "web assembly byte code ended abruptly "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "TYPE_INVALID",
|
|
||||||
"code": 73,
|
|
||||||
"description": "malformed and illegal wasm specifying an illegal local var type "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_BAD_MAGIC",
|
|
||||||
"code": 74,
|
|
||||||
"description": "wasm magic number missing or not wasm "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_INVALID",
|
|
||||||
"code": 75,
|
|
||||||
"description": "set hook operation would set invalid wasm "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_PARSE_LOOP",
|
|
||||||
"code": 76,
|
|
||||||
"description": "wasm section parsing resulted in an infinite loop "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_SMOKE_TEST",
|
|
||||||
"code": 77,
|
|
||||||
"description": "Informational: first attempt to load wasm into wasm runtime "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_TEST_FAILURE",
|
|
||||||
"code": 78,
|
|
||||||
"description": "the smoke test failed "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_TOO_BIG",
|
|
||||||
"code": 79,
|
|
||||||
"description": "set hook would exceed maximum hook size "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_TOO_SMALL",
|
|
||||||
"code": 80
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "WASM_VALIDATION",
|
|
||||||
"code": 81,
|
|
||||||
"description": "a generic error while parsing wasm, usually leb128 overflow"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "HOOK_CBAK_DIFF_TYPES",
|
|
||||||
"code": 82,
|
|
||||||
"description": "hook and cbak function definitions were different"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -10,10 +10,11 @@ import Box from '../../components/Box'
|
|||||||
import Button from '../../components/Button'
|
import Button from '../../components/Button'
|
||||||
import Popover from '../../components/Popover'
|
import Popover from '../../components/Popover'
|
||||||
import RunScript from '../../components/RunScript'
|
import RunScript from '../../components/RunScript'
|
||||||
import state from '../../state'
|
import state, { IFile } from '../../state'
|
||||||
import { compileCode } from '../../state/actions'
|
import { compileCode } from '../../state/actions'
|
||||||
import { getSplit, saveSplit } from '../../state/actions/persistSplits'
|
import { getSplit, saveSplit } from '../../state/actions/persistSplits'
|
||||||
import { styled } from '../../stitches.config'
|
import { styled } from '../../stitches.config'
|
||||||
|
import { getFileExtention } from '../../utils/helpers'
|
||||||
|
|
||||||
const HooksEditor = dynamic(() => import('../../components/HooksEditor'), {
|
const HooksEditor = dynamic(() => import('../../components/HooksEditor'), {
|
||||||
ssr: false
|
ssr: false
|
||||||
@@ -147,6 +148,8 @@ const CompilerSettings = () => {
|
|||||||
const Home: NextPage = () => {
|
const Home: NextPage = () => {
|
||||||
const snap = useSnapshot(state)
|
const snap = useSnapshot(state)
|
||||||
|
|
||||||
|
const activeFile = snap.files[snap.active] as IFile | undefined
|
||||||
|
const activeFileExt = getFileExtention(activeFile?.name)
|
||||||
return (
|
return (
|
||||||
<Split
|
<Split
|
||||||
direction="vertical"
|
direction="vertical"
|
||||||
@@ -159,7 +162,7 @@ const Home: NextPage = () => {
|
|||||||
>
|
>
|
||||||
<main style={{ display: 'flex', flex: 1, position: 'relative' }}>
|
<main style={{ display: 'flex', flex: 1, position: 'relative' }}>
|
||||||
<HooksEditor />
|
<HooksEditor />
|
||||||
{snap.files[snap.active]?.name?.split('.')?.[1]?.toLowerCase() === 'c' && (
|
{activeFileExt === 'c' && (
|
||||||
<Hotkeys
|
<Hotkeys
|
||||||
keyName="command+b,ctrl+b"
|
keyName="command+b,ctrl+b"
|
||||||
onKeyDown={() => !snap.compiling && snap.files.length && compileCode(snap.active)}
|
onKeyDown={() => !snap.compiling && snap.files.length && compileCode(snap.active)}
|
||||||
@@ -193,7 +196,7 @@ const Home: NextPage = () => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Hotkeys>
|
</Hotkeys>
|
||||||
)}
|
)}
|
||||||
{snap.files[snap.active]?.name?.split('.')?.[1]?.toLowerCase() === 'js' && (
|
{activeFileExt === 'js' && (
|
||||||
<Hotkeys
|
<Hotkeys
|
||||||
keyName="command+b,ctrl+b"
|
keyName="command+b,ctrl+b"
|
||||||
onKeyDown={() => !snap.compiling && snap.files.length && compileCode(snap.active)}
|
onKeyDown={() => !snap.compiling && snap.files.length && compileCode(snap.active)}
|
||||||
@@ -209,7 +212,7 @@ const Home: NextPage = () => {
|
|||||||
gap: '$2'
|
gap: '$2'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<RunScript file={snap.files[snap.active]} />
|
<RunScript file={activeFile as IFile} />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Hotkeys>
|
</Hotkeys>
|
||||||
)}
|
)}
|
||||||
@@ -225,7 +228,7 @@ const Home: NextPage = () => {
|
|||||||
>
|
>
|
||||||
<LogBox title="Development Log" clearLog={() => (state.logs = [])} logs={snap.logs} />
|
<LogBox title="Development Log" clearLog={() => (state.logs = [])} logs={snap.logs} />
|
||||||
</Flex>
|
</Flex>
|
||||||
{snap.files[snap.active]?.name?.split('.')?.[1]?.toLowerCase() === 'js' && (
|
{activeFileExt === 'js' && (
|
||||||
<Flex
|
<Flex
|
||||||
css={{
|
css={{
|
||||||
flex: 1
|
flex: 1
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
|
import { getFileExtention } from '../../utils/helpers'
|
||||||
import state, { IFile } from '../index'
|
import state, { IFile } from '../index'
|
||||||
|
|
||||||
const languageMapping = {
|
const languageMapping: Record<string, string | undefined> = {
|
||||||
ts: 'typescript',
|
ts: 'typescript',
|
||||||
js: 'javascript',
|
js: 'javascript',
|
||||||
md: 'markdown',
|
md: 'markdown',
|
||||||
c: 'c',
|
c: 'c',
|
||||||
h: 'c',
|
h: 'c',
|
||||||
other: ''
|
txt: 'text'
|
||||||
} /* Initializes empty file to global state */
|
}
|
||||||
|
|
||||||
export const createNewFile = (name: string) => {
|
export const createNewFile = (name: string) => {
|
||||||
const tempName = name.split('.')
|
const ext = getFileExtention(name) || ''
|
||||||
const fileExt = tempName[tempName.length - 1] || 'other'
|
|
||||||
const emptyFile: IFile = {
|
const emptyFile: IFile = { name, language: languageMapping[ext] || 'text', content: '' }
|
||||||
name,
|
|
||||||
language: languageMapping[fileExt as 'ts' | 'js' | 'md' | 'c' | 'h' | 'other'],
|
|
||||||
content: ''
|
|
||||||
}
|
|
||||||
state.files.push(emptyFile)
|
state.files.push(emptyFile)
|
||||||
state.active = state.files.length - 1
|
state.active = state.files.length - 1
|
||||||
}
|
}
|
||||||
@@ -24,5 +22,8 @@ export const renameFile = (oldName: string, nwName: string) => {
|
|||||||
const file = state.files.find(file => file.name === oldName)
|
const file = state.files.find(file => file.name === oldName)
|
||||||
if (!file) throw Error(`No file exists with name ${oldName}`)
|
if (!file) throw Error(`No file exists with name ${oldName}`)
|
||||||
|
|
||||||
|
const ext = getFileExtention(nwName) || ''
|
||||||
|
const language = languageMapping[ext] || 'text'
|
||||||
file.name = nwName
|
file.name = nwName
|
||||||
|
file.language = language
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { Link } from '../../components'
|
|||||||
import { ref } from 'valtio'
|
import { ref } from 'valtio'
|
||||||
import estimateFee from '../../utils/estimateFee'
|
import estimateFee from '../../utils/estimateFee'
|
||||||
import { SetHookData } from '../../utils/setHook'
|
import { SetHookData } from '../../utils/setHook'
|
||||||
import ResultLink from '../../components/ResultLink'
|
|
||||||
|
|
||||||
export const sha256 = async (string: string) => {
|
export const sha256 = async (string: string) => {
|
||||||
const utf8 = new TextEncoder().encode(string)
|
const utf8 = new TextEncoder().encode(string)
|
||||||
@@ -145,25 +144,6 @@ export const deployHook = async (account: IAccount & { name?: string }, data: Se
|
|||||||
tx_blob: signedTransaction
|
tx_blob: signedTransaction
|
||||||
})
|
})
|
||||||
|
|
||||||
const txHash = submitRes.tx_json?.hash
|
|
||||||
const resultMsg = ref(
|
|
||||||
<>
|
|
||||||
[<ResultLink result={submitRes.engine_result} />] {submitRes.engine_result_message}{' '}
|
|
||||||
{txHash && (
|
|
||||||
<>
|
|
||||||
Transaction hash:{' '}
|
|
||||||
<Link
|
|
||||||
as="a"
|
|
||||||
href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${txHash}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
{txHash}
|
|
||||||
</Link>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
if (submitRes.engine_result === 'tesSUCCESS') {
|
if (submitRes.engine_result === 'tesSUCCESS') {
|
||||||
state.deployLogs.push({
|
state.deployLogs.push({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
@@ -171,17 +151,27 @@ export const deployHook = async (account: IAccount & { name?: string }, data: Se
|
|||||||
})
|
})
|
||||||
state.deployLogs.push({
|
state.deployLogs.push({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: resultMsg
|
message: ref(
|
||||||
})
|
<>
|
||||||
} else if (submitRes.engine_result) {
|
[{submitRes.engine_result}] {submitRes.engine_result_message} Transaction hash:{' '}
|
||||||
state.deployLogs.push({
|
<Link
|
||||||
type: 'error',
|
as="a"
|
||||||
message: resultMsg
|
href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${submitRes.tx_json?.hash}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
{submitRes.tx_json?.hash}
|
||||||
|
</Link>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
// message: `[${submitRes.engine_result}] ${submitRes.engine_result_message} Validated ledger index: ${submitRes.validated_ledger_index}`,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
state.deployLogs.push({
|
state.deployLogs.push({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: `[${submitRes.error}] ${submitRes.error_exception}`
|
message: `[${submitRes.engine_result || submitRes.error}] ${
|
||||||
|
submitRes.engine_result_message || submitRes.error_exception
|
||||||
|
}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
import { derive, sign } from 'xrpl-accountlib'
|
|
||||||
|
|
||||||
import state from '..'
|
|
||||||
import type { IAccount } from '..'
|
|
||||||
import ResultLink from '../../components/ResultLink'
|
|
||||||
import { ref } from 'valtio'
|
|
||||||
|
|
||||||
interface TransactionOptions {
|
|
||||||
TransactionType: string
|
|
||||||
Account?: string
|
|
||||||
Fee?: string
|
|
||||||
Destination?: string
|
|
||||||
[index: string]: any
|
|
||||||
}
|
|
||||||
interface OtherOptions {
|
|
||||||
logPrefix?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const sendTransaction = async (
|
|
||||||
account: IAccount,
|
|
||||||
txOptions: TransactionOptions,
|
|
||||||
options?: OtherOptions
|
|
||||||
) => {
|
|
||||||
if (!state.client) throw Error('XRPL client not initalized')
|
|
||||||
|
|
||||||
const { Fee = '1000', ...opts } = txOptions
|
|
||||||
const tx: TransactionOptions = {
|
|
||||||
Account: account.address,
|
|
||||||
Sequence: account.sequence,
|
|
||||||
Fee, // TODO auto-fillable default
|
|
||||||
...opts
|
|
||||||
}
|
|
||||||
const { logPrefix = '' } = options || {}
|
|
||||||
try {
|
|
||||||
const signedAccount = derive.familySeed(account.secret)
|
|
||||||
const { signedTransaction } = sign(tx, signedAccount)
|
|
||||||
const response = await state.client.send({
|
|
||||||
command: 'submit',
|
|
||||||
tx_blob: signedTransaction
|
|
||||||
})
|
|
||||||
|
|
||||||
const resultMsg = ref(
|
|
||||||
<>
|
|
||||||
{logPrefix}[<ResultLink result={response.engine_result} />] {response.engine_result_message}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
if (response.engine_result === 'tesSUCCESS') {
|
|
||||||
state.transactionLogs.push({
|
|
||||||
type: 'success',
|
|
||||||
message: resultMsg
|
|
||||||
})
|
|
||||||
} else if (response.engine_result) {
|
|
||||||
state.transactionLogs.push({
|
|
||||||
type: 'error',
|
|
||||||
message: resultMsg
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
state.transactionLogs.push({
|
|
||||||
type: 'error',
|
|
||||||
message: `${logPrefix}[${response.error}] ${response.error_exception}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const currAcc = state.accounts.find(acc => acc.address === account.address)
|
|
||||||
if (currAcc && response.account_sequence_next) {
|
|
||||||
currAcc.sequence = response.account_sequence_next
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
state.transactionLogs.push({
|
|
||||||
type: 'error',
|
|
||||||
message:
|
|
||||||
err instanceof Error
|
|
||||||
? `${logPrefix}Error: ${err.message}`
|
|
||||||
: `${logPrefix}Something went wrong, try again later`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,3 +13,9 @@ export const capitalize = (value?: string) => {
|
|||||||
|
|
||||||
return value[0].toLocaleUpperCase() + value.slice(1)
|
return value[0].toLocaleUpperCase() + value.slice(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getFileExtention = (filename?: string): string | undefined => {
|
||||||
|
if (!filename) return
|
||||||
|
const ext = (filename.includes('.') && filename.split('.').pop()) || undefined
|
||||||
|
return ext
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user