diff --git a/packages/TBC20-app/.prettierrc b/packages/TBC20-app/.prettierrc
index e866155b4..a65b64ade 100644
--- a/packages/TBC20-app/.prettierrc
+++ b/packages/TBC20-app/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": true
+ "singleQuote": true,
+ "trailingComma": "none"
}
diff --git a/packages/TBC20-app/package.json b/packages/TBC20-app/package.json
index 30312112a..bbcf5ddb1 100644
--- a/packages/TBC20-app/package.json
+++ b/packages/TBC20-app/package.json
@@ -28,8 +28,10 @@
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
- "lint": "eslint --ext .ts,.tsx,.js src/ --fix",
- "prettier": "./node_modules/.bin/prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,scss,md}'"
+ "lint": "eslint --ext .ts,.tsx,.js src/",
+ "lint-fix": "eslint --ext .ts,.tsx,.js src/ --fix",
+ "prettier": "./node_modules/.bin/prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,scss,md}'",
+ "types": "tsc --noEmit"
},
"eslintConfig": {
"extends": "react-app"
diff --git a/packages/TBC20/.prettierrc b/packages/TBC20/.prettierrc
index e866155b4..a65b64ade 100644
--- a/packages/TBC20/.prettierrc
+++ b/packages/TBC20/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": true
+ "singleQuote": true,
+ "trailingComma": "none"
}
diff --git a/packages/TBC20/package.json b/packages/TBC20/package.json
index 37181260e..07046d3af 100644
--- a/packages/TBC20/package.json
+++ b/packages/TBC20/package.json
@@ -25,8 +25,10 @@
"clean": "rimraf coverage build tmp",
"clean-logs": "rm -f *.log 2> /dev/null",
"lint": "eslint src test --ext .ts,.tsx",
+ "lint-fix": "eslint src test --ext .ts,.tsx --fix",
"prebuild": "npm run lint",
"start": "node build/src/main.js",
+ "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md}\"",
"types": "tsc",
"test": "mocha --config .mocharc.json",
"test-and-show": "../../scripts/test-and-show.sh tbc20-test.log "
diff --git a/packages/TBC20/src/token.ts b/packages/TBC20/src/token.ts
index 30857b0b5..780221f91 100644
--- a/packages/TBC20/src/token.ts
+++ b/packages/TBC20/src/token.ts
@@ -57,7 +57,7 @@ export class TBC20 implements ITBC20 {
const revs = await this.computer.query({ publicKey })
const bags = await Promise.all(revs.map(async (rev: string) => this.computer.sync(rev)))
return bags.flatMap((bag: Token & { _root: string }) =>
- bag._root === this.mintId ? [bag] : [],
+ bag._root === this.mintId ? [bag] : []
)
}
diff --git a/packages/TBC404-app/.prettierrc b/packages/TBC404-app/.prettierrc
index 0213d4a4b..b7a412b57 100644
--- a/packages/TBC404-app/.prettierrc
+++ b/packages/TBC404-app/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": false
+ "singleQuote": false,
+ "trailingComma": "none"
}
diff --git a/packages/TBC404/.prettierrc b/packages/TBC404/.prettierrc
index e866155b4..a65b64ade 100644
--- a/packages/TBC404/.prettierrc
+++ b/packages/TBC404/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": true
+ "singleQuote": true,
+ "trailingComma": "none"
}
diff --git a/packages/TBC721-app/.prettierrc b/packages/TBC721-app/.prettierrc
index 0213d4a4b..b7a412b57 100644
--- a/packages/TBC721-app/.prettierrc
+++ b/packages/TBC721-app/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": false
+ "singleQuote": false,
+ "trailingComma": "none"
}
diff --git a/packages/TBC721/.prettierrc b/packages/TBC721/.prettierrc
index e866155b4..a65b64ade 100644
--- a/packages/TBC721/.prettierrc
+++ b/packages/TBC721/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": true
+ "singleQuote": true,
+ "trailingComma": "none"
}
diff --git a/packages/chat/.eslintrc b/packages/chat/.eslintrc
new file mode 100644
index 000000000..669d4a8f8
--- /dev/null
+++ b/packages/chat/.eslintrc
@@ -0,0 +1,25 @@
+{
+ "parser": "@typescript-eslint/parser",
+ "extends": ["airbnb-base", "prettier"],
+ "plugins": [],
+ "env": {
+ "jest": true
+ },
+ "globals": {
+ "document": true,
+ "window": true
+ },
+ "rules": {
+ "semi": ["error", "never"],
+ "import/extensions": "off",
+ "lines-between-class-members": "off",
+ "import/prefer-default-export": "off",
+ "no-underscore-dangle": [
+ "error",
+ {
+ "allowAfterThis": true,
+ "allow": ["_readers", "_owners", "_amount", "_id", "_rev", "_root"]
+ }
+ ]
+ }
+}
diff --git a/packages/chat/.prettierrc b/packages/chat/.prettierrc
index e866155b4..a65b64ade 100644
--- a/packages/chat/.prettierrc
+++ b/packages/chat/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": true
+ "singleQuote": true,
+ "trailingComma": "none"
}
diff --git a/packages/chat/package.json b/packages/chat/package.json
index 9944ad56f..29f56e1b3 100644
--- a/packages/chat/package.json
+++ b/packages/chat/package.json
@@ -16,7 +16,9 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
- "eject": "react-scripts eject"
+ "eject": "react-scripts eject",
+ "lint": "eslint src",
+ "lint-fix": "eslint src --fix"
},
"eslintConfig": {
"extends": "react-app"
@@ -32,5 +34,12 @@
"last 1 firefox version",
"last 1 safari version"
]
+ },
+ "devDependencies": {
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
+ "eslint": "^8.57.0",
+ "eslint-config-airbnb-typescript": "^17.1.0",
+ "eslint-config-prettier": "~9.1.0",
+ "eslint-plugin-import": "^2.29.1"
}
}
diff --git a/packages/components/.eslintrc b/packages/components/.eslintrc
new file mode 100644
index 000000000..c905f2c33
--- /dev/null
+++ b/packages/components/.eslintrc
@@ -0,0 +1,25 @@
+{
+ "parser": "@typescript-eslint/parser",
+ "extends": ["airbnb-base", "prettier", "plugin:@typescript-eslint/recommended"],
+ "plugins": ["@typescript-eslint"],
+ "env": {
+ "jest": true,
+ "browser": true
+ },
+ "globals": {},
+ "rules": {
+ "semi": ["error", "never"],
+ "import/extensions": "off",
+ "import/no-unresolved": "off",
+ "lines-between-class-members": "off",
+ "import/prefer-default-export": "off",
+ "@typescript-eslint/no-explicit-any": "off",
+ "no-underscore-dangle": [
+ "error",
+ {
+ "allowAfterThis": true,
+ "allow": ["_readers", "_owners", "_amount", "_id", "_rev", "_root"]
+ }
+ ]
+ }
+}
diff --git a/packages/components/.prettierrc b/packages/components/.prettierrc
index 0213d4a4b..b7a412b57 100644
--- a/packages/components/.prettierrc
+++ b/packages/components/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": false
+ "singleQuote": false,
+ "trailingComma": "none"
}
diff --git a/packages/components/package.json b/packages/components/package.json
index 499c3fab5..0adb6efad 100644
--- a/packages/components/package.json
+++ b/packages/components/package.json
@@ -7,17 +7,27 @@
"scripts": {
"tsc-compile": "rm -rf built/* && tsc",
"install-monorepo": "cd ../../../ && npm run delete-node-modules && npm install && cd monorepo/packages/components",
- "compile": "npm run tsc-compile && npm run install-monorepo"
+ "compile": "npm run tsc-compile && npm run install-monorepo",
+ "lint": "eslint --fix . --ext .ts,.tsx --ignore-pattern built/",
+ "lint-fix": "eslint src --fix",
+ "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md}\"",
+ "types": "tsc --noEmit"
},
"author": "",
"license": "ISC",
"dependencies": {
"@bitcoin-computer/lib": "^0.19.0-beta.0",
+ "eslint": "^8.57.0",
+ "eslint-config-airbnb-base": "^15.0.0",
+ "eslint-config-prettier": "~9.1.0",
+ "eslint-plugin-import": "^2.29.1",
"flowbite": "^2.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
- "@babel/preset-react": "^7.23.3"
+ "@babel/preset-react": "^7.23.3",
+ "@typescript-eslint/eslint-plugin": "^7.9.0",
+ "@typescript-eslint/parser": "^7.9.0"
}
}
diff --git a/packages/components/src/Auth.tsx b/packages/components/src/Auth.tsx
index b49772c7e..73e970f48 100644
--- a/packages/components/src/Auth.tsx
+++ b/packages/components/src/Auth.tsx
@@ -39,10 +39,9 @@ function getPath(chain: string, network: string): string {
function getEnvVariable(name: string) {
const res = process.env[name]
- if (typeof res === "undefined") {
- throw new Error(`Cannot find environment variable "${name}" in the .env file.`)
- }
- else return res
+ if (typeof res === "undefined") {
+ throw new Error(`Cannot find environment variable "${name}" in the .env file.`)
+ } else return res
}
function getUrl(chain: Chain, network: Network) {
@@ -50,8 +49,12 @@ function getUrl(chain: Chain, network: Network) {
}
function defaultConfiguration() {
- const chain = (localStorage.getItem("CHAIN") || getEnvVariable(`REACT_APP_CHAIN`) || "LTC") as Chain
- const network = (localStorage.getItem("NETWORK") || getEnvVariable(`REACT_APP_NETWORK`) || "regtest") as Network
+ const chain = (localStorage.getItem("CHAIN") ||
+ getEnvVariable(`REACT_APP_CHAIN`) ||
+ "LTC") as Chain
+ const network = (localStorage.getItem("NETWORK") ||
+ getEnvVariable(`REACT_APP_NETWORK`) ||
+ "regtest") as Network
const url = getUrl(chain, network)
return { chain, network, url }
}
@@ -66,7 +69,7 @@ function browserConfiguration() {
chain: localStorage.getItem("CHAIN") as Chain,
network: localStorage.getItem("NETWORK") as Network,
path: localStorage.getItem("PATH"),
- url: localStorage.getItem("URL"),
+ url: localStorage.getItem("URL")
}
}
@@ -77,7 +80,7 @@ function getComputer(): Computer {
function MnemonicInput({
mnemonic,
- setMnemonic,
+ setMnemonic
}: {
mnemonic: string
setMnemonic: Dispatch
@@ -180,7 +183,7 @@ function ChainInput({ chain, setChain }: { chain: Chain; setChain: Dispatch
@@ -255,7 +258,7 @@ function PathInput({
chain,
network,
path,
- setPath,
+ setPath
}: {
chain: string
network: string
@@ -292,7 +295,7 @@ function UrlInput({
chain,
network,
url,
- setUrl,
+ setUrl
}: {
chain: Chain
network: Network
@@ -412,5 +415,5 @@ export const Auth = {
browserConfiguration,
getComputer,
LoginForm,
- LoginModal,
+ LoginModal
}
diff --git a/packages/components/src/Card.tsx b/packages/components/src/Card.tsx
index 94378d3b3..32567a2a0 100644
--- a/packages/components/src/Card.tsx
+++ b/packages/components/src/Card.tsx
@@ -1,7 +1,7 @@
export function Card({ content }: any) {
- return ()
-}
\ No newline at end of file
+ return (
+
+ )
+}
diff --git a/packages/components/src/ComputerContext.tsx b/packages/components/src/ComputerContext.tsx
index 94b2c6d7d..fc7514323 100644
--- a/packages/components/src/ComputerContext.tsx
+++ b/packages/components/src/ComputerContext.tsx
@@ -1,4 +1,4 @@
-import { Computer } from '@bitcoin-computer/lib'
-import { createContext } from 'react'
+import { Computer } from "@bitcoin-computer/lib"
+import { createContext } from "react"
-export const ComputerContext = createContext(new Computer())
\ No newline at end of file
+export const ComputerContext = createContext(new Computer())
diff --git a/packages/components/src/Drawer.tsx b/packages/components/src/Drawer.tsx
index b7efe1c95..9278a637c 100644
--- a/packages/components/src/Drawer.tsx
+++ b/packages/components/src/Drawer.tsx
@@ -49,5 +49,5 @@ function Component({ Content, id }: any) {
export const Drawer = {
Component,
- ShowDrawer,
+ ShowDrawer
}
diff --git a/packages/components/src/Error404.tsx b/packages/components/src/Error404.tsx
index 6869141bd..b8ef40297 100644
--- a/packages/components/src/Error404.tsx
+++ b/packages/components/src/Error404.tsx
@@ -1,25 +1,23 @@
-export const Error404 = () => {
- return (
-
-
-
-
- 404
-
-
- Something's missing.
-
-
- Sorry, we can't find that page. You'll find lots to explore on the home page.{" "}
-
-
- Back to Homepage
-
-
+export const Error404 = () => (
+
+
+
+
+ 404
+
+
+ Something's missing.
+
+
+ Sorry, we can't find that page. You'll find lots to explore on the home page.{" "}
+
+
+ Back to Homepage
+
-
- )
-}
+
+
+)
diff --git a/packages/components/src/Gallery.tsx b/packages/components/src/Gallery.tsx
index 8dbf5d7cc..b9d990da3 100644
--- a/packages/components/src/Gallery.tsx
+++ b/packages/components/src/Gallery.tsx
@@ -1,8 +1,8 @@
import { Computer } from "@bitcoin-computer/lib"
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"
@@ -13,7 +13,7 @@ export type UserQuery
= Partial<{
publicKey: string
limit: number
offset: number
- order: 'ASC' | 'DESC'
+ order: "ASC" | "DESC"
ids: string[]
contract: {
class: T
@@ -173,8 +173,8 @@ export default function WithPagination(q: UserQuery) {
const fetch = async () => {
showLoader(true)
const query = { ...q, ...params }
- query["offset"] = contractsPerPage * pageNum
- query["limit"] = contractsPerPage + 1
+ query.offset = contractsPerPage * pageNum
+ query.limit = contractsPerPage + 1
const result = await computer.query(query)
setIsNextAvailable(result.length > contractsPerPage)
setRevs(result)
@@ -220,5 +220,5 @@ export default function WithPagination(q: UserQuery) {
export const Gallery = {
FromRevs,
- WithPagination,
+ WithPagination
}
diff --git a/packages/components/src/Modal.tsx b/packages/components/src/Modal.tsx
index 4e50da521..2962c9433 100644
--- a/packages/components/src/Modal.tsx
+++ b/packages/components/src/Modal.tsx
@@ -1,6 +1,5 @@
import { Modal as ModalClass } from "flowbite"
-import type { ModalOptions } from "flowbite"
-import type { InstanceOptions } from "flowbite"
+import type { ModalOptions, InstanceOptions } from "flowbite"
const get = (id: string) => {
const $modalElement = document.querySelector(`#${id}`) as HTMLElement
@@ -89,5 +88,5 @@ export const Modal = {
ShowButton,
HideButton,
ToggleButton,
- Component,
+ Component
}
diff --git a/packages/components/src/SmartObject.tsx b/packages/components/src/SmartObject.tsx
index df8de48c4..657105cc7 100644
--- a/packages/components/src/SmartObject.tsx
+++ b/packages/components/src/SmartObject.tsx
@@ -1,7 +1,7 @@
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"
@@ -50,111 +50,109 @@ const SmartObjectValues = ({ smartObject }: any) => {
const revToId = (rev: string) => rev?.split(":")[0]
-const MetaData = ({ smartObject }: any) => {
- return (
- <>
- Meta Data
-
-
-
- |
- Key
- |
-
- Short
- |
-
- Value
- |
-
-
-
-
- | Identity |
-
- _id
- |
-
-
- {smartObject?._id}
-
- |
-
-
-
- | Revision |
-
- _rev
- |
-
-
- {smartObject?._rev}
-
- |
-
-
-
- | Root |
-
- _root
- |
-
-
- {smartObject?._root}
-
- |
-
-
-
- | Owners |
-
- _owners
- |
-
-
- {smartObject?._owners}
-
- |
-
-
-
- | Amount |
-
- _amount
- |
-
-
- {smartObject?._amount}
-
- |
-
-
-
- | Transaction |
- |
-
-
- {revToId(smartObject?._rev)}
-
- |
-
-
-
- >
- )
-}
+const MetaData = ({ smartObject }: any) => (
+ <>
+ Meta Data
+
+
+
+ |
+ Key
+ |
+
+ Short
+ |
+
+ Value
+ |
+
+
+
+
+ | Identity |
+
+ _id
+ |
+
+
+ {smartObject?._id}
+
+ |
+
+
+
+ | Revision |
+
+ _rev
+ |
+
+
+ {smartObject?._rev}
+
+ |
+
+
+
+ | Root |
+
+ _root
+ |
+
+
+ {smartObject?._root}
+
+ |
+
+
+
+ | Owners |
+
+ _owners
+ |
+
+
+ {smartObject?._owners}
+
+ |
+
+
+
+ | Amount |
+
+ _amount
+ |
+
+
+ {smartObject?._amount}
+
+ |
+
+
+
+ | Transaction |
+ |
+
+
+ {revToId(smartObject?._rev)}
+
+ |
+
+
+
+ >
+)
function Component() {
const location = useLocation()
@@ -245,5 +243,5 @@ function Component() {
}
export const SmartObject = {
- Component,
+ Component
}
diff --git a/packages/components/src/SmartObjectFunction.tsx b/packages/components/src/SmartObjectFunction.tsx
index a3b94e9fc..2fac153fa 100644
--- a/packages/components/src/SmartObjectFunction.tsx
+++ b/packages/components/src/SmartObjectFunction.tsx
@@ -10,11 +10,11 @@ export const getErrorMessage = (error: any): string => {
"mandatory-script-verify-flag-failed (Operation not valid with the current stack size)"
) {
return "You are not authorized to make changes to this smart object"
- } else if (error?.response?.data?.error) {
+ }
+ if (error?.response?.data?.error) {
return error?.response?.data?.error
- } else {
- return error.message ? error.message : "Error occurred"
}
+ return error.message ? error.message : "Error occurred"
}
export const getFnParamNames = function (fn: string) {
@@ -47,13 +47,12 @@ export const SmartObjectFunction = ({
options,
setFunctionResult,
setShow,
- setModalTitle,
+ setModalTitle
}: any) => {
const [formState, setFormState] = useState({})
const { showLoader } = UtilsContext.useUtilsComponents()
const computer = useContext(ComputerContext)
-
const handleSmartObjectMethod = async (
event: any,
smartObject: any,
@@ -80,12 +79,12 @@ export const SmartObjectFunction = ({
return isValidRev(paramValue)
? param
: typeof paramValue === "string"
- ? `'${paramValue}'`
- : paramValue
+ ? `'${paramValue}'`
+ : paramValue
})})`,
env: { smartObject: smartObject._rev, ...revMap },
fund: true,
- sign: true,
+ sign: true
})
await computer.broadcast(tx!)
@@ -116,7 +115,7 @@ export const SmartObjectFunction = ({
setFormState(value)
}
- const capitalizeFirstLetter = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
+ const capitalizeFirstLetter = (s: string) => s.charAt(0).toUpperCase() + s.slice(1)
if (!functionsExist) return <>>
return (
@@ -130,7 +129,9 @@ export const SmartObjectFunction = ({
const paramList = getFnParamNames(Object.getPrototypeOf(smartObject)[key])
return (
-
{capitalizeFirstLetter(key)}
+
+ {capitalizeFirstLetter(key)}
+
diff --git a/packages/components/src/Transaction.tsx b/packages/components/src/Transaction.tsx
index 3417bf578..fae37b3d2 100644
--- a/packages/components/src/Transaction.tsx
+++ b/packages/components/src/Transaction.tsx
@@ -7,7 +7,7 @@ import { ComputerContext } from "./ComputerContext"
function ExpressionCard({ content, env }: { content: string; env: { [s: string]: string } }) {
const entries = Object.entries(env)
let formattedContent = content as any
- for (let entry of entries) {
+ for (const entry of entries) {
const [name, rev] = entry
const regExp = new RegExp(`(${name})`, "g")
const replacer = (name: string, i: number) => (
@@ -126,34 +126,32 @@ function Component() {
- {rpcTxnData?.vin?.map((input: any, ind: any) => {
- return (
-
- |
-
- {input.txid}
-
- |
-
-
-
- #{input.vout}
-
- |
-
- {input.scriptSig?.asm} |
-
- )
- })}
+ {rpcTxnData?.vin?.map((input: any, ind: any) => (
+
+ |
+
+ {input.txid}
+
+ |
+
+
+
+ #{input.vout}
+
+ |
+
+ {input.scriptSig?.asm} |
+
+ ))}
@@ -182,27 +180,22 @@ function Component() {
- {rpcTxnData?.vout?.map((output: any) => {
- return (
-
- |
-
- #{output.n}
-
- |
-
- {output.value} |
- {output.scriptPubKey.type} |
- {output.scriptPubKey.asm} |
-
- )
- })}
+ {rpcTxnData?.vout?.map((output: any) => (
+
+ |
+
+ #{output.n}
+
+ |
+
+ {output.value} |
+ {output.scriptPubKey.type} |
+ {output.scriptPubKey.asm} |
+
+ ))}
diff --git a/packages/components/src/UtilsContext.tsx b/packages/components/src/UtilsContext.tsx
index ccac1a594..283438ee2 100644
--- a/packages/components/src/UtilsContext.tsx
+++ b/packages/components/src/UtilsContext.tsx
@@ -55,5 +55,5 @@ export const UtilsProvider: React.FC = ({ children }) => {
export const UtilsContext = {
UtilsProvider,
- useUtilsComponents,
+ useUtilsComponents
}
diff --git a/packages/components/src/Wallet.tsx b/packages/components/src/Wallet.tsx
index 8111ad35a..32829157d 100644
--- a/packages/components/src/Wallet.tsx
+++ b/packages/components/src/Wallet.tsx
@@ -82,19 +82,18 @@ const Mnemonic = ({ computer }: any) => {
)
- else
- return (
-
-
-
-
-
- )
+ return (
+
+
+
+
+
+ )
}
const Path = ({ computer }: any) => (
@@ -133,31 +132,28 @@ const Network = ({ computer }: any) => (
)
-const LogOut = () => {
- return (
- <>
-
-
Log out
-
- Logging out will delete your mnemonic. Make sure to write it down.
-
-
-
-
-
- >
- )
-}
+const LogOut = () => (
+ <>
+
+
Log out
+
+ Logging out will delete your mnemonic. Make sure to write it down.
+
+
+
+
+
+ >
+)
export function Wallet() {
const computer = useContext(ComputerContext)
-
const Content = () => (
<>
Wallet
diff --git a/packages/components/src/common/Components.tsx b/packages/components/src/common/Components.tsx
index ca493f2b0..4063c52f5 100644
--- a/packages/components/src/common/Components.tsx
+++ b/packages/components/src/common/Components.tsx
@@ -19,4 +19,4 @@ export function Loader() {
)
-}
\ No newline at end of file
+}
diff --git a/packages/components/src/common/SmartCallExecutionResult.tsx b/packages/components/src/common/SmartCallExecutionResult.tsx
index e12375521..f2b70da32 100644
--- a/packages/components/src/common/SmartCallExecutionResult.tsx
+++ b/packages/components/src/common/SmartCallExecutionResult.tsx
@@ -4,26 +4,29 @@ export function FunctionResultModalContent({ functionResult }: any) {
const navigate = useNavigate()
if (functionResult && typeof functionResult === "object" && !Array.isArray(functionResult))
- return <>
-
- You created a
- {
- navigate(`/objects/${functionResult._rev}`)
- window.location.reload()
- }}
- >
- smart object
- .
-
- >
-
- return
+ return (
+ <>
+
+ You created a
+ {
+ navigate(`/objects/${functionResult._rev}`)
+ window.location.reload()
+ }}
+ >
+ smart object
+
+ .
+
+ >
+ )
+
+ return (
+
You created the value below at Revision {functionResult._rev}
-
- {functionResult.res.toString()}
-
+ {functionResult.res.toString()}
+ )
}
diff --git a/packages/components/src/common/TypeSelectionDropdown.tsx b/packages/components/src/common/TypeSelectionDropdown.tsx
index 72f604ca4..fd8d5fb2b 100644
--- a/packages/components/src/common/TypeSelectionDropdown.tsx
+++ b/packages/components/src/common/TypeSelectionDropdown.tsx
@@ -4,12 +4,12 @@ import {
DropdownInterface,
DropdownOptions,
InstanceOptions,
- initFlowbite,
+ initFlowbite
} from "flowbite"
export const TypeSelectionDropdown = ({ id, onSelectMethod, dropdownList, selectedType }: any) => {
const [dropDown, setDropdown] = useState()
- const [type, setType] = useState(selectedType ? selectedType : "Type")
+ const [type, setType] = useState(selectedType || "Type")
const [dropdownSelectionList] = useState(dropdownList)
useEffect(() => {
@@ -21,11 +21,11 @@ export const TypeSelectionDropdown = ({ id, onSelectMethod, dropdownList, select
triggerType: "click",
offsetSkidding: 0,
offsetDistance: 10,
- delay: 300,
+ delay: 300
}
const instanceOptions: InstanceOptions = {
id: `dropdownMenu${id}`,
- override: true,
+ override: true
}
setDropdown(new Dropdown($targetEl, $triggerEl, options, instanceOptions))
}, [id])
diff --git a/packages/components/src/common/types.ts b/packages/components/src/common/types.ts
index ae75b4f58..5eb750411 100644
--- a/packages/components/src/common/types.ts
+++ b/packages/components/src/common/types.ts
@@ -1,2 +1,2 @@
export type Chain = "LTC" | "BTC" | "DOGE"
-export type Network = "testnet" | "mainnet" | "regtest";
+export type Network = "testnet" | "mainnet" | "regtest"
diff --git a/packages/components/src/common/utils.ts b/packages/components/src/common/utils.ts
index a698f5740..3158bd13e 100644
--- a/packages/components/src/common/utils.ts
+++ b/packages/components/src/common/utils.ts
@@ -40,16 +40,16 @@ export const jsonMap =
throw new Error("Unsupported type")
}
- export const strip = (value: Json): Json => {
- if (isJBasic(value)) return value
- if (isJArray(value)) return value.map(strip)
- const { _id, _root, _rev, _amount, _owners, ...rest } = value
- return rest
- }
+export const strip = (value: Json): Json => {
+ if (isJBasic(value)) return value
+ if (isJArray(value)) return value.map(strip)
+ const { _id, _root, _rev, _amount, _owners, ...rest } = value
+ return rest
+}
// https://github.com/GoogleChromeLabs/jsbi/issues/30
export const toObject = (obj: any) =>
- JSON.stringify(obj, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2);
+ JSON.stringify(obj, (key, value) => (typeof value === "bigint" ? value.toString() : value), 2)
export const capitalizeFirstLetter = (string: string) =>
string.charAt(0).toUpperCase() + string.slice(1)
diff --git a/packages/cra-template/.eslintrc b/packages/cra-template/.eslintrc
new file mode 100644
index 000000000..c905f2c33
--- /dev/null
+++ b/packages/cra-template/.eslintrc
@@ -0,0 +1,25 @@
+{
+ "parser": "@typescript-eslint/parser",
+ "extends": ["airbnb-base", "prettier", "plugin:@typescript-eslint/recommended"],
+ "plugins": ["@typescript-eslint"],
+ "env": {
+ "jest": true,
+ "browser": true
+ },
+ "globals": {},
+ "rules": {
+ "semi": ["error", "never"],
+ "import/extensions": "off",
+ "import/no-unresolved": "off",
+ "lines-between-class-members": "off",
+ "import/prefer-default-export": "off",
+ "@typescript-eslint/no-explicit-any": "off",
+ "no-underscore-dangle": [
+ "error",
+ {
+ "allowAfterThis": true,
+ "allow": ["_readers", "_owners", "_amount", "_id", "_rev", "_root"]
+ }
+ ]
+ }
+}
diff --git a/packages/cra-template/.prettierrc b/packages/cra-template/.prettierrc
index 0213d4a4b..b7a412b57 100644
--- a/packages/cra-template/.prettierrc
+++ b/packages/cra-template/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": false
+ "singleQuote": false,
+ "trailingComma": "none"
}
diff --git a/packages/cra-template/package.json b/packages/cra-template/package.json
index 8095ff853..7b709cc42 100644
--- a/packages/cra-template/package.json
+++ b/packages/cra-template/package.json
@@ -30,7 +30,7 @@
"chai": "^5.1.0",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
- "eslint-config-airbnb-typescript": "^17.1.0",
+ "eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "~9.1.0",
"eslint-plugin-import": "^2.29.1",
"mocha": "^10.3.0",
@@ -41,7 +41,11 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
- "eject": "react-scripts eject"
+ "eject": "react-scripts eject",
+ "lint": "eslint src",
+ "lint-fix": "eslint src --fix",
+ "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md}\"",
+ "types": "tsc --noEmit"
},
"eslintConfig": {
"extends": [
diff --git a/packages/cra-template/src/App.test.tsx b/packages/cra-template/src/App.test.tsx
index 2a68616d9..ea796120d 100644
--- a/packages/cra-template/src/App.test.tsx
+++ b/packages/cra-template/src/App.test.tsx
@@ -1,9 +1,8 @@
-import React from 'react';
-import { render, screen } from '@testing-library/react';
-import App from './App';
+import { render, screen } from "@testing-library/react"
+import App from "./App"
-test('renders learn react link', () => {
- render();
- const linkElement = screen.getByText(/learn react/i);
- expect(linkElement).toBeInTheDocument();
-});
+test("renders learn react link", () => {
+ render()
+ const linkElement = screen.getByText(/learn react/i)
+ expect(linkElement).toBeInTheDocument()
+})
diff --git a/packages/cra-template/src/App.tsx b/packages/cra-template/src/App.tsx
index a52841d29..4f97be861 100644
--- a/packages/cra-template/src/App.tsx
+++ b/packages/cra-template/src/App.tsx
@@ -3,7 +3,15 @@ import { useContext, useEffect, useState } from "react"
import { BrowserRouter, Route, Routes, Navigate } from "react-router-dom"
import { Navbar } from "./components/Navbar"
import { initFlowbite } from "flowbite"
-import { Auth, Error404, UtilsContext, Wallet, SmartObject, Transaction, ComputerContext } from "@bitcoin-computer/components"
+import {
+ Auth,
+ Error404,
+ UtilsContext,
+ Wallet,
+ SmartObject,
+ Transaction,
+ ComputerContext
+} from "@bitcoin-computer/components"
import Mint from "./components/Mint"
import { AllAssets, MyAssets } from "./components/Assets"
diff --git a/packages/cra-template/src/components/Assets.tsx b/packages/cra-template/src/components/Assets.tsx
index 9f611c4a7..9262b73ab 100644
--- a/packages/cra-template/src/components/Assets.tsx
+++ b/packages/cra-template/src/components/Assets.tsx
@@ -5,15 +5,19 @@ const publicKey = Auth.getComputer().getPublicKey()
const contract = { class: Counter }
export function MyAssets() {
- return <>
- My Counters
-
- >
+ return (
+ <>
+ My Counters
+
+ >
+ )
}
export function AllAssets() {
- return <>
- All Counters
-
- >
-}
\ No newline at end of file
+ return (
+ <>
+ All Counters
+
+ >
+ )
+}
diff --git a/packages/cra-template/src/components/Mint.tsx b/packages/cra-template/src/components/Mint.tsx
index 68173dcfc..2d8971a53 100644
--- a/packages/cra-template/src/components/Mint.tsx
+++ b/packages/cra-template/src/components/Mint.tsx
@@ -4,65 +4,74 @@ import { Counter } from "../contracts/counter"
import { Link } from "react-router-dom"
function SuccessContent(rev: string) {
- return <>
-
-
- You created a
{
- Modal.hideModal("success-modal")
- }}
- >counter
+ return (
+ <>
+
+
+ You created a{" "}
+ {
+ Modal.hideModal("success-modal")
+ }}
+ >
+ counter
+
+
-
-
-
-
- >
+
+
+
+ >
+ )
}
function ErrorContent(msg: string) {
- return <>
-
-
- Something went wrong.
- {msg}
+ return (
+ <>
+
+
+ Something went wrong.
+
+
+ {msg}
+
+
+
+
-
-
-
-
- >
+ >
+ )
}
export default function Mint() {
const computer = useContext(ComputerContext)
- const [successRev, setSuccessRev] = useState('')
- const [errorMsg, setErrorMsg] = useState('')
+ const [successRev, setSuccessRev] = useState("")
+ const [errorMsg, setErrorMsg] = useState("")
const onSubmit = async (e: React.SyntheticEvent) => {
e.preventDefault()
try {
const counter = await computer.new(Counter)
setSuccessRev(counter._id)
- Modal.showModal('success-modal')
- } catch(err) {
+ Modal.showModal("success-modal")
+ } catch (err) {
if (err instanceof Error) {
setErrorMsg(err.message)
- Modal.showModal('error-modal')
+ Modal.showModal("error-modal")
}
}
}
@@ -70,10 +79,25 @@ export default function Mint() {
return (
<>
-
-
+
+
>
)
-}
\ No newline at end of file
+}
diff --git a/packages/cra-template/src/components/Navbar.tsx b/packages/cra-template/src/components/Navbar.tsx
index 1dd64a232..1c531832f 100644
--- a/packages/cra-template/src/components/Navbar.tsx
+++ b/packages/cra-template/src/components/Navbar.tsx
@@ -11,7 +11,7 @@ function formatChainAndNetwork(chain: Chain, network: Network) {
const map = {
mainnet: "",
testnet: "t",
- regtest: "r",
+ regtest: "r"
}
const prefix = map[network]
return `${prefix}${chain}`
@@ -82,11 +82,13 @@ function ModalContent() {
}
function SignInItem() {
- return
-
-
+ return (
+
+
+
+ )
}
export function NotLoggedMenu() {
@@ -112,9 +114,10 @@ export function NotLoggedMenu() {
Modal.get(modalId).show()
}
}
-
- function CoinSelectionItem({ chain, network }: { chain: Chain, network: Network }) {
- return
+
+ function CoinSelectionItem({ chain, network }: { chain: Chain; network: Network }) {
+ return (
+
setChainAndNetwork(chain, network)}
className="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
@@ -122,6 +125,7 @@ export function NotLoggedMenu() {
{chain} {network}
+ )
}
return (
@@ -159,17 +163,17 @@ export function NotLoggedMenu() {
className="py-2 text-sm text-gray-700 dark:text-gray-400 cursor-pointer"
aria-labelledby="dropdownLargeButton"
>
-
-
-
+
+
+
@@ -181,35 +185,40 @@ export function NotLoggedMenu() {
}
function WalletItem() {
- return
-
-
+ return (
+
+
+
+ )
}
-const capitalizeFirstLetter = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
+const capitalizeFirstLetter = (s: string) => s.charAt(0).toUpperCase() + s.slice(1)
function Item({ dest }: { dest: string }) {
- return
-
- {capitalizeFirstLetter(dest)}
-
-
+ return (
+
+
+ {capitalizeFirstLetter(dest)}
+
+
+ )
}
export function LoggedInMenu() {
return (
)
}
function NavbarDropdownButton() {
- return
+ )
}
-export function Logo({ name = 'TBC CRA Template' }) {
- return
+export function Logo({ name = "TBC CRA Template" }) {
+ return (
+
{name}
+ )
}
export function Navbar() {
diff --git a/packages/cra-template/src/contracts/counter.ts b/packages/cra-template/src/contracts/counter.ts
index f37d98f02..d010c7ba2 100644
--- a/packages/cra-template/src/contracts/counter.ts
+++ b/packages/cra-template/src/contracts/counter.ts
@@ -1,4 +1,3 @@
-
export class Counter extends Contract {
constructor() {
super({ count: 0 })
@@ -7,4 +6,4 @@ export class Counter extends Contract {
inc() {
this.count += 1
}
-}
\ No newline at end of file
+}
diff --git a/packages/cra-template/src/index.css b/packages/cra-template/src/index.css
index 313433e44..e2ac8d522 100644
--- a/packages/cra-template/src/index.css
+++ b/packages/cra-template/src/index.css
@@ -3,14 +3,12 @@
@tailwind utilities;
body {
margin: 0;
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
- "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
- sans-serif;
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
+ "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
- font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
- monospace;
+ font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
}
diff --git a/packages/cra-template/src/index.tsx b/packages/cra-template/src/index.tsx
index 032464fb6..b15f9a338 100644
--- a/packages/cra-template/src/index.tsx
+++ b/packages/cra-template/src/index.tsx
@@ -1,19 +1,17 @@
-import React from 'react';
-import ReactDOM from 'react-dom/client';
-import './index.css';
-import App from './App';
-import reportWebVitals from './reportWebVitals';
+import React from "react"
+import ReactDOM from "react-dom/client"
+import "./index.css"
+import App from "./App"
+import reportWebVitals from "./reportWebVitals"
-const root = ReactDOM.createRoot(
- document.getElementById('root') as HTMLElement
-);
+const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement)
root.render(
-);
+)
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
-reportWebVitals();
+reportWebVitals()
diff --git a/packages/cra-template/src/reportWebVitals.ts b/packages/cra-template/src/reportWebVitals.ts
index 49a2a16e0..8c8400b19 100644
--- a/packages/cra-template/src/reportWebVitals.ts
+++ b/packages/cra-template/src/reportWebVitals.ts
@@ -1,15 +1,15 @@
-import { ReportHandler } from 'web-vitals';
+import { ReportHandler } from "web-vitals"
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
- import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
- getCLS(onPerfEntry);
- getFID(onPerfEntry);
- getFCP(onPerfEntry);
- getLCP(onPerfEntry);
- getTTFB(onPerfEntry);
- });
+ import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
+ getCLS(onPerfEntry)
+ getFID(onPerfEntry)
+ getFCP(onPerfEntry)
+ getLCP(onPerfEntry)
+ getTTFB(onPerfEntry)
+ })
}
-};
+}
-export default reportWebVitals;
+export default reportWebVitals
diff --git a/packages/cra-template/src/setupTests.ts b/packages/cra-template/src/setupTests.ts
index 8f2609b7b..6a0fd1230 100644
--- a/packages/cra-template/src/setupTests.ts
+++ b/packages/cra-template/src/setupTests.ts
@@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
-import '@testing-library/jest-dom';
+import "@testing-library/jest-dom"
diff --git a/packages/cra-template/src/types/global.d.ts b/packages/cra-template/src/types/global.d.ts
index e191d51fa..755cba884 100644
--- a/packages/cra-template/src/types/global.d.ts
+++ b/packages/cra-template/src/types/global.d.ts
@@ -1 +1 @@
-declare var Contract: any;
+declare var Contract: any
diff --git a/packages/docs/API/query.md b/packages/docs/API/query.md
index 31b05643e..fbb930e36 100644
--- a/packages/docs/API/query.md
+++ b/packages/docs/API/query.md
@@ -5,18 +5,24 @@ Returns the latest revisions of smart objects. Conditions can be passed in to de
### Type
```ts
-
any>(query: {
- publicKey?: string
- ids?: string[]
- mod?: string
- limit?: number
- offset?: number
- order?: 'ASC' | 'DEC'
- contract?: { class: T, args?: ConstructorParameters }
-}) => Promise
+ any>(
+ query:
+ | {
+ ids: string[];
+ }
+ | {
+ publicKey?: string;
+ mod?: string;
+ limit?: number;
+ offset?: number;
+ order?: "ASC" | "DEC";
+ contract?: { class: T; args?: ConstructorParameters };
+ }
+) => Promise;
```
### Syntax
+
```js
await computer.query({ publicKey })
await computer.query({ ids })
@@ -29,24 +35,26 @@ await computer.query({ publicKey, contract, order })
### Parameters
#### params
+
An object with the query parameters.
{.compact}
-| Key | Type | Description |
+| Key | Type | Description |
|-----------|-------------------------------------------------|--------------------------------------------------------------------------------|
-| publicKey | string | Return latest revisions of smart objects owned by a public key |
-| ids | string[] | Return latest revision of smart objects with ids in order |
-| mod | string | Return the latest revision of smart objects created with this module specifier |
-| limit | number | Return only limited number of revisions |
-| offset | number | Return results starting from offset |
-| order | 'ASC' \| 'DEC' | Order results in ascending or descending order |
-| contract | { class: T, args?: ConstructorParameters\ } | Return latest revisions of smart objects from a class |
-
+| publicKey | string | Return latest revisions of smart objects owned by a public key |
+| ids | string[] | Return latest revision of smart objects with ids in order |
+| mod | string | Return the latest revision of smart objects created with this module specifier |
+| limit | number | Return only limited number of revisions |
+| offset | number | Return results starting from offset |
+| order | 'ASC' \| 'DEC' | Order results in ascending or descending order |
+| contract | { class: T, args?: ConstructorParameters\ } | Return latest revisions of smart objects from a class |
### Return value
+
Given the query parameters, returns an array of strings encoding the latest revisions of smart objects that matches the specified conditions.
### Examples
+
```ts
class A extends Contract { ... }
a = await computer.new(A)
@@ -79,4 +87,4 @@ const [revs5] = await computer.query({
contract: { class: A }
})
expect(rev5).to.equal(a._rev)
-```
\ No newline at end of file
+```
diff --git a/packages/explorer/.eslintrc b/packages/explorer/.eslintrc
new file mode 100644
index 000000000..c905f2c33
--- /dev/null
+++ b/packages/explorer/.eslintrc
@@ -0,0 +1,25 @@
+{
+ "parser": "@typescript-eslint/parser",
+ "extends": ["airbnb-base", "prettier", "plugin:@typescript-eslint/recommended"],
+ "plugins": ["@typescript-eslint"],
+ "env": {
+ "jest": true,
+ "browser": true
+ },
+ "globals": {},
+ "rules": {
+ "semi": ["error", "never"],
+ "import/extensions": "off",
+ "import/no-unresolved": "off",
+ "lines-between-class-members": "off",
+ "import/prefer-default-export": "off",
+ "@typescript-eslint/no-explicit-any": "off",
+ "no-underscore-dangle": [
+ "error",
+ {
+ "allowAfterThis": true,
+ "allow": ["_readers", "_owners", "_amount", "_id", "_rev", "_root"]
+ }
+ ]
+ }
+}
diff --git a/packages/explorer/.prettierrc b/packages/explorer/.prettierrc
index e866155b4..a65b64ade 100644
--- a/packages/explorer/.prettierrc
+++ b/packages/explorer/.prettierrc
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"semi": false,
- "singleQuote": true
+ "singleQuote": true,
+ "trailingComma": "none"
}
diff --git a/packages/explorer/package.json b/packages/explorer/package.json
index 20d07a4fc..820091dc7 100644
--- a/packages/explorer/package.json
+++ b/packages/explorer/package.json
@@ -12,6 +12,10 @@
"@types/node": "^20.11.21",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
+ "eslint": "^8.57.0",
+ "eslint-config-airbnb-base": "^15.0.0",
+ "eslint-config-prettier": "~9.1.0",
+ "eslint-plugin-import": "^2.29.1",
"flowbite": "^2.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
@@ -28,7 +32,11 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
- "deploy": "node --experimental-modules scripts/deploy.mjs"
+ "deploy": "node --experimental-modules scripts/deploy.mjs",
+ "lint": "eslint src",
+ "lint-fix": "eslint src --fix",
+ "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md}\"",
+ "types": "tsc --noEmit"
},
"eslintConfig": {
"extends": [
@@ -47,8 +55,5 @@
"last 1 firefox version",
"last 1 safari version"
]
- },
- "devDependencies": {
- "@babel/preset-react": "^7.23.3"
}
}
diff --git a/packages/explorer/src/components/Blocks.tsx b/packages/explorer/src/components/Blocks.tsx
index 8bf884464..584213459 100644
--- a/packages/explorer/src/components/Blocks.tsx
+++ b/packages/explorer/src/components/Blocks.tsx
@@ -37,7 +37,7 @@ export default function Blocks() {
length = totalBlocks - (pageNum * blocksPerPage + blocksPerPage - 1) + blocksPerPage - 1
}
setBlocks(
- Array.from({ length: length }, (_, i) => totalBlocks - (pageNum * blocksPerPage + i)),
+ Array.from({ length: length }, (_, i) => totalBlocks - (pageNum * blocksPerPage + i))
)
} catch (error) {
showSnackBar('Error setting blocks', false)
diff --git a/packages/explorer/src/components/Navbar.tsx b/packages/explorer/src/components/Navbar.tsx
index adb9d2045..6228d9c13 100644
--- a/packages/explorer/src/components/Navbar.tsx
+++ b/packages/explorer/src/components/Navbar.tsx
@@ -35,7 +35,7 @@ function formatChainAndNetwork(chain: string, network: string) {
const prefix = {
mainnet: '',
testnet: 't',
- regtest: 'r',
+ regtest: 'r'
}[network]
return `${prefix}${chain}`
}
@@ -46,7 +46,7 @@ function ModalContent() {
const [url, setUrl] = useState('')
const { showSnackBar } = UtilsContext.useUtilsComponents()
- function submit(e: React.SyntheticEvent) {
+ function submit(e: React.SyntheticEvent) {
e.preventDefault()
const isValidChain = ['LTC', 'BTC', 'DOGE'].includes(chain)
@@ -58,9 +58,8 @@ function ModalContent() {
localStorage.setItem('URL', url)
localStorage.setItem('CHAIN', chain)
localStorage.setItem('NETWORK', network)
- window.location.href = "/"
+ window.location.href = '/'
}
-
}
function closeModal() {
@@ -181,8 +180,20 @@ function NotLoggedMenu() {
className="flex items-center justify-between w-full py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 md:w-auto dark:text-white md:dark:hover:text-blue-500 dark:focus:text-white dark:border-gray-700 dark:hover:bg-gray-700 md:dark:hover:bg-transparent"
>
{dropDownLabel}
-