Compare commits
9 Commits
feat/impro
...
fix/decima
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2a6596cc5 | ||
|
|
37208ce97e | ||
|
|
bf4042926d | ||
|
|
3ccc1c16ac | ||
|
|
135f0c91a1 | ||
|
|
8f5786e242 | ||
|
|
810eb4ca27 | ||
|
|
e6574f9f12 | ||
|
|
1a6726fabf |
@@ -512,6 +512,7 @@ const ImportAccountDialog = () => {
|
||||
<Input
|
||||
name="secret"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
/>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,22 +38,22 @@ export const TxUI: FC<UIProps> = ({
|
||||
txFields,
|
||||
} = txState;
|
||||
|
||||
const transactionsOptions = transactionsData.map(tx => ({
|
||||
const transactionsOptions = transactionsData.map((tx) => ({
|
||||
value: tx.TransactionType,
|
||||
label: tx.TransactionType,
|
||||
}));
|
||||
|
||||
const accountOptions: SelectOption[] = accounts.map(acc => ({
|
||||
const accountOptions: SelectOption[] = accounts.map((acc) => ({
|
||||
label: acc.name,
|
||||
value: acc.address,
|
||||
}));
|
||||
|
||||
const destAccountOptions: SelectOption[] = accounts
|
||||
.map(acc => ({
|
||||
.map((acc) => ({
|
||||
label: acc.name,
|
||||
value: acc.address,
|
||||
}))
|
||||
.filter(acc => acc.value !== selectedAccount?.value);
|
||||
.filter((acc) => acc.value !== selectedAccount?.value);
|
||||
|
||||
const [feeLoading, setFeeLoading] = useState(false);
|
||||
|
||||
@@ -108,15 +108,15 @@ export const TxUI: FC<UIProps> = ({
|
||||
const specialFields = ["TransactionType", "Account", "Destination"];
|
||||
|
||||
const otherFields = Object.keys(txFields).filter(
|
||||
k => !specialFields.includes(k)
|
||||
(k) => !specialFields.includes(k)
|
||||
) as [keyof TxFields];
|
||||
|
||||
const switchToJson = () =>
|
||||
setState({ editorSavedValue: null, viewType: "json" });
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const defaultOption = transactionsOptions.find(
|
||||
tt => tt.value === "Payment"
|
||||
(tt) => tt.value === "Payment"
|
||||
);
|
||||
if (defaultOption) {
|
||||
handleChangeTxType(defaultOption);
|
||||
@@ -204,7 +204,7 @@ export const TxUI: FC<UIProps> = ({
|
||||
/>
|
||||
</Flex>
|
||||
)}
|
||||
{otherFields.map(field => {
|
||||
{otherFields.map((field) => {
|
||||
let _value = txFields[field];
|
||||
|
||||
let value: string | undefined;
|
||||
@@ -253,13 +253,39 @@ export const TxUI: FC<UIProps> = ({
|
||||
/>
|
||||
) : (
|
||||
<Input
|
||||
type={isFee ? "number" : "text"}
|
||||
value={value}
|
||||
onChange={e => {
|
||||
handleSetField(field, e.target.value);
|
||||
onChange={(e) => {
|
||||
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={{
|
||||
width: "70%",
|
||||
flex: "inherit",
|
||||
"-moz-appearance": "textfield",
|
||||
"&::-webkit-outer-spin-button": {
|
||||
"-webkit-appearance": "none",
|
||||
margin: 0,
|
||||
},
|
||||
"&::-webkit-inner-spin-button ": {
|
||||
"-webkit-appearance": "none",
|
||||
margin: 0,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -114,7 +114,7 @@ let initialState: IState = {
|
||||
mainModalShowed: false,
|
||||
accounts: [],
|
||||
compileOptions: {
|
||||
optimizationLevel: '-O0',
|
||||
optimizationLevel: '-O2',
|
||||
strip: true
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user