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 .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
id: metadata
uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Enable auto-merge for Dependabot Patch / Minor PRs
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr review --approve "$PR_URL" && gh pr merge --auto --squash "$PR_URL"
Expand Down
1 change: 1 addition & 0 deletions builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"yaml": "^2.8.0"
},
"devDependencies": {
"@types/minimist": "^1.2.5",
"@types/node": "^22.13.15",
"tsup": "^8.4.0"
}
Expand Down
2 changes: 1 addition & 1 deletion library/factories/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"@types/react": "^19.0.12",
"@w3ux/types": "^2.1.13",
"@w3ux/types": "^2.2.3",
"builder": "workspace:*",
"gulp": "^5.0.0",
"gulp-sourcemaps": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion library/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"@types/react": "^19.0.12",
"@w3ux/types": "^2.1.13",
"@w3ux/types": "^2.2.3",
"builder": "workspace:*",
"gulp": "^5.0.0",
"gulp-sourcemaps": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion library/observables-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@w3ux/utils": "^2.0.10"
},
"devDependencies": {
"@w3ux/types": "^2.1.13",
"@w3ux/types": "^2.2.3",
"builder": "workspace:*",
"gulp": "^5.0.0",
"gulp-sourcemaps": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions library/observables-connect/src/accounts/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getAccountsFromExtensions = async (
try {
const results = await Promise.allSettled(
Array.from(extensions.values()).map(({ extension }) =>
extension.accounts.get()
extension!.accounts.get()
)
)

Expand All @@ -21,7 +21,7 @@ export const getAccountsFromExtensions = async (
for (let i = 0; i < results.length; i++) {
const result = results[i]
const source = extensionEntries[i][0]
const signer = extensionEntries[i][1].extension.signer
const signer = extensionEntries[i][1].extension!.signer

if (result.status === 'fulfilled' && signer) {
const { value } = result
Expand Down
3 changes: 2 additions & 1 deletion library/observables-connect/src/extensions/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { _extensionsStatus, _gettingExtensions } from '../subjects'
// Gets extensions from injectedWeb3
export const getExtensions = async () => {
_gettingExtensions.next(true)
let injectedWeb3Interval: ReturnType<typeof setInterval> | null = null
let injectedWeb3Interval: ReturnType<typeof setInterval> | undefined =
undefined

// Format installed extensions
const formatInstalled = () =>
Expand Down
5 changes: 3 additions & 2 deletions library/observables-connect/src/extensions/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const doEnable = async (
(id) =>
withTimeoutThrow(
1000,
window.injectedWeb3[id].enable(dappName)
) as Promise<ExtensionInterface | undefined>
window.injectedWeb3![id].enable(dappName)
) as Promise<ExtensionInterface>
)
)

Expand All @@ -60,6 +60,7 @@ const formatEnabledExtensions = (
})
} else if (result.status === 'rejected') {
extensionsState.set(id, {
extension: null,
connected: false,
error: result.reason,
})
Expand Down
2 changes: 1 addition & 1 deletion library/observables-connect/src/extensions/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const initExtensions = async (
newStatus[id] = 'connected'
})
Array.from(withError.entries()).forEach(([id, { error }]) => {
if (error.startsWith('Error')) {
if (error?.startsWith('Error')) {
// Extension not found - remove from state
if (error.substring(0, 17) === 'NotInstalledError') {
delete newStatus[id]
Expand Down
6 changes: 3 additions & 3 deletions library/observables-connect/src/extensions/reconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export const reconnectExtensions = async (dappName: string, ss58: number) => {

// If available, subscribe to accounts for each connected extension
for (const [id, { extension }] of Array.from(connected.entries())) {
if (typeof extension.accounts.subscribe === 'function') {
const unsub = extension.accounts.subscribe((accounts) => {
if (typeof extension!.accounts.subscribe === 'function') {
const unsub = extension!.accounts.subscribe((accounts) => {
processExtensionAccounts(
{
source: id,
ss58,
},
extension.signer,
extension!.signer,
accounts
)
})
Expand Down
2 changes: 1 addition & 1 deletion library/react-connect-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"@types/react": "^19.0.12",
"@w3ux/types": "^2.2.1",
"@w3ux/types": "^2.2.3",
"builder": "workspace:*",
"gulp": "^5.0.0",
"gulp-sourcemaps": "^3.0.0",
Expand Down
12 changes: 9 additions & 3 deletions library/react-odometer/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* @license Copyright 2024 w3ux authors & contributors
SPDX-License-Identifier: GPL-3.0-only */

import type { RefObject } from 'react'
import { createRef, useEffect, useRef, useState } from 'react'
import './index.css'
import type { Digit, DigitRef, Direction, Props, Status } from './types'
Expand Down Expand Up @@ -48,7 +49,9 @@ export const Odometer = ({
const [digitRefs, setDigitRefs] = useState<DigitRef[]>([])

// Store refs of each `all` digit.
const [allDigitRefs, setAllDigitRefs] = useState<Record<string, DigitRef>>({})
const [allDigitRefs, setAllDigitRefs] = useState<
Record<string, RefObject<HTMLSpanElement | null>>
>({})

// Keep track of active transitions.
const activeTransitionCounter = useRef<number>(0)
Expand All @@ -59,7 +62,10 @@ export const Odometer = ({

// Phase 0: populate `allDigitRefs`.
useEffect(() => {
const all: Record<string, DigitRef> = Object.fromEntries(
const all: Record<
string,
RefObject<HTMLSpanElement | null>
> = Object.fromEntries(
Object.values(allDigits).map((v) => [`d_${v}`, createRef()])
)

Expand Down Expand Up @@ -105,7 +111,7 @@ export const Odometer = ({
}
}, [status, digitRefs])

const odometerCurrent: Element = odometerRef?.current
const odometerCurrent: HTMLSpanElement | null = odometerRef.current
let lineHeight = odometerCurrent
? window.getComputedStyle(odometerCurrent).lineHeight
: 'inherit'
Expand Down
6 changes: 4 additions & 2 deletions library/react-polkicon/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ export const getCircleCoordinates = (): Coordinate[] => {
* In effect, this function acts like a weighted random selector. Each scheme has a chance of being
* picked based on its `freq` relative to the total frequency across all schemes.
*/
const findScheme = (d: number): Scheme =>
Object.values(SCHEMA).find((scheme) => (d -= scheme.freq) < 0)
const findScheme = (d: number): Scheme => {
const schemes = Object.values(SCHEMA)
return schemes.find((scheme) => (d -= scheme.freq) < 0) ?? schemes[0]
}

/**
* Converts an address string into a unique identifier by first encoding and decoding the address
Expand Down
2 changes: 1 addition & 1 deletion library/types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@w3ux/types-source",
"license": "GPL-3.0-only",
"version": "2.2.1",
"version": "2.2.3",
"type": "module",
"scripts": {
"clear": "rm -rf node_modules dist tsconfig.tsbuildinfo",
Expand Down
2 changes: 1 addition & 1 deletion library/types/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type ExtensionEnableStatus =
export type ExtensionEnableResults = Map<string, ExtensionEnableResult>

export interface ExtensionEnableResult {
extension?: ExtensionInterface
extension: ExtensionInterface | null
connected: boolean
error?: string
}
Expand Down
4 changes: 2 additions & 2 deletions library/utils/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const camelize = (str: string) => {
}

const w = toWords(str)?.map((a) => a.toLowerCase())
return simpleCamelCase(w)
return simpleCamelCase(w || [])
}

/**
Expand Down Expand Up @@ -161,7 +161,7 @@ export const rmCommas = (val: string): string => val.replace(/,/g, '')
* @name rmDecimals
* @summary Removes the decimal point and decimals from a string.
*/
export const rmDecimals = (str) => str.split('.')[0]
export const rmDecimals = (str: string) => str.split('.')[0]

/**
* @name shuffle
Expand Down
8 changes: 8 additions & 0 deletions library/utils/src/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ export const removeVarFromUrlHash = (key: string) => {
*/
export const sortWithNull =
(ascending: boolean) => (a: unknown, b: unknown) => {
// if both items are undefined, treat them as equal
if (typeof a === 'undefined' && typeof b === 'undefined') {
return 0
}
// if either item is undefined, sort it last
if (typeof a === 'undefined' || typeof b === 'undefined') {
return typeof a === 'undefined' ? 1 : -1
}
// equal items sort equally
if (a === b) {
return 0
Expand Down
30 changes: 19 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false
"strict": true
},
"exclude": ["**/node_modules", "**/dist", "vite.config.js"]
}