Compare commits

...

11 Commits

Author SHA1 Message Date
Valtteri Karesto
31a86263a1 Disable suggest if no account selected 2022-06-22 14:42:50 +03:00
Valtteri Karesto
4d0025afc1 Fix splitscreen error 2022-06-22 14:42:39 +03:00
Valtteri Karesto
f85bd2398d Merge pull request #220 from XRPLF/fix/decimals-again
fixes #201
2022-06-22 12:28:12 +03:00
Valtteri Karesto
a2a6596cc5 Prevent pasting decimals 2022-06-22 12:16:36 +03:00
Valtteri Karesto
37208ce97e fixes #201 2022-06-22 12:03:43 +03:00
Valtteri Karesto
bf4042926d Merge pull request #218 from XRPLF/feat/ui-fixes
Fixes #213 and fixes #200
2022-06-22 11:41:31 +03:00
Valtteri Karesto
3ccc1c16ac Fixed deploy 2022-06-22 11:32:07 +03:00
Valtteri Karesto
135f0c91a1 Fixes #213 and fixes #200 2022-06-22 11:06:15 +03:00
Valtteri Karesto
8f5786e242 Merge pull request #216 from XRPLF/feat/change-default-optimization
fixes #214 change default optimization
2022-06-22 09:56:15 +03:00
Valtteri Karesto
810eb4ca27 Add new default to compileCode as well 2022-06-22 09:52:47 +03:00
Valtteri Karesto
e6574f9f12 fixes #214 change default optimization 2022-06-22 09:47:30 +03:00
8 changed files with 85 additions and 28 deletions

View File

@@ -512,6 +512,7 @@ const ImportAccountDialog = () => {
<Input <Input
name="secret" name="secret"
type="password" type="password"
autoComplete="new-password"
value={value} value={value}
onChange={(e) => setValue(e.target.value)} onChange={(e) => setValue(e.target.value)}
/> />

View File

@@ -34,7 +34,9 @@ const DeployEditor = () => {
const [showContent, setShowContent] = useState(false); const [showContent, setShowContent] = useState(false);
const activeFile = snap.files[snap.active]; const activeFile = snap.files[snap.active]?.compiledContent
? snap.files[snap.active]
: snap.files.filter((file) => file.compiledContent)[0];
const compiledSize = activeFile?.compiledContent?.byteLength || 0; const compiledSize = activeFile?.compiledContent?.byteLength || 0;
const color = const color =
compiledSize > FILESIZE_BREAKPOINTS[1] compiledSize > FILESIZE_BREAKPOINTS[1]
@@ -60,12 +62,21 @@ const DeployEditor = () => {
{activeFile?.lastCompiled && ( {activeFile?.lastCompiled && (
<ReactTimeAgo date={activeFile.lastCompiled} locale="en-US" /> <ReactTimeAgo date={activeFile.lastCompiled} locale="en-US" />
)} )}
{activeFile.compiledContent?.byteLength && ( {activeFile.compiledContent?.byteLength && (
<Text css={{ ml: "$2", color }}> <Text css={{ ml: "$2", color }}>
({filesize(activeFile.compiledContent.byteLength)}) ({filesize(activeFile.compiledContent.byteLength)})
</Text> </Text>
)} )}
</Flex> </Flex>
{activeFile.compiledContent?.byteLength &&
activeFile.compiledContent?.byteLength >= 64000 && (
<Flex css={{ flexDirection: "column", py: "$3", pb: "$1" }}>
<Text css={{ ml: "$2", color: "$error" }}>
File size is larger than 64kB, cannot set hook!
</Text>
</Flex>
)}
<Button variant="link" onClick={() => setShowContent(true)}> <Button variant="link" onClick={() => setShowContent(true)}>
View as WAT-file View as WAT-file
</Button> </Button>
@@ -119,8 +130,8 @@ const DeployEditor = () => {
className="hooks-editor" className="hooks-editor"
defaultLanguage={"wat"} defaultLanguage={"wat"}
language={"wat"} language={"wat"}
path={`file://tmp/c/${snap.files?.[snap.active]?.name}.wat`} path={`file://tmp/c/${activeFile?.name}.wat`}
value={snap.files?.[snap.active]?.compiledWatContent || ""} value={activeFile?.compiledWatContent || ""}
beforeMount={(monaco) => { beforeMount={(monaco) => {
monaco.languages.register({ id: "wat" }); monaco.languages.register({ id: "wat" });
monaco.languages.setLanguageConfiguration("wat", wat.config); monaco.languages.setLanguageConfiguration("wat", wat.config);

View File

@@ -140,6 +140,16 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
return null; return null;
} }
const tooLargeFile = () => {
const activeFile = snap.files[snap.active].compiledContent
? snap.files[snap.active]
: snap.files.filter((file) => file.compiledContent)[0];
return Boolean(
activeFile?.compiledContent?.byteLength &&
activeFile?.compiledContent?.byteLength >= 64000
);
};
const onSubmit: SubmitHandler<SetHookData> = async (data) => { const onSubmit: SubmitHandler<SetHookData> = async (data) => {
const currAccount = state.accounts.find( const currAccount = state.accounts.find(
(acc) => acc.address === account.address (acc) => acc.address === account.address
@@ -164,7 +174,8 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
variant={"secondary"} variant={"secondary"}
disabled={ disabled={
account.isLoading || account.isLoading ||
!snap.files.filter((file) => file.compiledWatContent).length !snap.files.filter((file) => file.compiledWatContent).length ||
tooLargeFile()
} }
> >
Set Hook Set Hook

View File

@@ -38,22 +38,22 @@ export const TxUI: FC<UIProps> = ({
txFields, txFields,
} = txState; } = txState;
const transactionsOptions = transactionsData.map(tx => ({ const transactionsOptions = transactionsData.map((tx) => ({
value: tx.TransactionType, value: tx.TransactionType,
label: tx.TransactionType, label: tx.TransactionType,
})); }));
const accountOptions: SelectOption[] = accounts.map(acc => ({ const accountOptions: SelectOption[] = accounts.map((acc) => ({
label: acc.name, label: acc.name,
value: acc.address, value: acc.address,
})); }));
const destAccountOptions: SelectOption[] = accounts const destAccountOptions: SelectOption[] = accounts
.map(acc => ({ .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 [feeLoading, setFeeLoading] = useState(false); const [feeLoading, setFeeLoading] = useState(false);
@@ -108,15 +108,15 @@ export const TxUI: FC<UIProps> = ({
const specialFields = ["TransactionType", "Account", "Destination"]; const specialFields = ["TransactionType", "Account", "Destination"];
const otherFields = Object.keys(txFields).filter( const otherFields = Object.keys(txFields).filter(
k => !specialFields.includes(k) (k) => !specialFields.includes(k)
) as [keyof TxFields]; ) as [keyof TxFields];
const switchToJson = () => const switchToJson = () =>
setState({ editorSavedValue: null, viewType: "json" }); setState({ editorSavedValue: null, viewType: "json" });
useEffect(() => { useEffect(() => {
const defaultOption = transactionsOptions.find( const defaultOption = transactionsOptions.find(
tt => tt.value === "Payment" (tt) => tt.value === "Payment"
); );
if (defaultOption) { if (defaultOption) {
handleChangeTxType(defaultOption); handleChangeTxType(defaultOption);
@@ -204,7 +204,7 @@ export const TxUI: FC<UIProps> = ({
/> />
</Flex> </Flex>
)} )}
{otherFields.map(field => { {otherFields.map((field) => {
let _value = txFields[field]; let _value = txFields[field];
let value: string | undefined; let value: string | undefined;
@@ -253,13 +253,39 @@ export const TxUI: FC<UIProps> = ({
/> />
) : ( ) : (
<Input <Input
type={isFee ? "number" : "text"}
value={value} value={value}
onChange={e => { onChange={(e) => {
handleSetField(field, e.target.value); if (isFee) {
const val = e.target.value
.replaceAll(".", "")
.replaceAll(",", "");
handleSetField(field, val);
} else {
handleSetField(field, e.target.value);
}
}} }}
onKeyPress={
isFee
? (e) => {
if (e.key === "." || e.key === ",") {
e.preventDefault();
}
}
: undefined
}
css={{ css={{
width: "70%", width: "70%",
flex: "inherit", flex: "inherit",
"-moz-appearance": "textfield",
"&::-webkit-outer-spin-button": {
"-webkit-appearance": "none",
margin: 0,
},
"&::-webkit-inner-spin-button ": {
"-webkit-appearance": "none",
margin: 0,
},
}} }}
/> />
)} )}
@@ -268,6 +294,8 @@ export const TxUI: FC<UIProps> = ({
size="xs" size="xs"
variant="primary" variant="primary"
outline outline
disabled={txState.txIsDisabled}
isDisabled={txState.txIsDisabled}
isLoading={feeLoading} isLoading={feeLoading}
css={{ css={{
position: "absolute", position: "absolute",

View File

@@ -32,14 +32,20 @@ const Test = () => {
if (!showComponent) { if (!showComponent) {
return null; return null;
} }
const hasScripts = const hasScripts = Boolean(
snap.files.filter((f) => f.name.endsWith(".js")).length > 0; snap.files.filter((f) => f.name.toLowerCase()?.endsWith(".js")).length
);
return ( return (
<Container css={{ px: 0 }}> <Container css={{ px: 0 }}>
<Split <Split
direction="vertical" direction="vertical"
sizes={ sizes={
getSplit("testVertical") || (hasScripts ? [50, 20, 30] : [50, 50]) hasScripts && getSplit("testVertical")?.length === 2
? [50, 20, 30]
: hasScripts
? [50, 20, 50]
: [50, 50]
} }
gutterSize={4} gutterSize={4}
gutterAlign="center" gutterAlign="center"
@@ -95,7 +101,7 @@ const Test = () => {
</Box> </Box>
</Split> </Split>
</Flex> </Flex>
{hasScripts && ( {hasScripts ? (
<Flex <Flex
as="div" as="div"
css={{ css={{
@@ -110,7 +116,7 @@ const Test = () => {
clearLog={() => (state.scriptLogs = [])} clearLog={() => (state.scriptLogs = [])}
/> />
</Flex> </Flex>
)} ) : null}
<Flex> <Flex>
<Split <Split
direction="horizontal" direction="horizontal"

View File

@@ -39,7 +39,7 @@ export const compileCode = async (activeId: number) => {
files: [ files: [
{ {
type: "c", type: "c",
options: state.compileOptions.optimizationLevel || '-O0', options: state.compileOptions.optimizationLevel || '-O2',
name: state.files[activeId].name, name: state.files[activeId].name,
src: state.files[activeId].content, src: state.files[activeId].content,
}, },

View File

@@ -54,15 +54,15 @@ export const prepareDeployHookTx = async (
account: IAccount & { name?: string }, account: IAccount & { name?: string },
data: SetHookData data: SetHookData
) => { ) => {
if ( const activeFile = state.files[state.active]?.compiledContent
!state.files || ? state.files[state.active]
state.files.length === 0 || : state.files.filter((file) => file.compiledContent)[0];
!state.files?.[state.active]?.compiledContent
) { if (!state.files || state.files.length === 0) {
return; return;
} }
if (!state.files?.[state.active]?.compiledContent) { if (!activeFile?.compiledContent) {
return; return;
} }
if (!state.client) { if (!state.client) {
@@ -99,7 +99,7 @@ export const prepareDeployHookTx = async (
{ {
Hook: { Hook: {
CreateCode: arrayBufferToHex( CreateCode: arrayBufferToHex(
state.files?.[state.active]?.compiledContent activeFile?.compiledContent
).toUpperCase(), ).toUpperCase(),
HookOn: calculateHookOn(hookOnValues), HookOn: calculateHookOn(hookOnValues),
HookNamespace, HookNamespace,

View File

@@ -114,7 +114,7 @@ let initialState: IState = {
mainModalShowed: false, mainModalShowed: false,
accounts: [], accounts: [],
compileOptions: { compileOptions: {
optimizationLevel: '-O0', optimizationLevel: '-O2',
strip: true strip: true
} }
}; };