From 7fe7c9da14b94a3fb6f8bf60285ebf77f0da4505 Mon Sep 17 00:00:00 2001 From: IrohDW Date: Wed, 11 Oct 2023 16:41:55 -0600 Subject: [PATCH] Initial Commit --- README.md | 12 +++++- index.js | 2 + package-lock.json | 43 +++++++++++++++++-- package.json | 17 ++++++-- .../QortalRequest.ts => src/Core/API/Names.ts | 16 +------ src/Core/API/QortalRequest.ts | 0 src/Core/API/Transactions.ts | 11 +++++ {QortalCore => src/Core}/Fetch.ts | 0 {QortalCore => src/Core}/Interfaces.ts | 2 +- {QortalCore => src/Core}/SendCoin.ts | 0 {QortalCore => src/Core}/Types.ts | 0 {Numbers => src/Numbers}/Colors.ts | 0 {Numbers => src/Numbers}/NumberConversion.ts | 0 {Numbers => src/Numbers}/Numbers.ts | 0 {Numbers => src/Numbers}/StringNumbers.ts | 0 {Strings => src/Strings}/printFunctions.ts | 0 global.d.ts => src/global.d.ts | 0 tsconfig.json | 9 ++-- tsconfig.node.json | 9 ++++ vite.config.ts | 14 ++++++ 20 files changed, 108 insertions(+), 27 deletions(-) create mode 100644 index.js rename QortalCore/QortalRequest.ts => src/Core/API/Names.ts (59%) create mode 100644 src/Core/API/QortalRequest.ts create mode 100644 src/Core/API/Transactions.ts rename {QortalCore => src/Core}/Fetch.ts (100%) rename {QortalCore => src/Core}/Interfaces.ts (96%) rename {QortalCore => src/Core}/SendCoin.ts (100%) rename {QortalCore => src/Core}/Types.ts (100%) rename {Numbers => src/Numbers}/Colors.ts (100%) rename {Numbers => src/Numbers}/NumberConversion.ts (100%) rename {Numbers => src/Numbers}/Numbers.ts (100%) rename {Numbers => src/Numbers}/StringNumbers.ts (100%) rename {Strings => src/Strings}/printFunctions.ts (100%) rename global.d.ts => src/global.d.ts (100%) create mode 100644 tsconfig.node.json create mode 100644 vite.config.ts diff --git a/README.md b/README.md index b970d55..76bda41 100644 --- a/README.md +++ b/README.md @@ -1 +1,11 @@ -# Q-Apps-Utils +# Q-App Utilities + +This library contains many utility functions for interacting with the Qortal blockchain in order to abstract out qortalRequest calls. This enables Frontend Developers to write Q-Apps without needing to know the Qortal Core API while also significantly reducing the complexity and size of code involved in using it. + +## What is Qortal +Qortal is a replacement for the traditional internet that provides user ownership of their data, 1 account for ALL websites, censorship immunity, and significantly more privacy and security than regular websites. + +Instead of centralized servers, Terms of Service, and databases constantly getting hacked, users on Qortal share copies of the websites they visit with each other, and all code is run on the user's machine. +Websites and the data they use such as videos, audio, blog posts, etc. are stored on the Qortal Data Network either publicly, or an encrypted format that only the user or other authorized accounts can see. + +Qortal Apps made by the development team can be found in the [Q-Apps repository](https://github.com/Qortal/Q-Apps) diff --git a/index.js b/index.js new file mode 100644 index 0000000..de5231d --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +const QortalUtils = require("./src/"); +module.exports = QortalUtils; diff --git a/package-lock.json b/package-lock.json index a838ea6..510e4e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,21 @@ { - "name": "q-utils", - "version": "0.0.0", + "name": "qortal-app-utils", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "q-utils", - "version": "0.0.0", + "name": "qortal-app-utils", + "version": "1.0.0", "dependencies": { "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.11.11", "@mui/material": "^5.11.13", "@mui/system": "^5.14.5", + "@types/node": "^20.8.4", "colorsys": "github:netbeast/colorsys", + "node": "^20.7.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", @@ -1371,6 +1373,14 @@ "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, + "node_modules/@types/node": { + "version": "20.8.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.4.tgz", + "integrity": "sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A==", + "dependencies": { + "undici-types": "~5.25.1" + } + }, "node_modules/@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -3094,6 +3104,26 @@ "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", "dev": true }, + "node_modules/node": { + "version": "20.7.0", + "resolved": "https://registry.npmjs.org/node/-/node-20.7.0.tgz", + "integrity": "sha512-GiKqtgSALW8+W7Zi9T2AI9aME8hJg+1EESH6O7Xmk4k1gJfBKOolpy9gdg8vCyR8dMeJlp5GQZOYnvxsu8v5TA==", + "hasInstallScript": true, + "dependencies": { + "node-bin-setup": "^1.0.0" + }, + "bin": { + "node": "bin/node" + }, + "engines": { + "npm": ">=5.0.0" + } + }, + "node_modules/node-bin-setup": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-bin-setup/-/node-bin-setup-1.1.3.tgz", + "integrity": "sha512-opgw9iSCAzT2+6wJOETCpeRYAQxSopqQ2z+N6BXwIMsQQ7Zj5M8MaafQY8JMlolRR6R1UXg2WmhKp0p9lSOivg==" + }, "node_modules/node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", @@ -3884,6 +3914,11 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "5.25.3", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" + }, "node_modules/update-browserslist-db": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", diff --git a/package.json b/package.json index aaec8a8..74e1443 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,16 @@ { - "name": "q-utils", - "private": true, - "version": "0.0.0", + "name": "qortal-app-utils", + "version": "1.0.0", + "description": "A series of convenience functions that perform common tasks, especially those that interact with the Qortal blockchain", + "keywords": ["Qortal", "QortalDataNetwork"], + "author": "Qortal Dev Team", + "repository": { + "type": "git", + "url": "https://github.com/Qortal/Q-Apps-Utils" + }, + "private": false, + "main": "index.js", + "types": "index.d.ts", "type": "module", "scripts": { "dev": "vite", @@ -15,7 +24,9 @@ "@mui/icons-material": "^5.11.11", "@mui/material": "^5.11.13", "@mui/system": "^5.14.5", + "@types/node": "^20.8.4", "colorsys": "github:netbeast/colorsys", + "node": "^20.7.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", diff --git a/QortalCore/QortalRequest.ts b/src/Core/API/Names.ts similarity index 59% rename from QortalCore/QortalRequest.ts rename to src/Core/API/Names.ts index 58abfb7..ffda9b2 100644 --- a/QortalCore/QortalRequest.ts +++ b/src/Core/API/Names.ts @@ -1,17 +1,5 @@ -import { - GetRequestData, - SearchTransactionResponse, - TransactionSearchParams, -} from "./Interfaces"; -import { stringIsEmpty } from "../Numbers/StringNumbers"; - -export const searchTransactions = async (params: TransactionSearchParams) => { - return (await qortalRequest({ - action: "SEARCH_TRANSACTIONS", - ...params, - })) as SearchTransactionResponse[]; -}; - +import { stringIsEmpty } from "../../Numbers/StringNumbers"; +import { GetRequestData } from "../Interfaces"; type AccountName = { name: string; owner: string }; export const getAccountNames = async ( diff --git a/src/Core/API/QortalRequest.ts b/src/Core/API/QortalRequest.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/Core/API/Transactions.ts b/src/Core/API/Transactions.ts new file mode 100644 index 0000000..8216a6d --- /dev/null +++ b/src/Core/API/Transactions.ts @@ -0,0 +1,11 @@ +import { + SearchTransactionResponse, + TransactionSearchParams, +} from "../Interfaces"; + +export const searchTransactions = async (params: TransactionSearchParams) => { + return (await qortalRequest({ + action: "SEARCH_TRANSACTIONS", + ...params, + })) as SearchTransactionResponse[]; +}; diff --git a/QortalCore/Fetch.ts b/src/Core/Fetch.ts similarity index 100% rename from QortalCore/Fetch.ts rename to src/Core/Fetch.ts diff --git a/QortalCore/Interfaces.ts b/src/Core/Interfaces.ts similarity index 96% rename from QortalCore/Interfaces.ts rename to src/Core/Interfaces.ts index e7051d8..452edb8 100644 --- a/QortalCore/Interfaces.ts +++ b/src/Core/Interfaces.ts @@ -1,4 +1,4 @@ -import { ConfirmationStatus, TransactionType } from "./Types"; +import { ConfirmationStatus, TransactionType } from ".//Types"; export interface GetRequestData { limit?: number; diff --git a/QortalCore/SendCoin.ts b/src/Core/SendCoin.ts similarity index 100% rename from QortalCore/SendCoin.ts rename to src/Core/SendCoin.ts diff --git a/QortalCore/Types.ts b/src/Core/Types.ts similarity index 100% rename from QortalCore/Types.ts rename to src/Core/Types.ts diff --git a/Numbers/Colors.ts b/src/Numbers/Colors.ts similarity index 100% rename from Numbers/Colors.ts rename to src/Numbers/Colors.ts diff --git a/Numbers/NumberConversion.ts b/src/Numbers/NumberConversion.ts similarity index 100% rename from Numbers/NumberConversion.ts rename to src/Numbers/NumberConversion.ts diff --git a/Numbers/Numbers.ts b/src/Numbers/Numbers.ts similarity index 100% rename from Numbers/Numbers.ts rename to src/Numbers/Numbers.ts diff --git a/Numbers/StringNumbers.ts b/src/Numbers/StringNumbers.ts similarity index 100% rename from Numbers/StringNumbers.ts rename to src/Numbers/StringNumbers.ts diff --git a/Strings/printFunctions.ts b/src/Strings/printFunctions.ts similarity index 100% rename from Strings/printFunctions.ts rename to src/Strings/printFunctions.ts diff --git a/global.d.ts b/src/global.d.ts similarity index 100% rename from global.d.ts rename to src/global.d.ts diff --git a/tsconfig.json b/tsconfig.json index 7de346b..d4de811 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { "target": "ESNext", - "lib": ["DOM", "DOM.Iterable", "ESNext"], "module": "ESNext", + "lib": ["DOM", "DOM.Iterable", "ESNext"], "skipLibCheck": true, - + "declaration": true, + "sourceMap": true, /* Bundler mode */ - "moduleResolution": "Node", + "moduleResolution": "node", "esModuleInterop": true, "allowImportingTsExtensions": true, "resolveJsonModule": true, @@ -21,6 +22,6 @@ "noFallthroughCasesInSwitch": true, "allowSyntheticDefaultImports": true }, - "include": ["**/*"], + "include": ["src/**/*"], "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..71fdc55 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..4359b75 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import { resolve } from "path"; +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + lib: { + entry: resolve(__dirname, "index.js"), + name: "QortalUtils", + }, + }, + plugins: [react()], + base: "", +});