Merge branch '31-feat-docs-add-blockchainelectrum-tool' into 'development'

Resolve "feat(Docs): Add BlockchainElectrum Tool"

Closes #31

See merge request GeneralProtocols/xo/stack!53
This commit is contained in:
Jim Hamill
2025-04-07 06:40:02 +00:00
5 changed files with 132 additions and 25 deletions
+1 -14
View File
@@ -207,29 +207,16 @@ export default withMermaid({
text: 'Stack',
collapsed: false,
items: [
/*
{
text: 'Blockchain',
link: '/tools/stack/blockchain',
items: [
{
text: 'Electrum',
link: '/tools/stack/blockchain#encryption',
link: '/tools/stack/blockchain#electrum',
},
],
},
{
text: 'Utils',
link: '/tools/stack/utils',
items: [
{
text: 'Encrypter',
link: '/tools/stack/utils#encrypter',
},
{ text: 'Hasher', link: '/tools/stack/utils#hasher' },
],
},
*/
],
},
],
@@ -75,7 +75,7 @@
</div>
</div>
<div>
<button type="submit" class="gradient-button" @click="() => executeMethod(state.selectedMethod.callback(state.primitive, state.selectedMethod.models))">Execute Method</button>
<button type="submit" class="gradient-button" @click="() => executeMethod(state.selectedMethod?.callback(state.primitive, state.selectedMethod.models))">Execute Method</button>
</div>
<!-- Result -->
<div>
@@ -135,7 +135,7 @@ export interface Method<Primitive> {
error?: string;
// Function that takes the models and returns the primitive
callback: (primitive: Primitive, value: Array<any>) => string;
callback: (primitive: Primitive, value: Array<any>) => string | Promise<string>;
// Whether the input is extended onto a new line
extendedInput?: boolean
@@ -185,13 +185,13 @@ const state: Ref<{
primitive: undefined,
})
async function setPrimitive(functionToExecute: () => Primitive | Promise<Primitive>): void {
async function setPrimitive(functionToExecute: () => Primitive | Promise<Primitive>): Promise<void> {
try {
state.value.primitive = await functionToExecute();
state.value.error = undefined;
state.value.toFunctions.forEach((wrappedMethod, i) => {
state.value.toFunctions[i].result = wrappedMethod.callback(state.value.primitive)
state.value.toFunctions.forEach(async (wrappedMethod, i) => {
state.value.toFunctions[i].result = await wrappedMethod.callback(state.value.primitive)
});
state.value.methods.forEach((method, i) => {
@@ -218,7 +218,7 @@ function getPrimitive(functionToExecute: () => string): string {
}
}
async function executeMethod(wrappedMethod: () => string | Promise<string>): string {
async function executeMethod(wrappedMethod: () => string | Promise<string>): Promise<void | string> {
try {
if(!state.value.primitive) {
return '';