Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions packages/components/built/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ var __assign = (this && this.__assign) || function () {
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useEffect, useState } from "react";
import { Computer } from "@bitcoin-computer/lib";
import { initFlowbite } from "flowbite";
import { useUtilsComponents } from "./UtilsContext";
import { Modal } from "./Modal";
import { initFlowbite } from "flowbite";
function isLoggedIn() {
return !!localStorage.getItem("BIP_39_KEY");
}
Expand Down Expand Up @@ -58,8 +58,12 @@ function getUrl(chain, network) {
return getEnvVariable("REACT_APP_".concat(chain.toUpperCase(), "_").concat(network.toUpperCase(), "_URL"));
}
function defaultConfiguration() {
var chain = (localStorage.getItem("CHAIN") || getEnvVariable("REACT_APP_CHAIN") || "LTC");
var network = (localStorage.getItem("NETWORK") || getEnvVariable("REACT_APP_NETWORK") || "regtest");
var chain = (localStorage.getItem("CHAIN") ||
getEnvVariable("REACT_APP_CHAIN") ||
"LTC");
var network = (localStorage.getItem("NETWORK") ||
getEnvVariable("REACT_APP_NETWORK") ||
"regtest");
var url = getUrl(chain, network);
return { chain: chain, network: network, url: url };
}
Expand All @@ -73,7 +77,7 @@ function browserConfiguration() {
chain: localStorage.getItem("CHAIN"),
network: localStorage.getItem("NETWORK"),
path: localStorage.getItem("PATH"),
url: localStorage.getItem("URL"),
url: localStorage.getItem("URL")
};
}
function getComputer() {
Expand Down Expand Up @@ -120,19 +124,10 @@ function LoginButton(_a) {
var showSnackBar = useUtilsComponents().showSnackBar;
var login = function (e) {
e.preventDefault();
try {
if (isLoggedIn())
throw new Error("A user is already logged in, please log out first.");
if (mnemonic.length === 0)
throw new Error("Please don't use an empty mnemonic string.");
new Computer({ mnemonic: mnemonic, chain: chain, network: network, path: path, url: url });
}
catch (error) {
if (error instanceof Error) {
showSnackBar(error.message, false);
}
return;
}
if (isLoggedIn())
showSnackBar("A user is already logged in, please log out first.", false);
if (mnemonic.length === 0)
showSnackBar("Please don't use an empty mnemonic string.", false);
localStorage.setItem("BIP_39_KEY", mnemonic);
localStorage.setItem("CHAIN", chain);
localStorage.setItem("NETWORK", network);
Expand Down Expand Up @@ -166,5 +161,5 @@ export var Auth = {
browserConfiguration: browserConfiguration,
getComputer: getComputer,
LoginForm: LoginForm,
LoginModal: LoginModal,
LoginModal: LoginModal
};
2 changes: 1 addition & 1 deletion packages/components/built/ComputerContext.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// <reference types="react" />
import { Computer } from '@bitcoin-computer/lib';
import { Computer } from "@bitcoin-computer/lib";
export declare const ComputerContext: import("react").Context<Computer>;
4 changes: 2 additions & 2 deletions packages/components/built/ComputerContext.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Computer } from '@bitcoin-computer/lib';
import { createContext } from 'react';
import { Computer } from "@bitcoin-computer/lib";
import { createContext } from "react";
export var ComputerContext = createContext(new Computer());
2 changes: 1 addition & 1 deletion packages/components/built/Drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ function Component(_a) {
}
export var Drawer = {
Component: Component,
ShowDrawer: ShowDrawer,
ShowDrawer: ShowDrawer
};
4 changes: 1 addition & 3 deletions packages/components/built/Error404.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ var __assign = (this && this.__assign) || function () {
return __assign.apply(this, arguments);
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export var Error404 = function () {
return (_jsx("section", __assign({ className: "w-full bg-white dark:bg-gray-900" }, { children: _jsx("div", __assign({ className: "py-8 px-4 mx-auto max-w-screen-xl lg:py-16 lg:px-6" }, { children: _jsxs("div", __assign({ className: "mx-auto max-w-screen-sm text-center" }, { children: [_jsx("h1", __assign({ className: "mb-4 text-6xl tracking-tight font-extrabold text-blue-700 dark:text-blue-600" }, { children: "404" })), _jsx("p", __assign({ className: "mb-4 text-3xl tracking-tight font-bold text-gray-700 md:text-4xl dark:text-white" }, { children: "Something's missing." })), _jsxs("p", __assign({ className: "mb-4 text-lg font-light text-gray-500 dark:text-gray-400" }, { children: ["Sorry, we can't find that page. You'll find lots to explore on the home page.", " "] })), _jsx("a", __assign({ href: "/", className: "inline-flex text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:focus:ring-blue-900 my-4" }, { children: "Back to Homepage" }))] })) })) })));
};
export var Error404 = function () { return (_jsx("section", __assign({ className: "w-full bg-white dark:bg-gray-900" }, { children: _jsx("div", __assign({ className: "py-8 px-4 mx-auto max-w-screen-xl lg:py-16 lg:px-6" }, { children: _jsxs("div", __assign({ className: "mx-auto max-w-screen-sm text-center" }, { children: [_jsx("h1", __assign({ className: "mb-4 text-6xl tracking-tight font-extrabold text-blue-700 dark:text-blue-600" }, { children: "404" })), _jsx("p", __assign({ className: "mb-4 text-3xl tracking-tight font-bold text-gray-700 md:text-4xl dark:text-white" }, { children: "Something's missing." })), _jsxs("p", __assign({ className: "mb-4 text-lg font-light text-gray-500 dark:text-gray-400" }, { children: ["Sorry, we can't find that page. You'll find lots to explore on the home page.", " "] })), _jsx("a", __assign({ href: "/", className: "inline-flex text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:focus:ring-blue-900 my-4" }, { children: "Back to Homepage" }))] })) })) }))); };
2 changes: 1 addition & 1 deletion packages/components/built/Gallery.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type UserQuery<T extends Class> = Partial<{
publicKey: string;
limit: number;
offset: number;
order: 'ASC' | 'DESC';
order: "ASC" | "DESC";
ids: string[];
contract: {
class: T;
Expand Down
8 changes: 4 additions & 4 deletions packages/components/built/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useContext, useEffect, useState } from "react";
import { Link, useLocation } from "react-router-dom";
import { jsonMap, strip, toObject } from "./common/utils";
import { initFlowbite } from "flowbite";
import { jsonMap, strip, toObject } from "./common/utils";
import { useUtilsComponents } from "./UtilsContext";
import { ComputerContext } from "./ComputerContext";
function HomePageCard(_a) {
Expand Down Expand Up @@ -121,8 +121,8 @@ export default function WithPagination(q) {
case 0:
showLoader(true);
query = __assign(__assign({}, q), params);
query["offset"] = contractsPerPage * pageNum;
query["limit"] = contractsPerPage + 1;
query.offset = contractsPerPage * pageNum;
query.limit = contractsPerPage + 1;
return [4 /*yield*/, computer.query(query)];
case 1:
result = _a.sent();
Expand Down Expand Up @@ -158,5 +158,5 @@ export default function WithPagination(q) {
}
export var Gallery = {
FromRevs: FromRevs,
WithPagination: WithPagination,
WithPagination: WithPagination
};
2 changes: 1 addition & 1 deletion packages/components/built/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ export var Modal = {
ShowButton: ShowButton,
HideButton: HideButton,
ToggleButton: ToggleButton,
Component: Component,
Component: Component
};
21 changes: 11 additions & 10 deletions packages/components/built/SmartObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useContext, useEffect, useState } from "react";
import { Link, useLocation, useNavigate, useParams } from "react-router-dom";
import { capitalizeFirstLetter, toObject } from "./common/utils";
import reactStringReplace from "react-string-replace";
import { capitalizeFirstLetter, toObject } from "./common/utils";
import { Card } from "./Card";
import { Modal } from "./Modal";
import { FunctionResultModalContent } from "./common/SmartCallExecutionResult";
Expand Down Expand Up @@ -82,11 +82,7 @@ var SmartObjectValues = function (_a) {
return (_jsxs("div", { children: [_jsx("h3", __assign({ className: "mt-2 text-xl font-bold dark:text-white" }, { children: capitalizeFirstLetter(key) })), _jsx(ObjectValueCard, { content: toObject(value) })] }, i));
}) }));
};
var revToId = function (rev) { return rev === null || rev === void 0 ? void 0 : rev.split(":")[0]; };
var MetaData = function (_a) {
var smartObject = _a.smartObject;
return (_jsxs(_Fragment, { children: [_jsx("h2", __assign({ className: "mb-2 text-4xl font-bold dark:text-white" }, { children: "Meta Data" })), _jsxs("table", __assign({ className: "w-full mt-4 mb-8 text-sm text-left text-gray-500 dark:text-gray-400" }, { children: [_jsx("thead", __assign({ className: "text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400" }, { children: _jsxs("tr", { children: [_jsx("th", __assign({ scope: "col", className: "px-6 py-3" }, { children: "Key" })), _jsx("th", __assign({ scope: "col", className: "px-6 py-3" }, { children: "Short" })), _jsx("th", __assign({ scope: "col", className: "px-6 py-3" }, { children: "Value" }))] }) })), _jsxs("tbody", { children: [_jsxs("tr", __assign({ className: "bg-white border-b dark:bg-gray-800 dark:border-gray-700" }, { children: [_jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: "Identity" })), _jsx("td", __assign({ className: "px-6 py-4 break-all text-sm" }, { children: _jsx("pre", { children: "_id" }) })), _jsx("td", __assign({ className: "px-6 py-4" }, { children: _jsx(Link, __assign({ to: "/objects/".concat(smartObject === null || smartObject === void 0 ? void 0 : smartObject._id), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline" }, { children: smartObject === null || smartObject === void 0 ? void 0 : smartObject._id })) }))] })), _jsxs("tr", __assign({ className: "bg-white border-b dark:bg-gray-800 dark:border-gray-700" }, { children: [_jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: "Revision" })), _jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: _jsx("pre", { children: "_rev" }) })), _jsx("td", __assign({ className: "px-6 py-4" }, { children: _jsx(Link, __assign({ to: "/objects/".concat(smartObject === null || smartObject === void 0 ? void 0 : smartObject._rev), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline" }, { children: smartObject === null || smartObject === void 0 ? void 0 : smartObject._rev })) }))] })), _jsxs("tr", __assign({ className: "bg-white border-b dark:bg-gray-800 dark:border-gray-700" }, { children: [_jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: "Root" })), _jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: _jsx("pre", { children: "_root" }) })), _jsx("td", __assign({ className: "px-6 py-4" }, { children: _jsx(Link, __assign({ to: "/objects/".concat(smartObject === null || smartObject === void 0 ? void 0 : smartObject._root), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline" }, { children: smartObject === null || smartObject === void 0 ? void 0 : smartObject._root })) }))] })), _jsxs("tr", __assign({ className: "bg-white border-b dark:bg-gray-800 dark:border-gray-700" }, { children: [_jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: "Owners" })), _jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: _jsx("pre", { children: "_owners" }) })), _jsx("td", __assign({ className: "px-6 py-4" }, { children: _jsx("span", __assign({ className: "font-medium text-gray-900 dark:text-white" }, { children: smartObject === null || smartObject === void 0 ? void 0 : smartObject._owners })) }))] })), _jsxs("tr", __assign({ className: "bg-white border-b dark:bg-gray-800 dark:border-gray-700" }, { children: [_jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: "Amount" })), _jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: _jsx("pre", { children: "_amount" }) })), _jsx("td", __assign({ className: "px-6 py-4" }, { children: _jsx("span", __assign({ className: "font-medium text-gray-900 dark:text-white" }, { children: smartObject === null || smartObject === void 0 ? void 0 : smartObject._amount })) }))] })), _jsxs("tr", __assign({ className: "bg-white border-b dark:bg-gray-800 dark:border-gray-700" }, { children: [_jsx("td", __assign({ className: "px-6 py-4 break-all" }, { children: "Transaction" })), _jsx("td", { className: "px-6 py-4 break-all" }), _jsx("td", __assign({ className: "px-6 py-4" }, { children: _jsx(Link, __assign({ to: "/transactions/".concat(revToId(smartObject === null || smartObject === void 0 ? void 0 : smartObject._rev)), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline" }, { children: revToId(smartObject === null || smartObject === void 0 ? void 0 : smartObject._rev) })) }))] }))] })] }))] }));
};
// const revToId = (rev: string) => rev?.split(":")[0]
function Component() {
var _this = this;
var location = useLocation();
Expand All @@ -100,7 +96,12 @@ function Component() {
var options = ["object", "string", "number", "bigint", "boolean", "undefined", "symbol"];
var _d = useState(""), modalTitle = _d[0], setModalTitle = _d[1];
var setShow = function (flag) {
flag ? Modal.get(modalId).show() : Modal.get(modalId).hide();
if (flag) {
Modal.get(modalId).show();
}
else {
Modal.get(modalId).hide();
}
};
useEffect(function () {
var fetch = function () { return __awaiter(_this, void 0, void 0, function () {
Expand Down Expand Up @@ -131,17 +132,17 @@ function Component() {
var filteredSmartObject = Object.getOwnPropertyNames(Object.getPrototypeOf(smartObject)).filter(function (key) {
return key !== "constructor" && typeof Object.getPrototypeOf(smartObject)[key] === "function";
});
for (var key in filteredSmartObject) {
Object.keys(filteredSmartObject).forEach(function (key) {
if (key) {
funcExist = true;
}
}
});
}
setFunctionsExist(funcExist);
}, [smartObject]);
var _e = rev.split(":"), txId = _e[0], outNum = _e[1];
return (_jsxs(_Fragment, { children: [_jsxs("div", { children: [_jsx("h1", __assign({ className: "mb-2 text-5xl font-extrabold dark:text-white" }, { children: "Object" })), _jsxs("p", __assign({ className: "mb-6 text-lg font-normal text-gray-500 lg:text-xl dark:text-gray-400" }, { children: [_jsx(Link, __assign({ to: "/transactions/".concat(txId), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline" }, { children: txId })), ":", outNum] })), _jsx(SmartObjectValues, { smartObject: smartObject }), _jsx(SmartObjectFunction, { smartObject: smartObject, functionsExist: functionsExist, options: options, setFunctionResult: setFunctionResult, setShow: setShow, setModalTitle: setModalTitle })] }), _jsx(Modal.Component, { title: modalTitle, content: FunctionResultModalContent, contentData: { functionResult: functionResult }, id: modalId })] }));
}
export var SmartObject = {
Component: Component,
Component: Component
};
2 changes: 1 addition & 1 deletion packages/components/built/SmartObjectFunction.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export declare const getErrorMessage: (error: any) => string;
export declare const getFnParamNames: (fn: string) => string[];
export declare const getValueForType: (type: string, stringValue: string) => string | number | true | null | undefined;
export declare const SmartObjectFunction: ({ smartObject, functionsExist, options, setFunctionResult, setShow, setModalTitle, }: any) => import("react/jsx-runtime").JSX.Element;
export declare const SmartObjectFunction: ({ smartObject, functionsExist, options, setFunctionResult, setShow, setModalTitle }: any) => import("react/jsx-runtime").JSX.Element;
Loading