-
-
- Module Specifier
- Optional
-
-
-
setModSpec(e.target.value)}
- className="sm:w-full md:w-2/3 lg:w-1/2 mr-4 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="mod spec"
- required
- />
+export const ModSpec = ({ modSpec, setModSpec }: { modSpec: any; setModSpec: any }) => (
+ <>
+
+
+
+ Module Specifier
+ Optional
+
- >
- )
-}
+
setModSpec(e.target.value)}
+ className="sm:w-full md:w-2/3 lg:w-1/2 mr-4 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="mod spec"
+ required
+ />
+
+ >
+)
diff --git a/packages/explorer/src/components/playground/Playground.tsx b/packages/explorer/src/components/playground/Playground.tsx
index 376b2ee21..22141b670 100644
--- a/packages/explorer/src/components/playground/Playground.tsx
+++ b/packages/explorer/src/components/playground/Playground.tsx
@@ -1,8 +1,9 @@
import { useEffect, useState } from 'react'
+import { initFlowbite } from 'flowbite'
+import { Auth, Modal, FunctionResultModalContent } from '@bitcoin-computer/components'
import CreateNew from './CreateNew'
import ExecuteExpression from './ExecuteExpression'
import DeployModule from './DeployModule'
-import { initFlowbite } from 'flowbite'
import {
chat,
chatExport,
@@ -21,109 +22,104 @@ import {
nftVars,
tokenVars
} from './examples'
-import { Auth, Modal, FunctionResultModalContent } from '@bitcoin-computer/components'
const modalId = 'playground-info-modal'
-const Examples = ({ loadExamples, clearExamples }: { loadExamples: any; clearExamples: any }) => {
- return (
- <>
-
-
Load Examples
-
-
-
+const Examples = ({ loadExamples, clearExamples }: { loadExamples: any; clearExamples: any }) => (
+ <>
+
+
Load Examples
+
+
+
+
+
+
+
+
+ >
+)
+
+const Tabs = () => (
+
+
+ -
+
+ -
+
+ -
-
-
- >
- )
-}
-
-const Tabs = () => {
- return (
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- )
-}
+
+
+
+)
const Playground = () => {
const [computer] = useState
(Auth.getComputer())
@@ -135,7 +131,11 @@ const Playground = () => {
const [modalTitle, setModalTitle] = useState('')
const setShow: any = (flag: boolean) => {
- flag ? Modal.get(modalId).show() : Modal.get(modalId).hide()
+ if (flag) {
+ Modal.get(modalId).show()
+ } else {
+ Modal.get(modalId).hide()
+ }
}
useEffect(() => {
diff --git a/packages/explorer/src/types/global.d.ts b/packages/explorer/src/types/global.d.ts
index 755cba884..89850bda3 100644
--- a/packages/explorer/src/types/global.d.ts
+++ b/packages/explorer/src/types/global.d.ts
@@ -1 +1 @@
-declare var Contract: any
+declare const Contract: any
diff --git a/packages/explorer/src/utils.ts b/packages/explorer/src/utils.ts
index 79738d5eb..3390dcfef 100644
--- a/packages/explorer/src/utils.ts
+++ b/packages/explorer/src/utils.ts
@@ -14,6 +14,7 @@ export function isValidRev(value: any): boolean {
// eslint-disable-next-line
export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
+// eslint-disable-next-line
type Json = JBasic | JObject | JArray
type JBasic = undefined | null | boolean | number | string | symbol | bigint
type JArray = Json[]
@@ -59,6 +60,7 @@ export const jsonMap =
export const strip = (value: Json): Json => {
if (isJBasic(value)) return value
if (isJArray(value)) return value.map(strip)
+ // eslint-disable-next-line
const { _id, _root, _rev, _amount, _owners, ...rest } = value
return rest
}
@@ -95,7 +97,7 @@ export const capitalizeFirstLetter = (string: string) =>
export const isValidHexadecimalPublicKey = (publicKey: string): boolean => {
if (!publicKey) return false
- let trimmedPublicKey = publicKey.trim()
+ const trimmedPublicKey = publicKey.trim()
return trimmedPublicKey.length === 64 || trimmedPublicKey.length === 66
}
@@ -105,11 +107,13 @@ export const getErrorMessage = (error: any): string => {
'mandatory-script-verify-flag-failed (Operation not valid with the current stack size)'
) {
return 'You are not authorised 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'
}
// https://github.com/GoogleChromeLabs/jsbi/issues/30
diff --git a/packages/wallet/package.json b/packages/wallet/package.json
index 624e2e49d..e9c790f88 100644
--- a/packages/wallet/package.json
+++ b/packages/wallet/package.json
@@ -3,6 +3,7 @@
"version": "0.19.0-beta.0",
"private": true,
"dependencies": {
+ "@bitcoin-computer/components": "^0.19.0-beta.0",
"@bitcoin-computer/lib": "^0.19.0-beta.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
diff --git a/packages/wallet/src/App.tsx b/packages/wallet/src/App.tsx
index 0dafa2f3f..ae535b29c 100644
--- a/packages/wallet/src/App.tsx
+++ b/packages/wallet/src/App.tsx
@@ -8,12 +8,12 @@ import {
UtilsContext,
ComputerContext
} from "@bitcoin-computer/components"
+import { useState } from "react"
import { Send } from "./components/Send"
import { Details } from "./components/Details"
import Transactions from "./components/Transactions"
import { Assets } from "./components/Assets"
import { SideBar } from "./components/Sidebar"
-import { useState } from "react"
export default function App() {
const [computer] = useState(Auth.getComputer())
diff --git a/packages/wallet/src/components/Details.tsx b/packages/wallet/src/components/Details.tsx
index a66150417..d673950d9 100644
--- a/packages/wallet/src/components/Details.tsx
+++ b/packages/wallet/src/components/Details.tsx
@@ -5,7 +5,7 @@ import { Computer } from "@bitcoin-computer/lib"
export const Details = () => {
const [computer] = useState(Auth.getComputer())
- const Mnemonic = ({ computer }: any) => {
+ const Mnemonic = ({ computer: comp }: any) => {
const [showMnemonic, setShowMnemonic] = useState(false)
const Heading = () => Mnemonic
@@ -14,10 +14,7 @@ export const Details = () => {
return (
-
- {/* @ts-ignore */}
- {computer.getMnemonic()}
-
+
{comp?.getMnemonic()}
)
- else
- return (
-
-
-
-
-
- )
+ return (
+
+
+
+
+
+ )
}
return (
@@ -59,16 +55,10 @@ export const Details = () => {
{computer.getNetwork()}
Path
-
- {/* @ts-ignore */}
- {computer.getPath() as any}
-
+ {computer.getPath() as any}
Url
-
- {/* @ts-ignore */}
- {computer.getUrl() as any}
-
+ {computer.getUrl() as any}
>
diff --git a/packages/wallet/src/components/Navbar.tsx b/packages/wallet/src/components/Navbar.tsx
index 7bf701f46..96e992681 100644
--- a/packages/wallet/src/components/Navbar.tsx
+++ b/packages/wallet/src/components/Navbar.tsx
@@ -1,8 +1,7 @@
import { Computer } from "@bitcoin-computer/lib"
import { initFlowbite } from "flowbite"
import { Dispatch, useEffect, useState } from "react"
-import { useNavigate } from "react-router-dom"
-import { Link } from "react-router-dom"
+import { useNavigate, Link } from "react-router-dom"
import { explorerURL } from "../config"
import { isValidHexadecimalPrivateKey } from "../utils"
@@ -22,7 +21,7 @@ export default function Navbar({
const isLoggedIn = !!localStorage.getItem("BIP_39_KEY")
const search = async (event: any) => {
- var code = event.keyCode || event.which
+ const code = event.keyCode || event.which
if (code === 13) {
if (searchInput === "") navigate("/")
else if (searchInput.includes(":")) {
diff --git a/packages/wallet/src/components/Send.tsx b/packages/wallet/src/components/Send.tsx
index 3294c0a1c..a8242f93b 100644
--- a/packages/wallet/src/components/Send.tsx
+++ b/packages/wallet/src/components/Send.tsx
@@ -10,8 +10,7 @@ export function SentTransactions({ computer }: { computer: Computer }) {
const [txs, setTxs] = useState({ sentTxs: [], receivedTxs: [] })
const updateTxs = useCallback(async () => {
- // @ts-ignore
- setTxs(await computer.listTxs())
+ setTxs((await computer.listTxs()) as any)
}, [computer])
useEffect(() => {
diff --git a/packages/wallet/src/components/Transactions.tsx b/packages/wallet/src/components/Transactions.tsx
index d756591e5..5c63aa078 100644
--- a/packages/wallet/src/components/Transactions.tsx
+++ b/packages/wallet/src/components/Transactions.tsx
@@ -1,17 +1,16 @@
import { initFlowbite } from "flowbite"
import { useCallback, useContext, useEffect, useState } from "react"
import { HiRefresh } from "react-icons/hi"
+import { ComputerContext } from "@bitcoin-computer/components"
import TransactionTable from "./TransactionTable"
import { TableTxs } from "../types/common"
-import { ComputerContext } from "@bitcoin-computer/components"
export default function Transactions() {
const computer = useContext(ComputerContext)
const [txs, setTxs] = useState({ sentTxs: [], receivedTxs: [] })
const updateTxs = useCallback(async () => {
- // @ts-ignore
- setTxs(await computer.listTxs())
+ setTxs((await computer.listTxs()) as any)
}, [computer])
useEffect(() => {
diff --git a/packages/wallet/src/components/TypeSelectionDropdown.tsx b/packages/wallet/src/components/TypeSelectionDropdown.tsx
index 7d420dc7c..6e38cc3f9 100644
--- a/packages/wallet/src/components/TypeSelectionDropdown.tsx
+++ b/packages/wallet/src/components/TypeSelectionDropdown.tsx
@@ -1,11 +1,10 @@
import { Dropdown, initFlowbite } from "flowbite"
-import type { DropdownOptions, DropdownInterface } from "flowbite"
-import type { InstanceOptions } from "flowbite"
+import type { DropdownOptions, DropdownInterface, InstanceOptions } from "flowbite"
import { useEffect, useState } from "react"
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(() => {
@@ -26,9 +25,9 @@ export const TypeSelectionDropdown = ({ id, onSelectMethod, dropdownList, select
setDropdown(new Dropdown($targetEl, $triggerEl, options, instanceOptions))
}, [])
- const handleClick = (type: string) => {
- setType(type)
- onSelectMethod(type)
+ const handleClick = (clicktType: string) => {
+ setType(clicktType)
+ onSelectMethod(clicktType)
if (dropDown) dropDown.hide()
}
diff --git a/packages/wallet/src/components/Utils/Drawer.tsx b/packages/wallet/src/components/Utils/Drawer.tsx
index 814e2c1ca..5c8b4f8fd 100644
--- a/packages/wallet/src/components/Utils/Drawer.tsx
+++ b/packages/wallet/src/components/Utils/Drawer.tsx
@@ -1,10 +1,8 @@
import { initFlowbite } from "flowbite"
-import { useCallback, useEffect, useState } from "react"
-import { HiRefresh } from "react-icons/hi"
+import { useEffect, useState } from "react"
import { chunk } from "../../utils"
export const CustomDrawer = ({ id, computer }: any) => {
- const [balance, setBalance] = useState(0)
const [showMnemonic, setShowMnemonic] = useState(false)
function Card({ content }: { content: string }) {
@@ -23,10 +21,11 @@ export const CustomDrawer = ({ id, computer }: any) => {
const mnemonicWell = () => {
const mnemonicChunks = chunk(computer.getMnemonic().split(" "))
- const mnemonicChunksString = mnemonicChunks.map((chunk) => chunk.join(" ") + "\n").join(" ")
+ const mnemonicChunksString = mnemonicChunks.map((batch) => `${batch.join(" ")}\n`).join(" ")
+
return (
<>
-
+