Compare commits
12 Commits
hotfix/fix
...
feat/add-h
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d75910972f | ||
|
|
589c604a12 | ||
|
|
e064251ff9 | ||
|
|
95022ef121 | ||
|
|
4519906b78 | ||
|
|
88a47c49a4 | ||
|
|
1ab03f9bed | ||
|
|
84ff667135 | ||
|
|
0d10e782f3 | ||
|
|
84e6763495 | ||
|
|
7ffcfd694d | ||
|
|
77e4917d38 |
@@ -215,6 +215,7 @@ export const Log: FC<ILog> = ({
|
|||||||
)}
|
)}
|
||||||
{expanded && jsonData && <Pre block>{jsonData}</Pre>}
|
{expanded && jsonData && <Pre block>{jsonData}</Pre>}
|
||||||
</LogText>
|
</LogText>
|
||||||
|
<br />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ export const addFaucetAccount = async (showToast: boolean = false) => {
|
|||||||
// fetch initial faucets
|
// fetch initial faucets
|
||||||
(async function fetchFaucets() {
|
(async function fetchFaucets() {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
if (state.accounts.length < 2) {
|
if (state.accounts.length === 0) {
|
||||||
await addFaucetAccount();
|
await addFaucetAccount();
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
addFaucetAccount();
|
// addFaucetAccount();
|
||||||
}, 10000);
|
// }, 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ const hash = async (string: string) => {
|
|||||||
return hashHex;
|
return hashHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toHex(str: string) {
|
||||||
|
var result = '';
|
||||||
|
for (var i = 0; i < str.length; i++) {
|
||||||
|
result += str.charCodeAt(i).toString(16);
|
||||||
|
}
|
||||||
|
return result.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
function arrayBufferToHex(arrayBuffer?: ArrayBuffer | null) {
|
function arrayBufferToHex(arrayBuffer?: ArrayBuffer | null) {
|
||||||
if (!arrayBuffer) {
|
if (!arrayBuffer) {
|
||||||
@@ -64,7 +71,7 @@ export const deployHook = async (account: IAccount & { name?: string }, data: Se
|
|||||||
).toUpperCase());
|
).toUpperCase());
|
||||||
const hookOnValues: (keyof TTS)[] = data.Invoke.map(tt => tt.value);
|
const hookOnValues: (keyof TTS)[] = data.Invoke.map(tt => tt.value);
|
||||||
const { HookParameters } = data;
|
const { HookParameters } = data;
|
||||||
const filteredHookParameters = HookParameters.filter(hp => hp.HookParameter.HookParameterName && hp.HookParameter.HookParameterValue);
|
const filteredHookParameters = HookParameters.filter(hp => hp.HookParameter.HookParameterName && hp.HookParameter.HookParameterValue)?.map(aa => ({ HookParameter: { HookParameterName: toHex(aa.HookParameter.HookParameterName || ''), HookParameterValue: toHex(aa.HookParameter.HookParameterValue || '') } }));
|
||||||
// const filteredHookGrants = HookGrants.filter(hg => hg.HookGrant.Authorize || hg.HookGrant.HookHash).map(hg => {
|
// const filteredHookGrants = HookGrants.filter(hg => hg.HookGrant.Authorize || hg.HookGrant.HookHash).map(hg => {
|
||||||
// return {
|
// return {
|
||||||
// HookGrant: {
|
// HookGrant: {
|
||||||
@@ -74,6 +81,7 @@ export const deployHook = async (account: IAccount & { name?: string }, data: Se
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
const tx = {
|
const tx = {
|
||||||
Account: account.address,
|
Account: account.address,
|
||||||
|
|||||||
@@ -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 || "",
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export const importAccount = (secret: string) => {
|
|||||||
sequence: 1,
|
sequence: 1,
|
||||||
hooks: [],
|
hooks: [],
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
version: '2'
|
||||||
});
|
});
|
||||||
return toast.success("Account imported successfully!");
|
return toast.success("Account imported successfully!");
|
||||||
};
|
};
|
||||||
1383
state/constants/headerTemplates.ts
Normal file
1383
state/constants/headerTemplates.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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']
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ if (typeof window !== "undefined") {
|
|||||||
initialAccounts = JSON.parse(localStorageAccounts);
|
initialAccounts = JSON.parse(localStorageAccounts);
|
||||||
}
|
}
|
||||||
// filter out old accounts (they do not have version property at all)
|
// filter out old accounts (they do not have version property at all)
|
||||||
initialAccounts = initialAccounts.filter(acc => acc.version === '2');
|
// initialAccounts = initialAccounts.filter(acc => acc.version === '2');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize state
|
// Initialize state
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import hooksGuardInFor from "./md/hooks-guard-in-for.md";
|
|||||||
import hooksGuardInWhile from "./md/hooks-guard-in-while.md";
|
import hooksGuardInWhile from "./md/hooks-guard-in-while.md";
|
||||||
import hooksHashBufLen from "./md/hooks-hash-buf-len.md";
|
import hooksHashBufLen from "./md/hooks-hash-buf-len.md";
|
||||||
import hooksKeyletBufLen from "./md/hooks-keylet-buf-len.md";
|
import hooksKeyletBufLen from "./md/hooks-keylet-buf-len.md";
|
||||||
|
import hooksParamBufLen from "./md/hooks-param-buf-len.md";
|
||||||
|
import hooksParamSetBufLen from "./md/hooks-param-set-buf-len.md";
|
||||||
import hooksRaddrConvBufLen from "./md/hooks-raddr-conv-buf-len.md";
|
import hooksRaddrConvBufLen from "./md/hooks-raddr-conv-buf-len.md";
|
||||||
import hooksRaddrConvPure from "./md/hooks-raddr-conv-pure.md";
|
import hooksRaddrConvPure from "./md/hooks-raddr-conv-pure.md";
|
||||||
import hooksReserveLimit from "./md/hooks-reserve-limit.md";
|
import hooksReserveLimit from "./md/hooks-reserve-limit.md";
|
||||||
@@ -69,6 +71,8 @@ const docs: { [key: string]: string; } = {
|
|||||||
"hooks-guard-in-while": hooksGuardInWhile,
|
"hooks-guard-in-while": hooksGuardInWhile,
|
||||||
"hooks-hash-buf-len": hooksHashBufLen,
|
"hooks-hash-buf-len": hooksHashBufLen,
|
||||||
"hooks-keylet-buf-len": hooksKeyletBufLen,
|
"hooks-keylet-buf-len": hooksKeyletBufLen,
|
||||||
|
"hooks-param-buf-len": hooksParamBufLen,
|
||||||
|
"hooks-param-set-buf-len": hooksParamSetBufLen,
|
||||||
"hooks-raddr-conv-buf-len": hooksRaddrConvBufLen,
|
"hooks-raddr-conv-buf-len": hooksRaddrConvBufLen,
|
||||||
"hooks-raddr-conv-pure": hooksRaddrConvPure,
|
"hooks-raddr-conv-pure": hooksRaddrConvPure,
|
||||||
"hooks-reserve-limit": hooksReserveLimit,
|
"hooks-reserve-limit": hooksReserveLimit,
|
||||||
|
|||||||
7
xrpl-hooks-docs/md/hooks-param-buf-len.md
Normal file
7
xrpl-hooks-docs/md/hooks-param-buf-len.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# hooks-param-buf-len
|
||||||
|
|
||||||
|
Function [hook_param](https://xrpl-hooks.readme.io/v2.0/reference/hook_param) expects a limited-length name input and produces fixed-size value output.
|
||||||
|
|
||||||
|
This check warns about invalid sizes of input and output buffers (if they're specified by constants - variable parameters are ignored).
|
||||||
|
|
||||||
|
[Read more](https://xrpl-hooks.readme.io/v2.0/docs/parameters)
|
||||||
7
xrpl-hooks-docs/md/hooks-param-set-buf-len.md
Normal file
7
xrpl-hooks-docs/md/hooks-param-set-buf-len.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# hooks-param-set-buf-len
|
||||||
|
|
||||||
|
Function [hook_param_set](https://xrpl-hooks.readme.io/v2.0/reference/hook_param_set) expects limited-length name, fixed-length hash and limited-length value inputs.
|
||||||
|
|
||||||
|
This check warns about invalid sizes of input buffers (if they're specified by constants - variable parameters are ignored).
|
||||||
|
|
||||||
|
[Read more](https://xrpl-hooks.readme.io/v2.0/docs/parameters)
|
||||||
Reference in New Issue
Block a user