From e1affeff99f2db492546bb64847137c64884fccb Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Wed, 20 Sep 2023 13:52:59 +0200 Subject: [PATCH] reverts recent commit --- .../useink/src/core/types/api-contract.ts | 4 +- packages/useink/src/notifications/context.ts | 2 +- .../notifications/hooks/useNotifications.ts | 2 +- .../notifications/hooks/useTxNotifications.ts | 2 +- .../useink/src/notifications/provider.tsx | 2 +- .../useink/src/react/hooks/config/useChain.ts | 2 +- .../src/react/hooks/config/useConfig.ts | 2 +- .../react/hooks/config/useDefaultCaller.ts | 2 +- .../useink/src/react/hooks/contracts/types.ts | 2 +- .../react/hooks/contracts/useAbiMessage.ts | 2 +- .../src/react/hooks/contracts/useCall.ts | 2 +- .../hooks/contracts/useCallSubscription.ts | 2 +- .../src/react/hooks/contracts/useCodeHash.ts | 2 +- .../src/react/hooks/contracts/useContract.ts | 2 +- .../contracts/useDeployer/useDeployer.ts | 2 +- .../src/react/hooks/contracts/useDryRun.ts | 4 +- .../hooks/contracts/useEventSubscription.ts | 4 +- .../src/react/hooks/contracts/useEvents.ts | 2 +- .../react/hooks/contracts/useMessageSigner.ts | 2 +- .../src/react/hooks/contracts/useMetadata.ts | 2 +- .../src/react/hooks/contracts/useSalter.ts | 2 +- .../hooks/contracts/useSignatureVerifier.ts | 2 +- .../useink/src/react/hooks/contracts/useTx.ts | 2 +- .../src/react/hooks/contracts/useTxEvents.ts | 2 +- .../react/hooks/contracts/useTxPaymentInfo.ts | 2 +- .../react/hooks/helpers/useUnixMilliToDate.ts | 2 +- .../hooks/substrate/balance/useBalance.ts | 2 +- .../substrate/timestamp/useTimestampNow.ts | 2 +- .../substrate/timestamp/useTimestampQuery.ts | 2 +- .../src/react/hooks/substrate/useApi.ts | 2 +- .../react/hooks/substrate/useBlockHeader.ts | 2 +- .../src/react/hooks/substrate/useTransfer.ts | 2 +- .../src/react/hooks/wallets/useAllWallets.ts | 2 +- .../hooks/wallets/useInstalledWallets.ts | 2 +- .../hooks/wallets/useUninstalledWallets.ts | 2 +- .../src/react/hooks/wallets/useWallet.ts | 2 +- .../src/react/providers/UseInkProvider.tsx | 2 +- .../useink/src/react/providers/api/context.ts | 2 +- .../src/react/providers/api/provider.tsx | 2 +- .../react/providers/blockHeader/context.ts | 2 +- .../react/providers/blockHeader/provider.tsx | 2 +- .../src/react/providers/config/context.ts | 2 +- .../src/react/providers/config/provider.tsx | 2 +- .../src/react/providers/events/context.ts | 2 +- .../src/react/providers/events/provider.tsx | 2 +- .../src/react/providers/wallet/context.ts | 2 +- .../src/react/providers/wallet/model.ts | 6 +- .../src/react/providers/wallet/provider.tsx | 4 +- packages/useink/src/utils/helpers/NOOP.ts | 2 +- .../utils/helpers/parseUnits/parseUnits.ts | 2 +- .../ConnectWallet/ConnectWallet.tsx | 14 +- .../components/FileDropper/FileDropper.tsx | 6 +- .../Notifications/Notifications.tsx | 6 +- .../src/components/Snackbar/Snackbar.tsx | 18 +- .../components/ToggleSwitch/ToggleSwitch.tsx | 2 +- .../pg-deploy/AbiParamInput/AbiParamInput.tsx | 28 +- .../src/components/pg-deploy/DeployPage.tsx | 144 ++-- .../src/components/pg-home/HomePage.tsx | 647 ++++++++++++++-- .../src/components/pg-home/HomePageSmol.tsx | 716 ++++++++++++++++++ playground/src/pages/_app.tsx | 2 +- playground/src/pages/_document.tsx | 4 +- playground/src/pages/deploy.tsx | 10 +- playground/src/pages/index.tsx | 8 +- 63 files changed, 1489 insertions(+), 228 deletions(-) create mode 100644 playground/src/components/pg-home/HomePageSmol.tsx diff --git a/packages/useink/src/core/types/api-contract.ts b/packages/useink/src/core/types/api-contract.ts index f9dcb6d..38ed37d 100644 --- a/packages/useink/src/core/types/api-contract.ts +++ b/packages/useink/src/core/types/api-contract.ts @@ -1,5 +1,5 @@ -import { SubmittableResult } from '@polkadot/api'; import { ISubmittableResult } from './substrate.ts'; +import { SubmittableResult } from '@polkadot/api'; export { BlueprintPromise, @@ -28,7 +28,7 @@ export type { } from '@polkadot/api-contract/types'; export { Abi, ContractPromise } from '@polkadot/api-contract'; -// biome-ignore lint/correctness/noUnusedVariables: The Release flow breaks when exporting from '@polkadot/api-contract/base/contract'; +// rome-ignore lint/correctness/noUnusedVariables: The Release flow breaks when exporting from '@polkadot/api-contract/base/contract'; export declare class ContractSubmittableResult extends SubmittableResult { readonly contractEvents?: DecodedEvent[] | undefined; constructor(result: ISubmittableResult, contractEvents?: DecodedEvent[]); diff --git a/packages/useink/src/notifications/context.ts b/packages/useink/src/notifications/context.ts index 06c337c..d7b35bd 100644 --- a/packages/useink/src/notifications/context.ts +++ b/packages/useink/src/notifications/context.ts @@ -1,10 +1,10 @@ -import { createContext } from 'react'; import { AddNotificationPayload, Config, DEFAULT_NOTIFICATIONS, Notifications, } from './model.ts'; +import { createContext } from 'react'; export const NotificationsContext = createContext<{ config?: Config; diff --git a/packages/useink/src/notifications/hooks/useNotifications.ts b/packages/useink/src/notifications/hooks/useNotifications.ts index 65b0a93..d3afc58 100644 --- a/packages/useink/src/notifications/hooks/useNotifications.ts +++ b/packages/useink/src/notifications/hooks/useNotifications.ts @@ -1,4 +1,3 @@ -import { useContext, useMemo } from 'react'; import { HALF_A_SECOND } from '../../react/constants.ts'; import { useInterval } from '../../react/hooks/internal/useInterval.ts'; import { getExpiredItem } from '../../utils/index'; @@ -8,6 +7,7 @@ import { Notification, Notifications, } from '../model.ts'; +import { useContext, useMemo } from 'react'; export interface UseNotifications { notifications: Notifications; diff --git a/packages/useink/src/notifications/hooks/useTxNotifications.ts b/packages/useink/src/notifications/hooks/useTxNotifications.ts index 8131141..603dce6 100644 --- a/packages/useink/src/notifications/hooks/useTxNotifications.ts +++ b/packages/useink/src/notifications/hooks/useTxNotifications.ts @@ -1,7 +1,7 @@ -import { useEffect } from 'react'; import { ChainId } from '../../chains/types.ts'; import { Tx } from '../../index'; import { useNotifications } from './useNotifications.ts'; +import { useEffect } from 'react'; type TxInfo = Pick, 'status'> & Pick, 'result'>; diff --git a/packages/useink/src/notifications/provider.tsx b/packages/useink/src/notifications/provider.tsx index 863444b..8f1f05e 100644 --- a/packages/useink/src/notifications/provider.tsx +++ b/packages/useink/src/notifications/provider.tsx @@ -1,4 +1,3 @@ -import React, { useCallback, useReducer } from 'react'; import { useIsMounted } from '../react/hooks/internal/useIsMounted.ts'; import { pseudoRandomId } from '../utils/index'; import { NotificationsContext } from './context.ts'; @@ -8,6 +7,7 @@ import { DEFAULT_NOTIFICATIONS, } from './model.ts'; import { notificationReducer } from './reducer.ts'; +import React, { useCallback, useReducer } from 'react'; export const NotificationsProvider: React.FC< React.PropsWithChildren<{ diff --git a/packages/useink/src/react/hooks/config/useChain.ts b/packages/useink/src/react/hooks/config/useChain.ts index 96bcfbe..918be99 100644 --- a/packages/useink/src/react/hooks/config/useChain.ts +++ b/packages/useink/src/react/hooks/config/useChain.ts @@ -1,6 +1,6 @@ -import { useMemo } from 'react'; import { Chain, ChainId } from '../../../chains/index'; import { useConfig } from './useConfig.ts'; +import { useMemo } from 'react'; export const useChain = (chainId?: ChainId): Chain | undefined => { const { chains } = useConfig(); diff --git a/packages/useink/src/react/hooks/config/useConfig.ts b/packages/useink/src/react/hooks/config/useConfig.ts index 0db427b..33ce2c6 100644 --- a/packages/useink/src/react/hooks/config/useConfig.ts +++ b/packages/useink/src/react/hooks/config/useConfig.ts @@ -1,5 +1,5 @@ -import { useContext } from 'react'; import { ConfigContext } from '../../providers/config/context.ts'; import { Config } from '../../providers/config/model.ts'; +import { useContext } from 'react'; export const useConfig = (): Config => useContext(ConfigContext); diff --git a/packages/useink/src/react/hooks/config/useDefaultCaller.ts b/packages/useink/src/react/hooks/config/useDefaultCaller.ts index 6ce5657..68320c7 100644 --- a/packages/useink/src/react/hooks/config/useDefaultCaller.ts +++ b/packages/useink/src/react/hooks/config/useDefaultCaller.ts @@ -1,7 +1,7 @@ -import { useMemo } from 'react'; import { ChainId } from '../../../chains/index'; import { useChain } from './useChain.ts'; import { useConfig } from './useConfig.ts'; +import { useMemo } from 'react'; export const useDefaultCaller = (chainId?: ChainId): string | undefined => { const { caller } = useConfig(); diff --git a/packages/useink/src/react/hooks/contracts/types.ts b/packages/useink/src/react/hooks/contracts/types.ts index 74d5efb..a288ae1 100644 --- a/packages/useink/src/react/hooks/contracts/types.ts +++ b/packages/useink/src/react/hooks/contracts/types.ts @@ -1,6 +1,6 @@ -import { BN } from '@polkadot/util'; import { ChainId } from '../../../chains/types.ts'; import { Abi, ContractOptions, ContractPromise } from '../../../core/index'; +import { BN } from '@polkadot/util'; export type CallOptions = Omit & { defaultCaller?: boolean; diff --git a/packages/useink/src/react/hooks/contracts/useAbiMessage.ts b/packages/useink/src/react/hooks/contracts/useAbiMessage.ts index d99f16b..eb6c088 100644 --- a/packages/useink/src/react/hooks/contracts/useAbiMessage.ts +++ b/packages/useink/src/react/hooks/contracts/useAbiMessage.ts @@ -1,9 +1,9 @@ -import { useMemo } from 'react'; import { AbiMessage, ContractPromise, toContractAbiMessage, } from '../../../core/index'; +import { useMemo } from 'react'; export function useAbiMessage( contract: ContractPromise | undefined, diff --git a/packages/useink/src/react/hooks/contracts/useCall.ts b/packages/useink/src/react/hooks/contracts/useCall.ts index 4008350..b5ef110 100644 --- a/packages/useink/src/react/hooks/contracts/useCall.ts +++ b/packages/useink/src/react/hooks/contracts/useCall.ts @@ -1,4 +1,3 @@ -import { useCallback, useState } from 'react'; import { DecodedContractResult, LazyCallOptions, @@ -7,6 +6,7 @@ import { import { ChainContract, useDefaultCaller } from '../index'; import { useWallet } from '../wallets/useWallet.ts'; import { useAbiMessage } from './useAbiMessage.ts'; +import { useCallback, useState } from 'react'; export type CallSend = ( args?: unknown[], diff --git a/packages/useink/src/react/hooks/contracts/useCallSubscription.ts b/packages/useink/src/react/hooks/contracts/useCallSubscription.ts index 946f67f..338c14f 100644 --- a/packages/useink/src/react/hooks/contracts/useCallSubscription.ts +++ b/packages/useink/src/react/hooks/contracts/useCallSubscription.ts @@ -1,8 +1,8 @@ -import { useEffect } from 'react'; import { LazyCallOptions } from '../../../core/index.ts'; import { useBlockHeader } from '../substrate/useBlockHeader.ts'; import { ChainContract } from './types.ts'; import { Call, useCall } from './useCall.ts'; +import { useEffect } from 'react'; export function useCallSubscription( chainContract: ChainContract | undefined, diff --git a/packages/useink/src/react/hooks/contracts/useCodeHash.ts b/packages/useink/src/react/hooks/contracts/useCodeHash.ts index ea24644..79fbab6 100644 --- a/packages/useink/src/react/hooks/contracts/useCodeHash.ts +++ b/packages/useink/src/react/hooks/contracts/useCodeHash.ts @@ -1,5 +1,5 @@ -import { useCallback, useEffect, useState } from 'react'; import { isValidHash } from '../../../utils'; +import { useCallback, useEffect, useState } from 'react'; export enum CodeHashError { InvalidHash = 'Invalid code hash value.', diff --git a/packages/useink/src/react/hooks/contracts/useContract.ts b/packages/useink/src/react/hooks/contracts/useContract.ts index a0d91ad..0f6f281 100644 --- a/packages/useink/src/react/hooks/contracts/useContract.ts +++ b/packages/useink/src/react/hooks/contracts/useContract.ts @@ -1,9 +1,9 @@ -import { useEffect, useMemo, useState } from 'react'; import { ChainId } from '../../../chains/index'; import { Abi, ContractPromise } from '../../../core/index'; import { useChain } from '../config/useChain.ts'; import { useApi } from '../substrate/useApi.ts'; import { ChainContract } from './types.ts'; +import { useEffect, useMemo, useState } from 'react'; export function useContract( address: string, diff --git a/packages/useink/src/react/hooks/contracts/useDeployer/useDeployer.ts b/packages/useink/src/react/hooks/contracts/useDeployer/useDeployer.ts index b489442..8dd69e8 100644 --- a/packages/useink/src/react/hooks/contracts/useDeployer/useDeployer.ts +++ b/packages/useink/src/react/hooks/contracts/useDeployer/useDeployer.ts @@ -1,4 +1,3 @@ -import { useCallback, useEffect, useMemo, useState } from 'react'; import { ChainId } from '../../../../chains/index.ts'; import { BlueprintPromise, @@ -27,6 +26,7 @@ import { useApi } from '../../substrate/useApi.ts'; import { useWallet } from '../../wallets/useWallet.ts'; import { useTxEvents } from '../useTxEvents.ts'; import { Deploy, DeploySignAndSend, DeployTx, DeployerError } from './types.ts'; +import { useCallback, useEffect, useMemo, useState } from 'react'; export function useDeployer(chainId?: ChainId): Deploy { const { account } = useWallet(); diff --git a/packages/useink/src/react/hooks/contracts/useDryRun.ts b/packages/useink/src/react/hooks/contracts/useDryRun.ts index 1ec42cf..ee4634b 100644 --- a/packages/useink/src/react/hooks/contracts/useDryRun.ts +++ b/packages/useink/src/react/hooks/contracts/useDryRun.ts @@ -1,4 +1,3 @@ -import { useMemo, useState } from 'react'; import { DecodedTxResult, LazyCallOptions, @@ -9,6 +8,7 @@ import { useDefaultCaller } from '../config/index'; import { useWallet } from '../wallets/useWallet.ts'; import { ChainContract } from './types.ts'; import { useAbiMessage } from './useAbiMessage.ts'; +import { useMemo, useState } from 'react'; export type DryRunResult = DecodedTxResult; @@ -21,7 +21,7 @@ export interface DryRun { send: Send; isSubmitting: boolean; result?: DryRunResult; - resolved: boolean; + resolved: Boolean; resetState: () => void; } diff --git a/packages/useink/src/react/hooks/contracts/useEventSubscription.ts b/packages/useink/src/react/hooks/contracts/useEventSubscription.ts index 8ab113f..6241af3 100644 --- a/packages/useink/src/react/hooks/contracts/useEventSubscription.ts +++ b/packages/useink/src/react/hooks/contracts/useEventSubscription.ts @@ -1,5 +1,3 @@ -import { IEventLike } from '@polkadot/types/types/events'; -import { useContext, useEffect } from 'react'; import { Bytes } from '../../../core/index'; import { getExpiredItem } from '../../../utils/index'; import { FIVE_SECONDS, HALF_A_SECOND } from '../../constants.ts'; @@ -8,6 +6,8 @@ import { useConfig } from '../config/useConfig.ts'; import { useInterval } from '../internal/useInterval.ts'; import { useBlockHeader } from '../substrate/useBlockHeader.ts'; import { ChainContract } from './types.ts'; +import { IEventLike } from '@polkadot/types/types/events'; +import { useContext, useEffect } from 'react'; export const useEventSubscription = ( chainContract: ChainContract | undefined, diff --git a/packages/useink/src/react/hooks/contracts/useEvents.ts b/packages/useink/src/react/hooks/contracts/useEvents.ts index 3dffb9f..6dc09a8 100644 --- a/packages/useink/src/react/hooks/contracts/useEvents.ts +++ b/packages/useink/src/react/hooks/contracts/useEvents.ts @@ -1,7 +1,7 @@ -import { useContext, useMemo } from 'react'; import { AccountId } from '../../../core/index'; import { Event, EventsContext } from '../../providers/events/index'; import { RemoveEventPayload } from '../../providers/events/model.ts'; +import { useContext, useMemo } from 'react'; export interface Events { events: Event[]; diff --git a/packages/useink/src/react/hooks/contracts/useMessageSigner.ts b/packages/useink/src/react/hooks/contracts/useMessageSigner.ts index 438543c..7118b29 100644 --- a/packages/useink/src/react/hooks/contracts/useMessageSigner.ts +++ b/packages/useink/src/react/hooks/contracts/useMessageSigner.ts @@ -1,6 +1,6 @@ -import { useCallback, useState } from 'react'; import { SignatureResult } from '../../../core/index.ts'; import { useWallet } from '../wallets/useWallet.ts'; +import { useCallback, useState } from 'react'; export type Sign = (data?: string) => void; diff --git a/packages/useink/src/react/hooks/contracts/useMetadata.ts b/packages/useink/src/react/hooks/contracts/useMetadata.ts index f08c133..05d953f 100644 --- a/packages/useink/src/react/hooks/contracts/useMetadata.ts +++ b/packages/useink/src/react/hooks/contracts/useMetadata.ts @@ -1,4 +1,3 @@ -import { useEffect, useState } from 'react'; import { ChainId } from '../../../chains'; import { DEFAULT, @@ -8,6 +7,7 @@ import { } from '../../../core'; import { MetadataError, toBasicMetadata } from '../../../utils'; import { useApi } from '../substrate/useApi'; +import { useEffect, useState } from 'react'; export interface BasicMetadataFile { data: Uint8Array; diff --git a/packages/useink/src/react/hooks/contracts/useSalter.ts b/packages/useink/src/react/hooks/contracts/useSalter.ts index dc482ec..05455d9 100644 --- a/packages/useink/src/react/hooks/contracts/useSalter.ts +++ b/packages/useink/src/react/hooks/contracts/useSalter.ts @@ -1,5 +1,5 @@ -import { useCallback, useState } from 'react'; import { isValidHash, pseudoRandomHex } from '../../../utils'; +import { useCallback, useState } from 'react'; export enum SalterError { InvalidHash = 'Invalid salt hash value.', diff --git a/packages/useink/src/react/hooks/contracts/useSignatureVerifier.ts b/packages/useink/src/react/hooks/contracts/useSignatureVerifier.ts index e230e97..411e67a 100644 --- a/packages/useink/src/react/hooks/contracts/useSignatureVerifier.ts +++ b/packages/useink/src/react/hooks/contracts/useSignatureVerifier.ts @@ -1,5 +1,5 @@ -import { useCallback, useState } from 'react'; import { signatureVerify } from '../../../utils'; +import { useCallback, useState } from 'react'; type VerificationParams = Parameters; diff --git a/packages/useink/src/react/hooks/contracts/useTx.ts b/packages/useink/src/react/hooks/contracts/useTx.ts index 5a8e1d0..235b3ea 100644 --- a/packages/useink/src/react/hooks/contracts/useTx.ts +++ b/packages/useink/src/react/hooks/contracts/useTx.ts @@ -1,4 +1,3 @@ -import { useMemo, useState } from 'react'; import { ApiBase, ContractSubmittableResult, @@ -11,6 +10,7 @@ import { useWallet } from '../wallets/useWallet.ts'; import { ChainContract } from './types.ts'; import { useDryRun } from './useDryRun.ts'; import { useTxEvents } from './useTxEvents.ts'; +import { useMemo, useState } from 'react'; export type ContractSubmittableResultCallback = ( result?: ContractSubmittableResult, diff --git a/packages/useink/src/react/hooks/contracts/useTxEvents.ts b/packages/useink/src/react/hooks/contracts/useTxEvents.ts index 30fa10e..1941bef 100644 --- a/packages/useink/src/react/hooks/contracts/useTxEvents.ts +++ b/packages/useink/src/react/hooks/contracts/useTxEvents.ts @@ -1,7 +1,7 @@ -import { useCallback, useEffect, useState } from 'react'; import { EventRecord } from '../../../core'; import { isInBlock } from '../../../utils'; import { Tx } from './useTx'; +import { useCallback, useEffect, useState } from 'react'; type Eventable = Pick, 'status'> & Pick, 'result'>; diff --git a/packages/useink/src/react/hooks/contracts/useTxPaymentInfo.ts b/packages/useink/src/react/hooks/contracts/useTxPaymentInfo.ts index a9e6350..a94eddb 100644 --- a/packages/useink/src/react/hooks/contracts/useTxPaymentInfo.ts +++ b/packages/useink/src/react/hooks/contracts/useTxPaymentInfo.ts @@ -1,4 +1,3 @@ -import { useCallback, useState } from 'react'; import { ChainContract, useDefaultCaller } from '..'; import { LazyCallOptions, @@ -7,6 +6,7 @@ import { txPaymentInfo, } from '../../../core'; import { useWallet } from '../wallets/useWallet.ts'; +import { useCallback, useState } from 'react'; type Send = ( params?: unknown[], diff --git a/packages/useink/src/react/hooks/helpers/useUnixMilliToDate.ts b/packages/useink/src/react/hooks/helpers/useUnixMilliToDate.ts index 278d618..f78fec7 100644 --- a/packages/useink/src/react/hooks/helpers/useUnixMilliToDate.ts +++ b/packages/useink/src/react/hooks/helpers/useUnixMilliToDate.ts @@ -1,5 +1,5 @@ -import { useMemo } from 'react'; import { unixMilliToDate } from '../../../utils/helpers/unixMilliToDate'; +import { useMemo } from 'react'; export const useUnixMilliToDate = ( unixInMilliSeconds: number | undefined, diff --git a/packages/useink/src/react/hooks/substrate/balance/useBalance.ts b/packages/useink/src/react/hooks/substrate/balance/useBalance.ts index b715841..c1c3427 100644 --- a/packages/useink/src/react/hooks/substrate/balance/useBalance.ts +++ b/packages/useink/src/react/hooks/substrate/balance/useBalance.ts @@ -1,10 +1,10 @@ -import { useEffect, useState } from 'react'; import { ChainId } from '../../../../chains/index'; import { DeriveBalancesAccount, WithAddress } from '../../../../core/index'; import { getBalance } from '../../../../core/index'; import { useChain } from '../../index'; import { useApi } from '../useApi.ts'; import { useBlockHeader } from '../useBlockHeader.ts'; +import { useEffect, useState } from 'react'; export const useBalance = ( account: WithAddress | undefined, diff --git a/packages/useink/src/react/hooks/substrate/timestamp/useTimestampNow.ts b/packages/useink/src/react/hooks/substrate/timestamp/useTimestampNow.ts index 80f51b4..9b8a9f7 100644 --- a/packages/useink/src/react/hooks/substrate/timestamp/useTimestampNow.ts +++ b/packages/useink/src/react/hooks/substrate/timestamp/useTimestampNow.ts @@ -1,8 +1,8 @@ -import { useEffect, useState } from 'react'; import { ChainId } from '../../../../chains'; import { getTimestampUnix } from '../../../../core'; import { useApi } from '../useApi'; import { useBlockHeader } from '../useBlockHeader'; +import { useEffect, useState } from 'react'; // Get the current timestamp in milliseconds export const useTimestampNow = (chainId?: ChainId): number | undefined => { diff --git a/packages/useink/src/react/hooks/substrate/timestamp/useTimestampQuery.ts b/packages/useink/src/react/hooks/substrate/timestamp/useTimestampQuery.ts index 28c5efd..d0121ea 100644 --- a/packages/useink/src/react/hooks/substrate/timestamp/useTimestampQuery.ts +++ b/packages/useink/src/react/hooks/substrate/timestamp/useTimestampQuery.ts @@ -1,7 +1,7 @@ -import { useEffect, useState } from 'react'; import { ChainId } from '../../../../chains'; import { QueryableModuleCalls, getTimestampQuery } from '../../../../core'; import { useApi } from '../useApi'; +import { useEffect, useState } from 'react'; // Get a queryable function that can then be used to call a chain: `await timestampQuery.now()` export const useTimestampQuery = ( diff --git a/packages/useink/src/react/hooks/substrate/useApi.ts b/packages/useink/src/react/hooks/substrate/useApi.ts index a704104..d9b4aa4 100644 --- a/packages/useink/src/react/hooks/substrate/useApi.ts +++ b/packages/useink/src/react/hooks/substrate/useApi.ts @@ -1,7 +1,7 @@ -import { useContext } from 'react'; import { ChainId } from '../../../chains/index'; import { IApiProvider, useChain } from '../../index'; import { API, APIContext } from '../../providers/api/index'; +import { useContext } from 'react'; export const useApis = (): API => useContext(APIContext); diff --git a/packages/useink/src/react/hooks/substrate/useBlockHeader.ts b/packages/useink/src/react/hooks/substrate/useBlockHeader.ts index c3eddc9..ac3cbb8 100644 --- a/packages/useink/src/react/hooks/substrate/useBlockHeader.ts +++ b/packages/useink/src/react/hooks/substrate/useBlockHeader.ts @@ -1,4 +1,3 @@ -import { useContext } from 'react'; import { ChainId } from '../../../chains/index'; import { BlockHeaderContext, @@ -6,6 +5,7 @@ import { } from '../../providers/blockHeader/index'; import { useChain } from '../config/useChain.ts'; import { BlockHeader } from './index'; +import { useContext } from 'react'; export type { BlockHeader } from '../../providers/blockHeader/index'; diff --git a/packages/useink/src/react/hooks/substrate/useTransfer.ts b/packages/useink/src/react/hooks/substrate/useTransfer.ts index fa3d4c0..8c957cc 100644 --- a/packages/useink/src/react/hooks/substrate/useTransfer.ts +++ b/packages/useink/src/react/hooks/substrate/useTransfer.ts @@ -1,8 +1,8 @@ -import { useCallback, useMemo, useState } from 'react'; import { useChain, useWallet } from '../'; import { ChainId } from '../../../chains'; import { Hash, SignerOptions, transfer } from '../../../core'; import { useApi } from './useApi.ts'; +import { useCallback, useMemo, useState } from 'react'; export type SignAndSendTransfer = ( to: string, diff --git a/packages/useink/src/react/hooks/wallets/useAllWallets.ts b/packages/useink/src/react/hooks/wallets/useAllWallets.ts index a0736ea..b22d2e3 100644 --- a/packages/useink/src/react/hooks/wallets/useAllWallets.ts +++ b/packages/useink/src/react/hooks/wallets/useAllWallets.ts @@ -1,6 +1,6 @@ -import { useMemo } from 'react'; import { Wallet } from '../../providers/wallet/index'; import { useWallet } from '../index'; +import { useMemo } from 'react'; export const useAllWallets = (): Wallet[] => { const { getWallets } = useWallet(); diff --git a/packages/useink/src/react/hooks/wallets/useInstalledWallets.ts b/packages/useink/src/react/hooks/wallets/useInstalledWallets.ts index 957dacf..45d1963 100644 --- a/packages/useink/src/react/hooks/wallets/useInstalledWallets.ts +++ b/packages/useink/src/react/hooks/wallets/useInstalledWallets.ts @@ -1,6 +1,6 @@ -import { useMemo } from 'react'; import { Wallet } from '../../providers/wallet/index'; import { useWallet } from '../index'; +import { useMemo } from 'react'; export const useInstalledWallets = (): Wallet[] => { const { getWallets } = useWallet(); diff --git a/packages/useink/src/react/hooks/wallets/useUninstalledWallets.ts b/packages/useink/src/react/hooks/wallets/useUninstalledWallets.ts index 5f17dcc..e539aa8 100644 --- a/packages/useink/src/react/hooks/wallets/useUninstalledWallets.ts +++ b/packages/useink/src/react/hooks/wallets/useUninstalledWallets.ts @@ -1,6 +1,6 @@ -import { useMemo } from 'react'; import { Wallet } from '../../providers/wallet/index'; import { useWallet } from './useWallet.ts'; +import { useMemo } from 'react'; export const useUninstalledWallets = (): Wallet[] => { const { getWallets } = useWallet(); diff --git a/packages/useink/src/react/hooks/wallets/useWallet.ts b/packages/useink/src/react/hooks/wallets/useWallet.ts index cec3c26..6088f63 100644 --- a/packages/useink/src/react/hooks/wallets/useWallet.ts +++ b/packages/useink/src/react/hooks/wallets/useWallet.ts @@ -1,5 +1,5 @@ -import { useContext } from 'react'; import { WalletContext, WalletState } from '../../providers/wallet/index'; +import { useContext } from 'react'; export type { WalletState } from '../../providers/wallet/index'; diff --git a/packages/useink/src/react/providers/UseInkProvider.tsx b/packages/useink/src/react/providers/UseInkProvider.tsx index f7dceaa..ff04ed8 100644 --- a/packages/useink/src/react/providers/UseInkProvider.tsx +++ b/packages/useink/src/react/providers/UseInkProvider.tsx @@ -1,9 +1,9 @@ -import React from 'react'; import { APIProvider } from './api/provider.tsx'; import { BlockHeaderProvider } from './blockHeader/index'; import { ConfigProps, ConfigProvider } from './config/index'; import { EventsProvider } from './events/index'; import { WalletProvider } from './wallet/index'; +import React from 'react'; export type InkConfig = { config: ConfigProps; diff --git a/packages/useink/src/react/providers/api/context.ts b/packages/useink/src/react/providers/api/context.ts index 80d3bb2..9bce7b1 100644 --- a/packages/useink/src/react/providers/api/context.ts +++ b/packages/useink/src/react/providers/api/context.ts @@ -1,5 +1,5 @@ -import { createContext } from 'react'; import { API } from './model.ts'; +import { createContext } from 'react'; export const APIContext = createContext({ apis: {}, diff --git a/packages/useink/src/react/providers/api/provider.tsx b/packages/useink/src/react/providers/api/provider.tsx index 2715895..1a8910a 100644 --- a/packages/useink/src/react/providers/api/provider.tsx +++ b/packages/useink/src/react/providers/api/provider.tsx @@ -1,9 +1,9 @@ -import React, { useEffect, useReducer } from 'react'; import { ApiPromise, WsProvider } from '../../../core/index'; import { useChains } from '../../hooks/index'; import { useConfig } from '../../index'; import { APIContext } from './context.ts'; import { apiProvidersReducer } from './reducer.ts'; +import React, { useEffect, useReducer } from 'react'; export const APIProvider: React.FC = ({ children, diff --git a/packages/useink/src/react/providers/blockHeader/context.ts b/packages/useink/src/react/providers/blockHeader/context.ts index 7e8bb0f..048b5df 100644 --- a/packages/useink/src/react/providers/blockHeader/context.ts +++ b/packages/useink/src/react/providers/blockHeader/context.ts @@ -1,5 +1,5 @@ -import { createContext } from 'react'; import { BLOCK_HEADER_DEFAULTS, ChainBlockHeaders } from './model.ts'; +import { createContext } from 'react'; export const BlockHeaderContext = createContext({ ...BLOCK_HEADER_DEFAULTS, diff --git a/packages/useink/src/react/providers/blockHeader/provider.tsx b/packages/useink/src/react/providers/blockHeader/provider.tsx index 9103af9..4635762 100644 --- a/packages/useink/src/react/providers/blockHeader/provider.tsx +++ b/packages/useink/src/react/providers/blockHeader/provider.tsx @@ -1,9 +1,9 @@ -import React, { useEffect, useMemo, useReducer } from 'react'; import { ChainId } from '../../../chains/index'; import { useApis } from '../../index'; import { BlockHeaderContext } from './context.ts'; import { ChainBlockHeaders } from './model.ts'; import { chainBlockHeaderReducer } from './reducer.ts'; +import React, { useEffect, useMemo, useReducer } from 'react'; const toBlockNumber = (valWithComma: string | undefined): number => parseInt(`${valWithComma?.split(',').join('')}`); diff --git a/packages/useink/src/react/providers/config/context.ts b/packages/useink/src/react/providers/config/context.ts index 389ddbb..2e07605 100644 --- a/packages/useink/src/react/providers/config/context.ts +++ b/packages/useink/src/react/providers/config/context.ts @@ -1,5 +1,5 @@ -import React from 'react'; import { ChainConfig, ConfigProps, DEFAULT_CONFIG } from './model.ts'; +import React from 'react'; export const ConfigContext = React.createContext( DEFAULT_CONFIG, diff --git a/packages/useink/src/react/providers/config/provider.tsx b/packages/useink/src/react/providers/config/provider.tsx index 3fc041c..e6f7765 100644 --- a/packages/useink/src/react/providers/config/provider.tsx +++ b/packages/useink/src/react/providers/config/provider.tsx @@ -1,7 +1,7 @@ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Chain, ChainId } from '../../../chains/index'; import { ConfigContext } from './context.ts'; import { ChainRPCs, ConfigProps, DEFAULT_CONFIG } from './model.ts'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; export interface Props { config: ConfigProps; diff --git a/packages/useink/src/react/providers/events/context.ts b/packages/useink/src/react/providers/events/context.ts index 73aec39..913bc39 100644 --- a/packages/useink/src/react/providers/events/context.ts +++ b/packages/useink/src/react/providers/events/context.ts @@ -1,10 +1,10 @@ -import { createContext } from 'react'; import { AddEventPayload, DEFAULT_EVENTS, Events, RemoveEventPayload, } from './model.ts'; +import { createContext } from 'react'; export const EventsContext = createContext<{ events: Events; diff --git a/packages/useink/src/react/providers/events/provider.tsx b/packages/useink/src/react/providers/events/provider.tsx index 12a04f2..fe0d519 100644 --- a/packages/useink/src/react/providers/events/provider.tsx +++ b/packages/useink/src/react/providers/events/provider.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { pseudoRandomId } from '../../../utils/index'; import { EventsContext } from './context.ts'; import { @@ -7,6 +6,7 @@ import { RemoveEventPayload, } from './model.ts'; import { eventsReducer } from './reducer.ts'; +import React from 'react'; import { useIsMounted } from '../../hooks/internal/useIsMounted.ts'; diff --git a/packages/useink/src/react/providers/wallet/context.ts b/packages/useink/src/react/providers/wallet/context.ts index 23e827e..dc1ba6c 100644 --- a/packages/useink/src/react/providers/wallet/context.ts +++ b/packages/useink/src/react/providers/wallet/context.ts @@ -1,5 +1,5 @@ -import { createContext } from 'react'; import { WALLET_DEFAULTS, WalletState } from './model.ts'; +import { createContext } from 'react'; export const WalletContext = createContext({ ...WALLET_DEFAULTS, diff --git a/packages/useink/src/react/providers/wallet/model.ts b/packages/useink/src/react/providers/wallet/model.ts index 2c3f2aa..d4f379c 100644 --- a/packages/useink/src/react/providers/wallet/model.ts +++ b/packages/useink/src/react/providers/wallet/model.ts @@ -27,11 +27,11 @@ export interface WalletState { export type Wallet = Exclude, undefined>; export const WALLET_DEFAULTS: WalletState = { - connect: () => {}, - disconnect: () => {}, + connect: () => undefined, + disconnect: () => undefined, account: undefined, accounts: undefined, - setAccount: () => {}, + setAccount: () => undefined, isConnected: false, getWallets, getWalletBySource, diff --git a/packages/useink/src/react/providers/wallet/provider.tsx b/packages/useink/src/react/providers/wallet/provider.tsx index cb28d33..e021559 100644 --- a/packages/useink/src/react/providers/wallet/provider.tsx +++ b/packages/useink/src/react/providers/wallet/provider.tsx @@ -1,4 +1,3 @@ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Unsub, WalletAccount, @@ -8,6 +7,7 @@ import { import { useConfig } from '../../hooks'; import { WalletContext } from './context.ts'; import { AutoConnect, WalletError, WalletName } from './model.ts'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; function getAutoConnectWalletInfo(key: string): AutoConnect | null { const item = localStorage.getItem(key); @@ -25,7 +25,6 @@ function disableAutoConnect(key: string) { export const WalletProvider: React.FC = ({ children, }) => { - console.log('walletprovider'); const C = useConfig(); const [account, setWalletAccount] = useState(); const [accounts, setAccounts] = useState(); @@ -156,7 +155,6 @@ export const WalletProvider: React.FC = ({ }, []); useEffect(() => { - console.log('activeWallet'); if (!activeWallet) { const wallet = getAutoConnectWalletInfo(dappName)?.wallet; if (wallet) setActiveWallet(wallet); diff --git a/packages/useink/src/utils/helpers/NOOP.ts b/packages/useink/src/utils/helpers/NOOP.ts index c07de78..54caacb 100644 --- a/packages/useink/src/utils/helpers/NOOP.ts +++ b/packages/useink/src/utils/helpers/NOOP.ts @@ -1 +1 @@ -export const NOOP: () => void = () => {}; +export const NOOP: () => void = () => undefined; diff --git a/packages/useink/src/utils/helpers/parseUnits/parseUnits.ts b/packages/useink/src/utils/helpers/parseUnits/parseUnits.ts index a5e3ffe..502acf4 100644 --- a/packages/useink/src/utils/helpers/parseUnits/parseUnits.ts +++ b/packages/useink/src/utils/helpers/parseUnits/parseUnits.ts @@ -64,7 +64,7 @@ export const planckToDecimalFormatted = ( export const decimalToPlanck = ( amount: number, options: DecimalOptions | undefined, -): bigint | undefined => { +): BigInt | undefined => { const decimals = options?.decimals || options?.api?.registry.chainDecimals[0]; if (!decimals) return; diff --git a/playground/src/components/ConnectWallet/ConnectWallet.tsx b/playground/src/components/ConnectWallet/ConnectWallet.tsx index d89511b..e3173d3 100644 --- a/playground/src/components/ConnectWallet/ConnectWallet.tsx +++ b/playground/src/components/ConnectWallet/ConnectWallet.tsx @@ -8,7 +8,7 @@ export const ConnectWallet = () => { if (installedWallets.length === 0) { return ( -

+

You don't have any wallets installed...

); @@ -16,17 +16,17 @@ export const ConnectWallet = () => { return ( <> -

Connect a Wallet

-

Installed Wallets

-
    +

    Connect a Wallet

    +

    Installed Wallets

    +
      {installedWallets.map((w) => (
    • diff --git a/playground/src/components/FileDropper/FileDropper.tsx b/playground/src/components/FileDropper/FileDropper.tsx index 14a1bec..0dd1546 100644 --- a/playground/src/components/FileDropper/FileDropper.tsx +++ b/playground/src/components/FileDropper/FileDropper.tsx @@ -22,10 +22,10 @@ export const FileDropper: React.FC = ({ onDrop, cta }) => { 'dark:border-white/20 dark:text-white-70 max-w-5xl mx-auto transition duration-75', 'hover:bg-brand-500/10', )} - htmlFor="file" + htmlFor='file' > - squink - + squink + {cta} diff --git a/playground/src/components/Notifications/Notifications.tsx b/playground/src/components/Notifications/Notifications.tsx index 2e7284f..63f9e7c 100644 --- a/playground/src/components/Notifications/Notifications.tsx +++ b/playground/src/components/Notifications/Notifications.tsx @@ -1,5 +1,5 @@ -import { toNotificationLevel, useNotifications } from 'useink/notifications'; import { Snackbar } from '../Snackbar'; +import { toNotificationLevel, useNotifications } from 'useink/notifications'; export const Notifications: React.FC = () => { const { notifications, removeNotification } = useNotifications(); @@ -7,9 +7,9 @@ export const Notifications: React.FC = () => { if (!notifications.length) return null; return ( -
        +
          {notifications.map((n) => ( -
        • +
        • = ({ show, message, type, onClick }) => ( -
          +
          - - diff --git a/playground/src/components/ToggleSwitch/ToggleSwitch.tsx b/playground/src/components/ToggleSwitch/ToggleSwitch.tsx index 09369cb..7354bba 100644 --- a/playground/src/components/ToggleSwitch/ToggleSwitch.tsx +++ b/playground/src/components/ToggleSwitch/ToggleSwitch.tsx @@ -20,7 +20,7 @@ const ToggleSwitch: React.FC = ({ enabled, onChange }) => ( )} >