Compare commits

..

4 Commits

Author SHA1 Message Date
Valtteri Karesto
d75910972f Change order 2022-03-30 12:09:16 +03:00
Valtteri Karesto
589c604a12 Add header files as hard coded 2022-03-30 12:00:27 +03:00
Valtteri Karesto
e064251ff9 Merge pull request #150 from eqlabs/feat/fix-newlines
Fixes issue #86 again, regressed in #107 for Firefox
2022-03-29 15:29:51 +03:00
Valtteri Karesto
95022ef121 Fixes issue #86 again, regressed in #107 for Firefox 2022-03-29 13:55:10 +03:00
6 changed files with 1407 additions and 18 deletions

View File

@@ -249,7 +249,6 @@ export const AccountDialog = ({
<Button <Button
size="xs" size="xs"
outline outline
disabled={activeAccount.isLoading}
css={{ mt: "$3", mr: "$1", ml: "auto" }} css={{ mt: "$3", mr: "$1", ml: "auto" }}
onClick={() => { onClick={() => {
deleteHook(activeAccount); deleteHook(activeAccount);

View File

@@ -215,6 +215,7 @@ export const Log: FC<ILog> = ({
)} )}
{expanded && jsonData && <Pre block>{jsonData}</Pre>} {expanded && jsonData && <Pre block>{jsonData}</Pre>}
</LogText> </LogText>
<br />
</> </>
); );
}; };

View File

@@ -153,18 +153,13 @@ export const deleteHook = async (account: IAccount & { name?: string }) => {
if (!state.client) { if (!state.client) {
return; return;
} }
const currentAccount = state.accounts.find(
(acc) => acc.address === account.address
);
if (currentAccount?.isLoading || !currentAccount?.hooks.length) {
return
}
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
const tx = { const tx = {
Account: account.address, Account: account.address,
TransactionType: "SetHook", TransactionType: "SetHook",
Sequence: account.sequence, Sequence: account.sequence,
Fee: "100000", Fee: "1000000",
Hooks: [ Hooks: [
{ {
Hook: { Hook: {
@@ -177,7 +172,9 @@ export const deleteHook = async (account: IAccount & { name?: string }) => {
const keypair = derive.familySeed(account.secret); const keypair = derive.familySeed(account.secret);
const { signedTransaction } = sign(tx, keypair); const { signedTransaction } = sign(tx, keypair);
const currentAccount = state.accounts.find(
(acc) => acc.address === account.address
);
if (currentAccount) { if (currentAccount) {
currentAccount.isLoading = true; currentAccount.isLoading = true;
} }
@@ -199,7 +196,6 @@ export const deleteHook = async (account: IAccount & { name?: string }) => {
type: "success", type: "success",
message: `[${submitRes.engine_result}] ${submitRes.engine_result_message} Validated ledger index: ${submitRes.validated_ledger_index}`, message: `[${submitRes.engine_result}] ${submitRes.engine_result_message} Validated ledger index: ${submitRes.validated_ledger_index}`,
}); });
currentAccount.hooks = [];
} else { } else {
toast.error(`${submitRes.engine_result_message || submitRes.error_exception}`, { id: toastId }) toast.error(`${submitRes.engine_result_message || submitRes.error_exception}`, { id: toastId })
state.deployLogs.push({ state.deployLogs.push({

View File

@@ -2,6 +2,7 @@ import { Octokit } from "@octokit/core";
import Router from "next/router"; import Router from "next/router";
import state from '../index'; import state from '../index';
import { templateFileIds } from '../constants'; import { templateFileIds } from '../constants';
import { hookapiH, hookmacroH, sfcodesH } from '../constants/headerTemplates';
const octokit = new Octokit(); const octokit = new Octokit();
@@ -24,16 +25,26 @@ export const fetchFiles = (gistId: string) => {
return res return res
} }
// in case of templates, fetch header file(s) and append to 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 = {
const files = { ...res.data.files, ...headerFiles } ...res.data.files,
res.data.files = files 'hookapi.h': res.data.files?.['hookapi.h'] || { filename: 'hookapi.h', content: hookapiH, language: 'C' },
return res 'hookmacro.h': res.data.files?.['hookmacro.h'] || { filename: 'hookmacro.h', content: hookmacroH, language: 'C' },
}) 'sfcodes.h': res.data.files?.['sfcodes.h'] || { filename: 'sfcodes.h', content: sfcodesH, 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) => { .then((res) => {
if (res.data.files && Object.keys(res.data.files).length > 0) { if (res.data.files && Object.keys(res.data.files).length > 0) {
const files = Object.keys(res.data.files).map((filename) => ({ 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() || "", language: res.data.files?.[filename]?.language?.toLowerCase() || "",
content: res.data.files?.[filename]?.content || "", content: res.data.files?.[filename]?.content || "",
})); }));

File diff suppressed because it is too large Load Diff

View File

@@ -14,8 +14,7 @@ export const templateFileIds = {
'carbon': 'a9fbcaf1b816b198c7fc0f62962bebf2', 'carbon': 'a9fbcaf1b816b198c7fc0f62962bebf2',
'doubler': '56b86174aeb70b2b48eee962bad3e355', 'doubler': '56b86174aeb70b2b48eee962bad3e355',
'peggy': 'd21298a37e1550b781682014762a567b', 'peggy': 'd21298a37e1550b781682014762a567b',
'headers': '9b448e8a55fab11ef5d1274cb59f9cf3' 'headers': '55f639bce59a49c58c45e663776b5138'
} }
export const apiHeaderFiles = ['hookapi.h', 'sfcodes.h', 'hookmacro.h'] export const apiHeaderFiles = ['hookapi.h', 'sfcodes.h', 'hookmacro.h']