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
614 changes: 605 additions & 9 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/components/built/Card.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare function Card({ content }: any): import("react/jsx-runtime").JSX.Element;
export declare function Card({ content, id }: any): import("react/jsx-runtime").JSX.Element;
4 changes: 2 additions & 2 deletions packages/components/built/Card.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jsx as _jsx } from "react/jsx-runtime";
export function Card(_a) {
var content = _a.content;
return (_jsx("div", { className: "block mt-4 mb-8 p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700", children: _jsx("pre", { className: "font-normal text-gray-700 dark:text-gray-400 text-xs", children: content }) }));
var content = _a.content, id = _a.id;
return (_jsx("div", { className: "block mt-4 mb-8 p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700", children: _jsx("pre", { id: id !== null && id !== void 0 ? id : undefined, className: "font-normal text-gray-700 dark:text-gray-400 text-xs", children: content }) }));
}
2 changes: 1 addition & 1 deletion packages/components/built/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ValueComponent(_a) {
}); };
fetch();
}, [computer, rev]);
var loadingContent = function () { return (_jsxs(_Fragment, { children: [_jsxs("svg", { "aria-hidden": "true", role: "status", className: "inline w-4 h-4 me-3 text-gray-200 animate-spin dark:text-gray-600", viewBox: "0 0 100 101", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z", fill: "currentColor" }), _jsx("path", { d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z", fill: "#1C64F2" })] }), "\u00A0Loading..."] })); };
var loadingContent = function () { return (_jsxs(_Fragment, { children: [_jsxs("svg", { "aria-hidden": "true", role: "status", className: "inline w-4 h-4 me-3 text-gray-200 animate-spin dark:text-gray-600", viewBox: "0 0 100 101", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z", fill: "currentColor" }), _jsx("path", { d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z", fill: "#1C64F2" })] }), _jsx("span", { className: "loading-smart-contract-span", children: "\u00A0Loading..." })] })); };
return loading ? (_jsx(HomePageCard, { content: loadingContent })) : (_jsx(HomePageCard, { content: function () { return errorMsg || value; } }));
}
function FromRevs(_a) {
Expand Down
6 changes: 3 additions & 3 deletions packages/components/built/SmartObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function Copy(_a) {
return (_jsx("button", { onClick: function () { return navigator.clipboard.writeText(text); }, className: "cursor-pointer pl-2 text-gray-600 hover:text-gray-800 focus:outline-none", "aria-label": "Copy Transaction ID", children: _jsx(HiOutlineClipboard, {}) }));
}
function ObjectValueCard(_a) {
var content = _a.content;
var content = _a.content, id = _a.id;
var isRev = /([0-9a-fA-F]{64}:[0-9]+)/g;
var revLink = function (rev, i) { return (_jsx(Link, { to: "/objects/".concat(rev), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline", children: rev }, i)); };
var formattedContent = reactStringReplace(content, isRev, revLink);
return _jsx(Card, { content: formattedContent });
return _jsx(Card, { content: formattedContent, id: "property-".concat(id, "-value") });
}
var SmartObjectValues = function (_a) {
var smartObject = _a.smartObject;
Expand All @@ -73,7 +73,7 @@ var SmartObjectValues = function (_a) {
})
.map(function (_a, i) {
var key = _a[0], value = _a[1];
return (_jsxs("div", { children: [_jsx("h3", { className: "mt-2 text-xl font-bold dark:text-white", children: capitalizeFirstLetter(key) }), _jsx(ObjectValueCard, { content: toObject(value || '') })] }, i));
return (_jsxs("div", { children: [_jsx("h3", { className: "mt-2 text-xl font-bold dark:text-white", children: capitalizeFirstLetter(key) }), _jsx(ObjectValueCard, { id: key, content: toObject(value || '') })] }, i));
}) }));
};
function MetaData(_a) {
Expand Down
6 changes: 3 additions & 3 deletions packages/components/built/SmartObjectFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export var SmartObjectFunction = function (_a) {
case 5:
res = _a.sent();
setFunctionResult({ _rev: res[0] });
setModalTitle('Success!');
setModalTitle('Success');
setShow(true);
return [3 /*break*/, 8];
case 6:
Expand Down Expand Up @@ -171,8 +171,8 @@ export var SmartObjectFunction = function (_a) {
})
.map(function (key, fnIndex) {
var paramList = getFnParamNames(Object.getPrototypeOf(smartObject)[key]);
return (_jsxs("div", { className: "mt-6 mb-6", children: [_jsx("h3", { className: "my-2 text-xl font-bold dark:text-white", children: capitalizeFirstLetter(key) }), _jsxs("form", { id: "fn-index-".concat(fnIndex), children: [paramList.map(function (paramName, paramIndex) { return (_jsx("div", { className: "mb-4", children: _jsxs("div", { className: "flex items-center space-x-4", children: [_jsx("input", { type: "text", id: "".concat(key, "-").concat(paramName), value: formState["".concat(key, "-").concat(paramName)] || '', onChange: function (e) { return updateFormValue(e, "".concat(key, "-").concat(paramName)); }, className: "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500", placeholder: paramName, required: true }), _jsx(TypeSelectionDropdown, { id: "".concat(key).concat(paramName), dropdownList: options, onSelectMethod: function (option) {
return (_jsxs("div", { className: "mt-6 mb-6", id: "function-".concat(key), children: [_jsx("h3", { className: "my-2 text-xl font-bold dark:text-white", children: capitalizeFirstLetter(key) }), _jsxs("form", { id: "fn-index-".concat(fnIndex), children: [paramList.map(function (paramName, paramIndex) { return (_jsx("div", { className: "mb-4", children: _jsxs("div", { className: "flex items-center space-x-4", children: [_jsx("input", { type: "text", id: "".concat(key, "-").concat(paramName), value: formState["".concat(key, "-").concat(paramName)] || '', onChange: function (e) { return updateFormValue(e, "".concat(key, "-").concat(paramName)); }, className: "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500", placeholder: paramName, required: true }), _jsx(TypeSelectionDropdown, { id: "".concat(key).concat(paramName), dropdownList: options, onSelectMethod: function (option) {
return updateTypes(option, "".concat(key, "-").concat(paramName));
} })] }) }, paramIndex)); }), _jsx("button", { className: "text-gray-900 bg-white border border-gray-300 focus:outline-none hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700", onClick: function (evt) { return handleSmartObjectMethod(evt, smartObject, key, paramList); }, children: "Call Function" })] })] }, fnIndex));
} })] }) }, paramIndex)); }), _jsx("button", { id: "".concat(key, "-call-function-button"), className: "text-gray-900 bg-white border border-gray-300 focus:outline-none hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700", onClick: function (evt) { return handleSmartObjectMethod(evt, smartObject, key, paramList); }, children: "Call Function" })] })] }, fnIndex));
}) }));
};
2 changes: 1 addition & 1 deletion packages/components/built/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var Balance = function (_a) {
useEffect(function () {
refreshBalance();
}, []);
return (_jsxs("div", { id: "dropdown-cta", className: "relative flex flex-col p-6 my-4 rounded-lg bg-blue-50 dark:bg-blue-900", role: "alert", children: [_jsxs("div", { className: "text-center mb-1 text-2xl font-bold text-blue-800 dark:text-blue-400", children: [balance / 1e8, " ", computer.getChain(), ' ', _jsx(HiRefresh, { onClick: refreshBalance, className: "w-4 h-4 ml-1 mb-1 inline cursor-pointer hover:text-slate-700 dark:hover:text-slate-100" })] }), _jsx("div", { className: "text-center uppercase text-xs text-blue-800 dark:text-blue-400", children: computer.getNetwork() }), computer.getNetwork() === 'regtest' && (_jsx("button", { type: "button", onClick: fund, className: "absolute bottom-2 right-2 px-1 py-1 text-center text-xs font-medium text-center text-blue-700 hover:text-white border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg dark:border-blue-500 dark:text-blue-500 dark:hover:text-white dark:hover:bg-blue-500 dark:focus:ring-blue-800", children: "Fund" }))] }));
return (_jsxs("div", { id: "dropdown-cta", className: "relative flex flex-col p-6 my-4 rounded-lg bg-blue-50 dark:bg-blue-900", role: "alert", children: [_jsxs("div", { className: "text-center mb-1 text-2xl font-bold text-blue-800 dark:text-blue-400", children: [balance / 1e8, " ", computer.getChain(), ' ', _jsx(HiRefresh, { onClick: refreshBalance, className: "w-4 h-4 ml-1 mb-1 inline cursor-pointer hover:text-slate-700 dark:hover:text-slate-100" })] }), _jsx("div", { className: "text-center uppercase text-xs text-blue-800 dark:text-blue-400", children: computer.getNetwork() }), computer.getNetwork() === 'regtest' && (_jsx("button", { id: "fund-wallet", type: "button", onClick: fund, className: "absolute bottom-2 right-2 px-1 py-1 text-center text-xs font-medium text-center text-blue-700 hover:text-white border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg dark:border-blue-500 dark:text-blue-500 dark:hover:text-white dark:hover:bg-blue-500 dark:focus:ring-blue-800", children: "Fund" }))] }));
};
var Address = function (_a) {
var computer = _a.computer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function FunctionResultModalContent(_a) {
var functionResult = _a.functionResult;
var navigate = useNavigate();
if (functionResult && typeof functionResult === 'object' && !Array.isArray(functionResult))
return (_jsx(_Fragment, { children: _jsxs("div", { className: "p-4 md:p-5 dark:text-gray-400", children: ["You created a\u00A0", _jsx(Link, { to: "/objects/".concat(functionResult._rev), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline", onClick: function () {
return (_jsx(_Fragment, { children: _jsxs("div", { id: "smart-call-execution-success", className: "p-4 md:p-5 dark:text-gray-400", children: ["You created a\u00A0", _jsx(Link, { id: "smart-call-execution-counter-link", to: "/objects/".concat(functionResult._rev), className: "font-medium text-blue-600 dark:text-blue-500 hover:underline", onClick: function () {
navigate("/objects/".concat(functionResult._rev));
window.location.reload();
}, children: "smart object" }), "."] }) }));
Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export function Card({ content }: any) {
export function Card({ content, id }: any) {
return (
<div className="block mt-4 mb-8 p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<pre className="font-normal text-gray-700 dark:text-gray-400 text-xs">{content}</pre>
<pre id={id ?? undefined} className="font-normal text-gray-700 dark:text-gray-400 text-xs">
{content}
</pre>
</div>
)
}
2 changes: 1 addition & 1 deletion packages/components/src/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function ValueComponent({ rev, computer }: { rev: string; computer: Computer })
fill="#1C64F2"
/>
</svg>
&nbsp;Loading...
<span className="loading-smart-contract-span">&nbsp;Loading...</span>
</>
)

Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/SmartObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Copy({ text }: { text: string }) {
)
}

function ObjectValueCard({ content }: { content: string }) {
function ObjectValueCard({ content, id }: { content: string; id?: string }) {
const isRev = /([0-9a-fA-F]{64}:[0-9]+)/g
const revLink = (rev: string, i: number) => (
<Link
Expand All @@ -42,7 +42,7 @@ function ObjectValueCard({ content }: { content: string }) {
)
const formattedContent = reactStringReplace(content, isRev, revLink)

return <Card content={formattedContent} />
return <Card content={formattedContent} id={`property-${id}-value`} />
}

const SmartObjectValues = ({ smartObject }: any) => {
Expand All @@ -54,7 +54,7 @@ const SmartObjectValues = ({ smartObject }: any) => {
.map(([key, value], i) => (
<div key={i}>
<h3 className="mt-2 text-xl font-bold dark:text-white">{capitalizeFirstLetter(key)}</h3>
<ObjectValueCard content={toObject(value || '')} />
<ObjectValueCard id={key} content={toObject(value || '')} />
</div>
))}
</>
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/SmartObjectFunction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const SmartObjectFunction = ({
await sleep(1000)
const res = await computer.query({ ids: [smartObject._id] })
setFunctionResult({ _rev: res[0] })
setModalTitle('Success!')
setModalTitle('Success')
setShow(true)
} catch (error: any) {
setFunctionResult(getErrorMessage(error))
Expand Down Expand Up @@ -131,7 +131,7 @@ export const SmartObjectFunction = ({
.map((key, fnIndex) => {
const paramList = getFnParamNames(Object.getPrototypeOf(smartObject)[key])
return (
<div className="mt-6 mb-6" key={fnIndex}>
<div className="mt-6 mb-6" key={fnIndex} id={`function-${key}`}>
<h3 className="my-2 text-xl font-bold dark:text-white">
{capitalizeFirstLetter(key)}
</h3>
Expand Down Expand Up @@ -159,6 +159,7 @@ export const SmartObjectFunction = ({
</div>
))}
<button
id={`${key}-call-function-button`}
className="text-gray-900 bg-white border border-gray-300 focus:outline-none hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700"
onClick={(evt) => handleSmartObjectMethod(evt, smartObject, key, paramList)}
>
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const Balance = ({ computer, modSpecs }: { computer: Computer; modSpecs: string[
</div>
{computer.getNetwork() === 'regtest' && (
<button
id="fund-wallet"
type="button"
onClick={fund}
className="absolute bottom-2 right-2 px-1 py-1 text-center text-xs font-medium text-center text-blue-700 hover:text-white border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg dark:border-blue-500 dark:text-blue-500 dark:hover:text-white dark:hover:bg-blue-500 dark:focus:ring-blue-800"
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/common/SmartCallExecutionResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export function FunctionResultModalContent({ functionResult }: any) {
if (functionResult && typeof functionResult === 'object' && !Array.isArray(functionResult))
return (
<>
<div className="p-4 md:p-5 dark:text-gray-400">
<div id="smart-call-execution-success" className="p-4 md:p-5 dark:text-gray-400">
You created a&nbsp;
<Link
id="smart-call-execution-counter-link"
to={`/objects/${functionResult._rev}`}
className="font-medium text-blue-600 dark:text-blue-500 hover:underline"
onClick={() => {
Expand Down
5 changes: 5 additions & 0 deletions packages/vite-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"start": "vite",
"test": "vitest run",
"test:dev": "vitest",
"test:puppeteer": "vitest run --config vite.puppeteer.config.ts",
"test:puppeteer:headless": "HEADLESS=true npm run test:puppeteer",
"test:puppeteer:build:headless": "npm run build && (npm run preview & sleep 2 && URL=http://localhost:4173 HEADLESS=true npm run test:puppeteer && pkill -f 'vite preview')",
"test:show": "npm run test 2>&1 | tee vite-template-test.log; if [ ${PIPESTATUS[0]} -ne 0 ]; then open vite-template-test.log; fi",
"types": "tsc --noEmit"
},
Expand All @@ -25,6 +28,7 @@
"@bitcoin-computer/lib": "^0.23.0-beta.0",
"dotenv": "^16.4.5",
"flowbite": "^2.3.0",
"puppeteer": "^24.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"ts-node": "^10.9.2"
Expand All @@ -35,6 +39,7 @@
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^20.11.20",
"@types/puppeteer": "^7.0.4",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
Expand Down
7 changes: 3 additions & 4 deletions packages/vite-template/src/components/Assets.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Auth, Gallery } from '@bitcoin-computer/components'
import { Counter } from '../contracts/counter'
import { VITE_COUNTER_MOD_SPEC } from '../constants/modSpecs'

const publicKey = Auth.getComputer().getPublicKey()
const contract = { class: Counter }

export function MyAssets() {
return (
<>
<h2 className="text-4xl font-bold dark:text-white">My Counters</h2>
<Gallery.WithPagination contract={contract} publicKey={publicKey} />
<Gallery.WithPagination mod={VITE_COUNTER_MOD_SPEC} publicKey={publicKey} />
</>
)
}
Expand All @@ -17,7 +16,7 @@ export function AllAssets() {
return (
<>
<h2 className="text-4xl font-bold dark:text-white">All Counters</h2>
<Gallery.WithPagination contract={contract} />
<Gallery.WithPagination mod={VITE_COUNTER_MOD_SPEC} />
</>
)
}
Loading