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
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

npm run husky:checks
npm run husky:checks || exit 1
2,486 changes: 1,939 additions & 547 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"check:obfuscation": "./scripts/check-obfuscation.sh",
"clean": "find . -name 'node_modules' -type d -prune -exec rm -rf {} \\;",
"format": "npm run format --if-present --workspaces",
"husky:checks": "npm run check:obfuscation",
"husky:checks": "npm run check:obfuscation && npm run lint",
"lint": "npm run lint --if-present --workspaces",
"lint:fix": "npm run lint --if-present --workspaces -- --fix",
"prepare": "husky",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Wallet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useContext, useEffect, useState } from 'react'
import { HiRefresh, HiOutlineClipboardCopy } from 'react-icons/hi'
import { HiRefresh } from 'react-icons/hi'
import { FiCopy, FiCheck } from 'react-icons/fi'
import { Computer } from '@bitcoin-computer/lib'
import { Auth } from './Auth'
Expand Down
12 changes: 10 additions & 2 deletions packages/explorer/src/components/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ function Block() {
const params = useParams()
const computer = useContext(ComputerContext)
const [block] = useState(params.block)
const [blockData, setBlockData] = useState<any | null>(null)
const [blockData, setBlockData] = useState<{
hash: string
time: string
size: string
weight: string
previousblockhash: string
nextblockhash: string
tx: { txid: string }[]
} | null>(null)
const { showSnackBar, showLoader } = UtilsContext.useUtilsComponents()

useEffect(() => {
Expand Down Expand Up @@ -118,7 +126,7 @@ function Block() {
</tr>
</thead>
<tbody>
{blockData?.tx?.map((txn: any) => (
{blockData?.tx?.map((txn: { txid: string }) => (
<tr
key={txn.txid}
className="bg-white border-b dark:bg-gray-800 dark:border-gray-700"
Expand Down
2 changes: 1 addition & 1 deletion packages/explorer/src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function Card({ content }: any) {
export function Card({ content }: { content: string }) {
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>
Expand Down
1 change: 1 addition & 0 deletions packages/explorer/src/components/Module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function Module() {
const computer = useContext(ComputerContext)
const params = useParams()
const [modSpec] = useState(params.rev)
// eslint-disable-next-line
const [module, setModule] = useState<any>({})
const { showSnackBar } = UtilsContext.useUtilsComponents()

Expand Down
2 changes: 1 addition & 1 deletion packages/explorer/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function SearchBar() {
try {
await computer.load(searchInput)
navigate(`/modules/${searchInput}`)
} catch (error) {
} catch {
navigate(`/objects/${searchInput}`)
}
} else if (isValidHexadecimalPublicKey(searchInput))
Expand Down
12 changes: 11 additions & 1 deletion packages/explorer/src/components/TypeSelectionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ import { Dropdown, initFlowbite } from 'flowbite'
import type { DropdownOptions, DropdownInterface, InstanceOptions } from 'flowbite'
import { useEffect, useState } from 'react'

export const TypeSelectionDropdown = ({ id, onSelectMethod, dropdownList, selectedType }: any) => {
export const TypeSelectionDropdown = ({
id,
onSelectMethod,
dropdownList,
selectedType,
}: {
id: string
onSelectMethod: (option: string) => void
dropdownList: string[]
selectedType: string
}) => {
const [dropDown, setDropdown] = useState<DropdownInterface>()
const [type, setType] = useState(selectedType || 'Type')
const [dropdownSelectionList] = useState(dropdownList)
Expand Down
7 changes: 5 additions & 2 deletions packages/explorer/src/components/playground/CreateNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ interface Argument {

const CreateNew = (props: {
computer: Computer
setShow: Dispatch<SetStateAction<boolean>>
setShow: (flag: boolean) => void
// eslint-disable-next-line
setFunctionResult: Dispatch<SetStateAction<any>>
setModalTitle: Dispatch<SetStateAction<string>>
exampleCode: string
Expand Down Expand Up @@ -112,6 +113,7 @@ const CreateNew = (props: {
const { tx } = await computer.encode(encodeObject)
const txId = await computer.broadcast(tx)
sleep(500)
// eslint-disable-next-line
const { res } = (await computer.sync(txId)) as any
setFunctionResult({ _rev: res._rev, type: 'objects' })
setModalTitle('Success!')
Expand All @@ -121,7 +123,7 @@ const CreateNew = (props: {
setModalTitle('Error!')
setShow(true)
}
} catch (error: any) {
} catch (error: unknown) {
setFunctionResult(getErrorMessage(error))
setModalTitle('Error!')
setShow(true)
Expand All @@ -139,6 +141,7 @@ const CreateNew = (props: {
placeholder="Enter your JS class and code here"
rows={16}
className="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white font-mono" // Added font-mono for monospaced font
// eslint-disable-next-line
style={{ tabSize: 2, MozTabSize: 2, OTabSize: 2, WebkitTabSize: 2 } as any} // Set tab size to 2 spaces
spellCheck="false" // Disable spell check
autoCapitalize="none" // Disable auto capitalization
Expand Down
6 changes: 4 additions & 2 deletions packages/explorer/src/components/playground/DeployModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { getErrorMessage } from '../../utils'

const DeployModule = (props: {
computer: Computer
setShow: Dispatch<SetStateAction<boolean>>
setShow: (flag: boolean) => void
// eslint-disable-next-line
setFunctionResult: Dispatch<SetStateAction<any>>
setModalTitle: Dispatch<SetStateAction<string>>
exampleModule: string
Expand All @@ -25,7 +26,7 @@ const DeployModule = (props: {
setFunctionResult({ _rev: modSpec, type: 'modules' })
setModalTitle('Success!')
setShow(true)
} catch (error: any) {
} catch (error: unknown) {
setFunctionResult(getErrorMessage(error))
setModalTitle('Error!')
setShow(true)
Expand All @@ -43,6 +44,7 @@ const DeployModule = (props: {
placeholder="Enter your module here"
rows={16}
className="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white font-mono" // Added font-mono for monospaced font
// eslint-disable-next-line
style={{ tabSize: 2, MozTabSize: 2, OTabSize: 2, WebkitTabSize: 2 } as any} // Set tab size to 2 spaces
spellCheck="false" // Disable spell check
autoCapitalize="none" // Disable auto capitalization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ interface ExpressionArgument {

const ExecuteExpression = (props: {
computer: Computer
setShow: Dispatch<SetStateAction<boolean>>
setShow: (flag: boolean) => void
// eslint-disable-next-line
setFunctionResult: Dispatch<SetStateAction<any>>
setModalTitle: Dispatch<SetStateAction<string>>
exampleExpression: string
Expand Down Expand Up @@ -90,7 +91,7 @@ const ExecuteExpression = (props: {
setFunctionResult({ _rev: `${txId}:0`, type: 'objects', res: effect.res })
setModalTitle('Success!')
setShow(true)
} catch (error: any) {
} catch (error: unknown) {
setFunctionResult(getErrorMessage(error))
setModalTitle('Error!')
setShow(true)
Expand All @@ -108,6 +109,7 @@ const ExecuteExpression = (props: {
placeholder="Enter expression here"
rows={16}
className="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white font-mono" // Added font-mono for monospaced font
// eslint-disable-next-line
style={{ tabSize: 2, MozTabSize: 2, OTabSize: 2, WebkitTabSize: 2 } as any} // Set tab size to 2 spaces
spellCheck="false" // Disable spell check
autoCapitalize="none" // Disable auto capitalization
Expand Down
12 changes: 9 additions & 3 deletions packages/explorer/src/components/playground/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,20 @@ const Tabs = () => (

const Playground = () => {
const [computer] = useState<Computer>(Auth.getComputer())
const [functionResult, setFunctionResult] = useState<any>({})
const [functionResult, setFunctionResult] = useState<string | { [key: string]: string }>({})
const [exampleCode, setExampleCode] = useState<string>('')
const [exampleExpression, setExampleExpresion] = useState<string>('')
const [exampleModule, setExampleModule] = useState<string>('')
const [exampleVars, setExampleVars] = useState<any[]>([])
const [exampleVars, setExampleVars] = useState<
{
name: string
type: string
value: string
}[]
>([])
const [modalTitle, setModalTitle] = useState('')

const setShow: any = (flag: boolean) => {
const setShow = (flag: boolean): void => {
if (flag) {
Modal.get(modalId).show()
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/explorer/src/components/playground/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const tokenVars = (pubKey: string) => [
{
name: 'supply',
type: 'number',
value: 100,
value: '100',
},
{
name: 'to',
Expand Down
12 changes: 10 additions & 2 deletions packages/explorer/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ export interface ErrorResponse {
message?: string
}

export const getErrorMessage = (error: ErrorResponse): string => {
const isErrorResponse = (error: unknown): error is ErrorResponse => {
return typeof error === 'object'
}

export const getErrorMessage = (error: ErrorResponse | unknown): string => {
if (!isErrorResponse(error)) {
return 'Error occurred'
}

if (
error?.response?.data?.error ===
'mandatory-script-verify-flag-failed (Operation not valid with the current stack size)'
Expand All @@ -123,7 +131,7 @@ export const getErrorMessage = (error: ErrorResponse): string => {
return error?.response?.data?.error
}

return error.message ? error.message : 'Error occurred'
return error instanceof Error ? error.message : 'Error occurred'
}

// https://github.com/GoogleChromeLabs/jsbi/issues/30
Expand Down
20 changes: 10 additions & 10 deletions packages/lib/dist/bc-lib.browser.min.mjs

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions packages/lib/dist/bc-lib.commonjs.min.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lib/dist/bc-lib.main.es.mjs

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions packages/lib/dist/bc-lib.module.es.mjs

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions packages/nft/src/components/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { initFlowbite } from 'flowbite'
import { ComputerContext, UtilsContext } from '@bitcoin-computer/components'
import { NFT } from '@bitcoin-computer/TBC721'

// eslint-disable-next-line
export type Class = new (...args: any) => any

export type UserQuery<T extends Class> = Partial<{
Expand Down Expand Up @@ -46,7 +47,7 @@ function NFTCard({ nft }: { nft: NFT | undefined }) {
)
}

function HomePageCard({ content }: any) {
function HomePageCard({ content }: { content: string | (() => JSX.Element) }) {
return (
<div className="block w-80 p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
<pre className="font-normal overflow-auto text-gray-700 dark:text-gray-400 text-xs">
Expand Down Expand Up @@ -171,7 +172,18 @@ function FromRevs({ revs, computer }: { revs: string[]; computer: Computer }) {
)
}

function Pagination({ isPrevAvailable, handlePrev, isNextAvailable, handleNext }: any) {
function Pagination({
isPrevAvailable,
handlePrev,
isNextAvailable,
handleNext,
}: {
isPrevAvailable: boolean
handlePrev: () => Promise<void>
isNextAvailable: boolean
handleNext: () => Promise<void>
revs: string[]
}) {
return (
<nav className="flex items-center justify-between" aria-label="Table navigation">
<ul className="inline-flex items-center -space-x-px">
Expand Down
2 changes: 1 addition & 1 deletion packages/nft/src/components/Nft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ const BuyNftComponent = ({
showLoader(false)
} catch (error) {
showLoader(false)
showSnackBar('Failed to buy nft', false)
showSnackBar(error instanceof Error ? error.message : 'Failed to buy nft', false)
}
}}
className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 ml-auto flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"
Expand Down
7 changes: 0 additions & 7 deletions packages/wallet/src/components/Card.tsx

This file was deleted.

84 changes: 0 additions & 84 deletions packages/wallet/src/components/TypeSelectionDropdown.tsx

This file was deleted.

Loading