Compare commits

...

5 Commits

Author SHA1 Message Date
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
5 changed files with 35 additions and 13 deletions

View File

@@ -34,7 +34,9 @@ const DeployEditor = () => {
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 color =
compiledSize > FILESIZE_BREAKPOINTS[1]
@@ -60,12 +62,21 @@ const DeployEditor = () => {
{activeFile?.lastCompiled && (
<ReactTimeAgo date={activeFile.lastCompiled} locale="en-US" />
)}
{activeFile.compiledContent?.byteLength && (
<Text css={{ ml: "$2", color }}>
({filesize(activeFile.compiledContent.byteLength)})
</Text>
)}
</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)}>
View as WAT-file
</Button>
@@ -119,8 +130,8 @@ const DeployEditor = () => {
className="hooks-editor"
defaultLanguage={"wat"}
language={"wat"}
path={`file://tmp/c/${snap.files?.[snap.active]?.name}.wat`}
value={snap.files?.[snap.active]?.compiledWatContent || ""}
path={`file://tmp/c/${activeFile?.name}.wat`}
value={activeFile?.compiledWatContent || ""}
beforeMount={(monaco) => {
monaco.languages.register({ id: "wat" });
monaco.languages.setLanguageConfiguration("wat", wat.config);

View File

@@ -140,6 +140,16 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
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 currAccount = state.accounts.find(
(acc) => acc.address === account.address
@@ -164,7 +174,8 @@ export const SetHookDialog: React.FC<{ accountAddress: string }> = React.memo(
variant={"secondary"}
disabled={
account.isLoading ||
!snap.files.filter((file) => file.compiledWatContent).length
!snap.files.filter((file) => file.compiledWatContent).length ||
tooLargeFile()
}
>
Set Hook

View File

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

View File

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

View File

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