From 5cf00fb7d54a1fb8ac9fa2ce77f622de447aa010 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Mon, 24 Jun 2024 11:49:39 -0700 Subject: [PATCH 1/3] enable curly --- packages/eslint-config/eslint.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config/eslint.config.mjs b/packages/eslint-config/eslint.config.mjs index 01afa5bd..3cf10b69 100644 --- a/packages/eslint-config/eslint.config.mjs +++ b/packages/eslint-config/eslint.config.mjs @@ -94,5 +94,6 @@ export const penumbraEslintConfig = { ], }, ], + curly: ['error', 'all'], }, }; From 878b654f1b4763846205e930f314041d46f537b6 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Mon, 24 Jun 2024 11:51:39 -0700 Subject: [PATCH 2/3] changeset --- .changeset/eight-ducks-search.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/eight-ducks-search.md diff --git a/.changeset/eight-ducks-search.md b/.changeset/eight-ducks-search.md new file mode 100644 index 00000000..b040f18a --- /dev/null +++ b/.changeset/eight-ducks-search.md @@ -0,0 +1,5 @@ +--- +'@repo/eslint-config': minor +--- + +add rule curly all From d40f9c2918b1692c1051df8c0ebf461f1daca0b5 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Wed, 10 Jul 2024 16:02:41 -0700 Subject: [PATCH 3/3] lint fix curly --- apps/extension/src/approve-transaction.ts | 3 +- .../injected-request-listener.ts | 3 +- apps/extension/src/ctx/full-viewing-key.ts | 4 +- apps/extension/src/ctx/spend-key.ts | 12 ++++-- apps/extension/src/ctx/wallet-id.ts | 4 +- apps/extension/src/entry/offscreen-handler.ts | 4 +- apps/extension/src/hooks/chain-id.ts | 4 +- apps/extension/src/hooks/full-sync-height.ts | 12 ++++-- apps/extension/src/hooks/validation-result.ts | 4 +- .../src/listeners/message-prax-init.ts | 3 +- apps/extension/src/popup.ts | 11 ++++-- apps/extension/src/routes/page/index.tsx | 12 ++++-- .../src/routes/popup/approval/origin.tsx | 4 +- .../popup/approval/transaction/index.tsx | 8 +++- .../use-transaction-view-switcher.ts | 4 +- .../src/routes/popup/home/frontend-link.tsx | 4 +- .../extension/src/routes/popup/home/index.tsx | 8 +++- ...ess-ownership-info-from-bech32m-address.ts | 8 +++- .../popup/home/validate-address/result.tsx | 4 +- .../extension/src/routes/popup/popup-needs.ts | 8 +++- .../routes/popup/settings/settings-rpc.tsx | 4 +- apps/extension/src/rpc/rethrow-impl-errors.ts | 15 +++++-- apps/extension/src/rpc/tendermint-proxy.ts | 8 +++- apps/extension/src/senders/disconnect.ts | 7 +++- apps/extension/src/senders/validate.ts | 39 ++++++++++++++----- .../grpc-endpoint-form/chain-id-or-error.tsx | 4 +- .../components/grpc-endpoint-form/index.tsx | 8 +++- .../use-grpc-endpoint-form.ts | 12 ++++-- apps/extension/src/state/connected-sites.ts | 4 +- apps/extension/src/state/origin-approval.ts | 12 ++++-- apps/extension/src/state/password.ts | 12 ++++-- apps/extension/src/state/persist.ts | 8 +++- .../extension/src/state/seed-phrase/import.ts | 4 +- apps/extension/src/state/tx-approval.ts | 11 ++++-- apps/extension/src/state/wallets.ts | 16 ++++++-- apps/extension/src/storage/base.ts | 7 +++- apps/extension/src/storage/onboard.ts | 8 +++- apps/extension/src/storage/origin.ts | 11 ++++-- .../src/utils/get-numeraires-from-registry.ts | 4 +- apps/extension/src/wallet-services.ts | 7 +++- packages/context/src/index.ts | 7 +++- .../components/ui/account-switcher/index.tsx | 16 ++++++-- .../ui/components/ui/address-view/index.tsx | 4 +- .../components/ui/block-sync-status/index.tsx | 7 +++- packages/ui/components/ui/identicon/index.tsx | 4 +- .../ui/components/ui/select/select-list.tsx | 7 +++- packages/ui/components/ui/tx/action-view.tsx | 8 +++- .../ui/tx/actions-views/swap/swap-claim.tsx | 8 +++- .../ui/tx/auction-id-component/index.tsx | 4 +- .../expanded-details/get-price.ts | 3 +- .../expanded-details/get-step-index.ts | 12 ++++-- .../expanded-details/index.tsx | 4 +- .../ui/tx/dutch-auction-component/index.tsx | 4 +- .../get-human-readable-interval.ts | 28 +++++++++---- .../progress-bar/indicator/get-progress.ts | 8 +++- .../progress-bar/indicator/index.tsx | 4 +- packages/ui/components/ui/tx/index.tsx | 8 +++- packages/ui/components/ui/value/index.tsx | 4 +- packages/ui/lib/toast/toast.ts | 7 +++- packages/ui/lib/toast/transaction-toast.tsx | 12 ++++-- 60 files changed, 358 insertions(+), 126 deletions(-) diff --git a/apps/extension/src/approve-transaction.ts b/apps/extension/src/approve-transaction.ts index a6a495b5..0ade9e4d 100644 --- a/apps/extension/src/approve-transaction.ts +++ b/apps/extension/src/approve-transaction.ts @@ -21,8 +21,9 @@ export const approveTransaction = async ( if (popupResponse) { const resAuthorizeRequest = AuthorizeRequest.fromJson(popupResponse.authorizeRequest); - if (!authorizeRequest.equals(resAuthorizeRequest)) + if (!authorizeRequest.equals(resAuthorizeRequest)) { throw new Error('Invalid response from popup'); + } } return popupResponse?.choice; diff --git a/apps/extension/src/content-scripts/injected-request-listener.ts b/apps/extension/src/content-scripts/injected-request-listener.ts index dbdddeca..a65026d4 100644 --- a/apps/extension/src/content-scripts/injected-request-listener.ts +++ b/apps/extension/src/content-scripts/injected-request-listener.ts @@ -14,8 +14,9 @@ const handleRequest = (ev: MessageEvent) => { PraxConnection, undefined | PenumbraRequestFailure >(PraxConnection.Request); - if (failure) + if (failure) { window.postMessage({ [PRAX]: failure } satisfies PraxMessage, '/'); + } })(); } }; diff --git a/apps/extension/src/ctx/full-viewing-key.ts b/apps/extension/src/ctx/full-viewing-key.ts index 1c794503..8d60d923 100644 --- a/apps/extension/src/ctx/full-viewing-key.ts +++ b/apps/extension/src/ctx/full-viewing-key.ts @@ -4,7 +4,9 @@ import { localExtStorage } from '../storage/local'; export const getFullViewingKey = async () => { const wallet0 = (await localExtStorage.get('wallets'))[0]; - if (!wallet0) throw new ConnectError('No wallet available', Code.FailedPrecondition); + if (!wallet0) { + throw new ConnectError('No wallet available', Code.FailedPrecondition); + } return FullViewingKey.fromJsonString(wallet0.fullViewingKey); }; diff --git a/apps/extension/src/ctx/spend-key.ts b/apps/extension/src/ctx/spend-key.ts index 30321da9..dc94a5b2 100644 --- a/apps/extension/src/ctx/spend-key.ts +++ b/apps/extension/src/ctx/spend-key.ts @@ -7,15 +7,21 @@ import { generateSpendKey } from '@penumbra-zone/wasm/keys'; export const getSpendKey = async () => { const passKeyJson = await sessionExtStorage.get('passwordKey'); - if (!passKeyJson) throw new ConnectError('User must login', Code.Unauthenticated); + if (!passKeyJson) { + throw new ConnectError('User must login', Code.Unauthenticated); + } const passKey = await Key.fromJson(passKeyJson); const wallet0 = (await localExtStorage.get('wallets'))[0]; - if (!wallet0) throw new ConnectError('No wallet found'); + if (!wallet0) { + throw new ConnectError('No wallet found'); + } const seedBox = Box.fromJson(wallet0.custody.encryptedSeedPhrase); const seedPhrase = await passKey.unseal(seedBox); - if (!seedPhrase) throw new ConnectError('Unable to decrypt seed phrase', Code.Unauthenticated); + if (!seedPhrase) { + throw new ConnectError('Unable to decrypt seed phrase', Code.Unauthenticated); + } return generateSpendKey(seedPhrase); }; diff --git a/apps/extension/src/ctx/wallet-id.ts b/apps/extension/src/ctx/wallet-id.ts index 1e8f64ea..5be35757 100644 --- a/apps/extension/src/ctx/wallet-id.ts +++ b/apps/extension/src/ctx/wallet-id.ts @@ -4,7 +4,9 @@ import { localExtStorage } from '../storage/local'; export const getWalletId = async () => { const wallet0 = (await localExtStorage.get('wallets'))[0]; - if (!wallet0) throw new ConnectError('No wallet available', Code.FailedPrecondition); + if (!wallet0) { + throw new ConnectError('No wallet available', Code.FailedPrecondition); + } return WalletId.fromJsonString(wallet0.id); }; diff --git a/apps/extension/src/entry/offscreen-handler.ts b/apps/extension/src/entry/offscreen-handler.ts index 6f6eac5d..8c8621c2 100644 --- a/apps/extension/src/entry/offscreen-handler.ts +++ b/apps/extension/src/entry/offscreen-handler.ts @@ -8,7 +8,9 @@ import { } from '@penumbra-zone/types/internal-msg/offscreen'; chrome.runtime.onMessage.addListener((req, _sender, respond) => { - if (!isOffscreenRequest(req)) return false; + if (!isOffscreenRequest(req)) { + return false; + } const { type, request } = req; if (isActionBuildRequest(request)) { void (async () => { diff --git a/apps/extension/src/hooks/chain-id.ts b/apps/extension/src/hooks/chain-id.ts index 23873f2e..e8324176 100644 --- a/apps/extension/src/hooks/chain-id.ts +++ b/apps/extension/src/hooks/chain-id.ts @@ -3,7 +3,9 @@ import { viewClient } from '../clients'; const getChainIdViaViewService = async (): Promise => { const { parameters } = await viewClient.appParameters({}); - if (!parameters?.chainId) throw new Error('No chainId in response'); + if (!parameters?.chainId) { + throw new Error('No chainId in response'); + } return parameters.chainId; }; diff --git a/apps/extension/src/hooks/full-sync-height.ts b/apps/extension/src/hooks/full-sync-height.ts index fccb15d8..cf56f7cf 100644 --- a/apps/extension/src/hooks/full-sync-height.ts +++ b/apps/extension/src/hooks/full-sync-height.ts @@ -9,8 +9,12 @@ import { createPromiseClient } from '@connectrpc/connect'; const tryGetMax = (a?: number, b?: number): number | undefined => { // Height can be 0n which is falsy, so should compare to undefined state - if (a === undefined) return b; - if (b === undefined) return a; + if (a === undefined) { + return b; + } + if (b === undefined) { + return a; + } return Math.max(a, b); }; @@ -31,7 +35,9 @@ export const useSyncProgress = () => { const { data: queriedLatest, error } = useQuery({ queryKey: ['latestBlockHeight'], queryFn: async () => { - if (!grpcEndpoint) return; + if (!grpcEndpoint) { + return; + } const tendermintClient = createPromiseClient( TendermintProxyService, createGrpcWebTransport({ baseUrl: grpcEndpoint }), diff --git a/apps/extension/src/hooks/validation-result.ts b/apps/extension/src/hooks/validation-result.ts index b763678a..64866e8b 100644 --- a/apps/extension/src/hooks/validation-result.ts +++ b/apps/extension/src/hooks/validation-result.ts @@ -4,7 +4,9 @@ export const useValidationResult = ( value: string, validations?: Validation[], ): undefined | Validation => { - if (!validations) return; + if (!validations) { + return; + } const results = validations.filter(v => v.checkFn(value)); const error = results.find(v => v.type === 'error'); return error ? error : results.find(v => v.type === 'warn'); diff --git a/apps/extension/src/listeners/message-prax-init.ts b/apps/extension/src/listeners/message-prax-init.ts index c00cec39..858b5cfc 100644 --- a/apps/extension/src/listeners/message-prax-init.ts +++ b/apps/extension/src/listeners/message-prax-init.ts @@ -19,12 +19,13 @@ chrome.runtime.onMessage.addListener( void (async () => { const alreadyApproved = await alreadyApprovedSender(validSender); - if (alreadyApproved) + if (alreadyApproved) { void chrome.tabs.sendMessage(validSender.tab.id, PraxConnection.Init, { // init only the specific document frameId: validSender.frameId, documentId: validSender.documentId, }); + } })(); // handler is done diff --git a/apps/extension/src/popup.ts b/apps/extension/src/popup.ts index 0a05c6ed..ed9bec7a 100644 --- a/apps/extension/src/popup.ts +++ b/apps/extension/src/popup.ts @@ -24,8 +24,11 @@ export const popup = async ( const response = await chrome.runtime .sendMessage, InternalResponse>(req) .catch((e: unknown) => { - if (isChromeResponderDroppedError(e)) return null; - else throw e; + if (isChromeResponderDroppedError(e)) { + return null; + } else { + throw e; + } }); if (response && 'error' in response) { throw errorFromJson(response.error, undefined, ConnectError.from(response)); @@ -58,7 +61,9 @@ const throwIfAlreadyOpen = (path: string) => ], }) .then(popupContexts => { - if (popupContexts.length) throw Error('Popup already open'); + if (popupContexts.length) { + throw Error('Popup already open'); + } }); const throwIfNeedsLogin = async () => { diff --git a/apps/extension/src/routes/page/index.tsx b/apps/extension/src/routes/page/index.tsx index 74260001..70ed4c7c 100644 --- a/apps/extension/src/routes/page/index.tsx +++ b/apps/extension/src/routes/page/index.tsx @@ -14,9 +14,15 @@ export const pageIndexLoader = async () => { const grpcEndpoint = await localExtStorage.get('grpcEndpoint'); const frontendUrl = await localExtStorage.get('frontendUrl'); - if (!wallets.length) return redirect(PagePath.WELCOME); - if (!grpcEndpoint) return redirect(PagePath.SET_GRPC_ENDPOINT); - if (!frontendUrl) return redirect(PagePath.SET_DEFAULT_FRONTEND); + if (!wallets.length) { + return redirect(PagePath.WELCOME); + } + if (!grpcEndpoint) { + return redirect(PagePath.SET_GRPC_ENDPOINT); + } + if (!frontendUrl) { + return redirect(PagePath.SET_DEFAULT_FRONTEND); + } return null; }; diff --git a/apps/extension/src/routes/popup/approval/origin.tsx b/apps/extension/src/routes/popup/approval/origin.tsx index 1e81220e..d23fafcd 100644 --- a/apps/extension/src/routes/popup/approval/origin.tsx +++ b/apps/extension/src/routes/popup/approval/origin.tsx @@ -30,7 +30,9 @@ export const OriginApproval = () => { window.close(); }; - if (!requestOrigin) return null; + if (!requestOrigin) { + return null; + } return ( diff --git a/apps/extension/src/routes/popup/approval/transaction/index.tsx b/apps/extension/src/routes/popup/approval/transaction/index.tsx index 704c2513..0ebdb6d8 100644 --- a/apps/extension/src/routes/popup/approval/transaction/index.tsx +++ b/apps/extension/src/routes/popup/approval/transaction/index.tsx @@ -16,9 +16,13 @@ export const TransactionApproval = () => { const { selectedTransactionView, selectedTransactionViewName, setSelectedTransactionViewName } = useTransactionViewSwitcher(); - if (!authReqString) return null; + if (!authReqString) { + return null; + } const authorizeRequest = AuthorizeRequest.fromJsonString(authReqString); - if (!authorizeRequest.plan || !selectedTransactionView) return null; + if (!authorizeRequest.plan || !selectedTransactionView) { + return null; + } const approve = () => { setChoice(UserChoice.Approved); diff --git a/apps/extension/src/routes/popup/approval/transaction/use-transaction-view-switcher.ts b/apps/extension/src/routes/popup/approval/transaction/use-transaction-view-switcher.ts index 7ec07a2d..1f24ad5a 100644 --- a/apps/extension/src/routes/popup/approval/transaction/use-transaction-view-switcher.ts +++ b/apps/extension/src/routes/popup/approval/transaction/use-transaction-view-switcher.ts @@ -15,7 +15,9 @@ export const useTransactionViewSwitcher = (): { useState(TransactionViewTab.SENDER); const deserializedTransactionViews = useMemo(() => { - if (!asSender || !asReceiver || !asPublic) return {}; + if (!asSender || !asReceiver || !asPublic) { + return {}; + } return { asSender: TransactionView.fromJsonString(asSender), diff --git a/apps/extension/src/routes/popup/home/frontend-link.tsx b/apps/extension/src/routes/popup/home/frontend-link.tsx index d8689edf..53501694 100644 --- a/apps/extension/src/routes/popup/home/frontend-link.tsx +++ b/apps/extension/src/routes/popup/home/frontend-link.tsx @@ -12,7 +12,9 @@ export const FrontendLink = () => { // In case the frontendUrl is not set, prevent the link action, and open the settings page instead const onClick: MouseEventHandler = event => { - if (frontendUrl) return; + if (frontendUrl) { + return; + } event.stopPropagation(); navigate(PopupPath.SETTINGS_DEFAULT_FRONTEND); }; diff --git a/apps/extension/src/routes/popup/home/index.tsx b/apps/extension/src/routes/popup/home/index.tsx index d886f02c..b5de76a3 100644 --- a/apps/extension/src/routes/popup/home/index.tsx +++ b/apps/extension/src/routes/popup/home/index.tsx @@ -24,7 +24,9 @@ export interface PopupLoaderData { export const popupIndexLoader = async (): Promise => { await needsOnboard(); const redirect = await needsLogin(); - if (redirect) return redirect; + if (redirect) { + return redirect; + } return { fullSyncHeight: await localExtStorage.get('fullSyncHeight'), @@ -34,7 +36,9 @@ export const popupIndexLoader = async (): Promise => const getAddrByIndex = (wallet?: Wallet) => (index: number, ephemeral: boolean): Address => { - if (!wallet) throw new Error('No active wallet'); + if (!wallet) { + throw new Error('No active wallet'); + } const fullViewingKey = FullViewingKey.fromJsonString(wallet.fullViewingKey); return ephemeral diff --git a/apps/extension/src/routes/popup/home/validate-address/get-address-ownership-info-from-bech32m-address.ts b/apps/extension/src/routes/popup/home/validate-address/get-address-ownership-info-from-bech32m-address.ts index db4099bc..0b98e5b2 100644 --- a/apps/extension/src/routes/popup/home/validate-address/get-address-ownership-info-from-bech32m-address.ts +++ b/apps/extension/src/routes/popup/home/validate-address/get-address-ownership-info-from-bech32m-address.ts @@ -5,14 +5,18 @@ import { Address } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/k export const getAddressOwnershipInfoFromBech32mAddress = async ( bech32mAddress: string, ): Promise => { - if (!bech32mAddress) return undefined; + if (!bech32mAddress) { + return undefined; + } try { const { addressIndex } = await viewClient.indexByAddress({ address: new Address({ altBech32m: bech32mAddress }), }); - if (!addressIndex) return { isValidAddress: true, belongsToWallet: false }; + if (!addressIndex) { + return { isValidAddress: true, belongsToWallet: false }; + } return { addressIndexAccount: addressIndex.account, diff --git a/apps/extension/src/routes/popup/home/validate-address/result.tsx b/apps/extension/src/routes/popup/home/validate-address/result.tsx index baaedede..954d24cf 100644 --- a/apps/extension/src/routes/popup/home/validate-address/result.tsx +++ b/apps/extension/src/routes/popup/home/validate-address/result.tsx @@ -6,7 +6,9 @@ export const Result = ({ }: { addressOwnershipInfo?: AddressOwnershipInfo; }) => { - if (!addressOwnershipInfo) return null; + if (!addressOwnershipInfo) { + return null; + } if (!addressOwnershipInfo.isValidAddress) { return ( diff --git a/apps/extension/src/routes/popup/popup-needs.ts b/apps/extension/src/routes/popup/popup-needs.ts index d687bd42..9b1c7167 100644 --- a/apps/extension/src/routes/popup/popup-needs.ts +++ b/apps/extension/src/routes/popup/popup-needs.ts @@ -5,7 +5,9 @@ import { sessionExtStorage } from '../../storage/session'; export const needsLogin = async (): Promise => { const password = await sessionExtStorage.get('passwordKey'); - if (password) return null; + if (password) { + return null; + } return redirect(PopupPath.LOGIN); }; @@ -15,7 +17,9 @@ export const needsOnboard = async () => { const grpcEndpoint = await localExtStorage.get('grpcEndpoint'); const frontendUrl = await localExtStorage.get('frontendUrl'); - if (wallets.length && grpcEndpoint !== undefined && frontendUrl !== undefined) return null; + if (wallets.length && grpcEndpoint !== undefined && frontendUrl !== undefined) { + return null; + } void chrome.runtime.openOptionsPage(); window.close(); diff --git a/apps/extension/src/routes/popup/settings/settings-rpc.tsx b/apps/extension/src/routes/popup/settings/settings-rpc.tsx index 06e94a4e..36b39ae1 100644 --- a/apps/extension/src/routes/popup/settings/settings-rpc.tsx +++ b/apps/extension/src/routes/popup/settings/settings-rpc.tsx @@ -12,7 +12,9 @@ export const SettingsRPC = () => { const { promise, resolve } = Promise.withResolvers(); setCountdownTime(seconds); setInterval(() => { - if (!seconds) resolve(undefined); + if (!seconds) { + resolve(undefined); + } setCountdownTime(--seconds); }, 1000); return promise; diff --git a/apps/extension/src/rpc/rethrow-impl-errors.ts b/apps/extension/src/rpc/rethrow-impl-errors.ts index f171a44a..edbe5b32 100644 --- a/apps/extension/src/rpc/rethrow-impl-errors.ts +++ b/apps/extension/src/rpc/rethrow-impl-errors.ts @@ -10,14 +10,19 @@ const wrapUnaryImpl = (req: AnyMessage, ctx: HandlerContext) => { try { const result = methodImplementation(req, ctx); - if (result instanceof Promise) + if (result instanceof Promise) { return result.catch((e: unknown) => { - if (globalThis.__DEV__) console.debug(ctx.method.name, req, e); + if (globalThis.__DEV__) { + console.debug(ctx.method.name, req, e); + } throw ConnectError.from(e); }); + } return result; } catch (e) { - if (globalThis.__DEV__) console.debug(ctx.method.name, req, e); + if (globalThis.__DEV__) { + console.debug(ctx.method.name, req, e); + } throw ConnectError.from(e); } }; @@ -31,7 +36,9 @@ const wrapServerStreamingImpl = ( yield result; } } catch (e) { - if (globalThis.__DEV__) console.debug(ctx.method.name, req, e); + if (globalThis.__DEV__) { + console.debug(ctx.method.name, req, e); + } throw ConnectError.from(e); } }; diff --git a/apps/extension/src/rpc/tendermint-proxy.ts b/apps/extension/src/rpc/tendermint-proxy.ts index 8acede0a..7de61b24 100644 --- a/apps/extension/src/rpc/tendermint-proxy.ts +++ b/apps/extension/src/rpc/tendermint-proxy.ts @@ -23,8 +23,12 @@ export const makeTendermintProxyZeroNanos = ( ): Pick, 'getBlockByHeight'> => ({ getBlockByHeight: async req => { const r = await c.getBlockByHeight(req); - if (r.block?.header?.time?.nanos) r.block.header.time.nanos = 0; - if (r.block?.lastCommit?.signatures.length) r.block.lastCommit.signatures = []; + if (r.block?.header?.time?.nanos) { + r.block.header.time.nanos = 0; + } + if (r.block?.lastCommit?.signatures.length) { + r.block.lastCommit.signatures = []; + } return r; }, }); diff --git a/apps/extension/src/senders/disconnect.ts b/apps/extension/src/senders/disconnect.ts index ffe2f603..3fbc45be 100644 --- a/apps/extension/src/senders/disconnect.ts +++ b/apps/extension/src/senders/disconnect.ts @@ -13,6 +13,9 @@ import { removeOriginRecord } from '../storage/origin'; export const disconnectSender = (disconnect: { origin: string }) => void alreadyApprovedSender(disconnect).then(hasApproval => { - if (!hasApproval) throw new Error('Sender does not possess approval'); - else void removeOriginRecord(disconnect.origin); + if (!hasApproval) { + throw new Error('Sender does not possess approval'); + } else { + void removeOriginRecord(disconnect.origin); + } }); diff --git a/apps/extension/src/senders/validate.ts b/apps/extension/src/senders/validate.ts index 95f78d78..c7d3feb4 100644 --- a/apps/extension/src/senders/validate.ts +++ b/apps/extension/src/senders/validate.ts @@ -14,21 +14,40 @@ type ValidSender = chrome.runtime.MessageSender & { }; export const assertValidSender = (sender?: chrome.runtime.MessageSender) => { - if (!sender) throw new Error('Sender undefined'); - if (!sender.tab?.id) throw new Error('Sender is not a tab'); - if (sender.frameId !== 0) throw new Error('Sender is not a top-level frame'); - if (!sender.documentId) throw new Error('Sender is not a document'); + if (!sender) { + throw new Error('Sender undefined'); + } + if (!sender.tab?.id) { + throw new Error('Sender is not a tab'); + } + if (sender.frameId !== 0) { + throw new Error('Sender is not a top-level frame'); + } + if (!sender.documentId) { + throw new Error('Sender is not a document'); + } - if (!sender.origin) throw new Error('Sender has no origin'); + if (!sender.origin) { + throw new Error('Sender has no origin'); + } const parsedOrigin = new URL(sender.origin); - if (parsedOrigin.origin !== sender.origin) throw new Error('Sender origin is invalid'); - if (!(parsedOrigin.protocol in ValidProtocol)) + if (parsedOrigin.origin !== sender.origin) { + throw new Error('Sender origin is invalid'); + } + if (!(parsedOrigin.protocol in ValidProtocol)) { throw new Error(`Sender protocol is not ${Object.values(ValidProtocol).join(',')}`); + } - if (!sender.url) throw new Error('Sender has no URL'); + if (!sender.url) { + throw new Error('Sender has no URL'); + } const parsedUrl = new URL(sender.url); - if (parsedUrl.href !== sender.url) throw new Error('Sender URL is invalid'); - if (parsedUrl.origin !== parsedOrigin.origin) throw new Error('Sender URL has unexpected origin'); + if (parsedUrl.href !== sender.url) { + throw new Error('Sender URL is invalid'); + } + if (parsedUrl.origin !== parsedOrigin.origin) { + throw new Error('Sender URL has unexpected origin'); + } // TODO: externally_connectable can use more sender data //if (!sender.tlsChannelId) throw new Error('Sender has no tlsChannelId'); diff --git a/apps/extension/src/shared/components/grpc-endpoint-form/chain-id-or-error.tsx b/apps/extension/src/shared/components/grpc-endpoint-form/chain-id-or-error.tsx index 3e710ed3..0d826c3c 100644 --- a/apps/extension/src/shared/components/grpc-endpoint-form/chain-id-or-error.tsx +++ b/apps/extension/src/shared/components/grpc-endpoint-form/chain-id-or-error.tsx @@ -9,7 +9,9 @@ export const ChainIdOrError = ({ chainId?: string; chainIdChanged: boolean; }) => { - if (!error && !chainId) return null; + if (!error && !chainId) { + return null; + } return (
) => { e.preventDefault(); - if (isSubmitButtonEnabled) void onSubmit(onSuccess); + if (isSubmitButtonEnabled) { + void onSubmit(onSuccess); + } }; return ( @@ -81,7 +83,9 @@ export const GrpcEndpointForm = ({ /> } onSelect={() => { - if (!isCustomGrpcEndpoint) setGrpcEndpointInput(''); + if (!isCustomGrpcEndpoint) { + setGrpcEndpointInput(''); + } customGrpcEndpointInput.current?.focus(); }} isSelected={isCustomGrpcEndpoint} diff --git a/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts b/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts index 78ea65b9..a827d1da 100644 --- a/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts +++ b/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts @@ -44,7 +44,9 @@ export const useGrpcEndpointForm = (isOnboarding: boolean) => { grpcEndpointInput !== '' && !grpcEndpoints.some(({ url }) => url === grpcEndpointInput); const setGrpcEndpointInputOnLoadFromState = useCallback(() => { - if (grpcEndpoint) setGrpcEndpointInput(grpcEndpoint); + if (grpcEndpoint) { + setGrpcEndpointInput(grpcEndpoint); + } }, [grpcEndpoint]); useEffect(setGrpcEndpointInputOnLoadFromState, [setGrpcEndpointInputOnLoadFromState]); @@ -54,7 +56,9 @@ export const useGrpcEndpointForm = (isOnboarding: boolean) => { setIsSubmitButtonEnabled(false); setRpcError(undefined); - if (!isValidUrl(grpcEndpointInput)) return; + if (!isValidUrl(grpcEndpointInput)) { + return; + } try { setIsValidationLoading(true); @@ -63,7 +67,9 @@ export const useGrpcEndpointForm = (isOnboarding: boolean) => { createGrpcWebTransport({ baseUrl: grpcEndpointInput }), ); const { appParameters } = await trialClient.appParameters({}); - if (!appParameters?.chainId) throw new ConnectError('', Code.NotFound); + if (!appParameters?.chainId) { + throw new ConnectError('', Code.NotFound); + } setIsSubmitButtonEnabled(true); setChainId(appParameters.chainId); diff --git a/apps/extension/src/state/connected-sites.ts b/apps/extension/src/state/connected-sites.ts index 38d916c3..280bd5d0 100644 --- a/apps/extension/src/state/connected-sites.ts +++ b/apps/extension/src/state/connected-sites.ts @@ -32,7 +32,9 @@ export const createConnectedSitesSlice = export const allSitesFilteredOutSelector = (state: AllSlices) => { const filter = state.connectedSites.filter; - if (!filter) return false; + if (!filter) { + return false; + } return !state.connectedSites.knownSites.some(site => site.origin.includes(filter)); }; diff --git a/apps/extension/src/state/origin-approval.ts b/apps/extension/src/state/origin-approval.ts index c521ec28..d5bc7214 100644 --- a/apps/extension/src/state/origin-approval.ts +++ b/apps/extension/src/state/origin-approval.ts @@ -35,7 +35,9 @@ export const createOriginApprovalSlice = (): SliceCreator = responder, ) => { const existing = get().originApproval; - if (existing.responder) throw new Error('Another request is still pending'); + if (existing.responder) { + throw new Error('Another request is still pending'); + } set(state => { state.originApproval.favIconUrl = favIconUrl; @@ -49,10 +51,14 @@ export const createOriginApprovalSlice = (): SliceCreator = sendResponse: () => { const { responder, choice, requestOrigin } = get().originApproval; - if (!responder) throw new Error('No responder'); + if (!responder) { + throw new Error('No responder'); + } try { - if (choice === undefined || !requestOrigin) throw new Error('Missing response data'); + if (choice === undefined || !requestOrigin) { + throw new Error('Missing response data'); + } responder({ type: PopupType.OriginApproval, data: { diff --git a/apps/extension/src/state/password.ts b/apps/extension/src/state/password.ts index d62f5b6d..630a3926 100644 --- a/apps/extension/src/state/password.ts +++ b/apps/extension/src/state/password.ts @@ -34,10 +34,14 @@ export const createPasswordSlice = }, setSessionPassword: async password => { const keyPrintJson = await local.get('passwordKeyPrint'); - if (!keyPrintJson) throw new Error('Password KeyPrint not in storage'); + if (!keyPrintJson) { + throw new Error('Password KeyPrint not in storage'); + } const key = await Key.recreate(password, KeyPrint.fromJson(keyPrintJson)); - if (!key) throw new Error('Password does not match KeyPrint'); + if (!key) { + throw new Error('Password does not match KeyPrint'); + } const keyJson = await key.toJson(); @@ -53,7 +57,9 @@ export const createPasswordSlice = }, isPassword: async attempt => { const keyPrintJson = await local.get('passwordKeyPrint'); - if (!keyPrintJson) throw new Error('Password KeyPrint not in storage'); + if (!keyPrintJson) { + throw new Error('Password KeyPrint not in storage'); + } const key = await Key.recreate(attempt, KeyPrint.fromJson(keyPrintJson)); return Boolean(key); diff --git a/apps/extension/src/state/persist.ts b/apps/extension/src/state/persist.ts index 7046d0b2..6d311ce8 100644 --- a/apps/extension/src/state/persist.ts +++ b/apps/extension/src/state/persist.ts @@ -47,8 +47,12 @@ export const customPersistImpl: Persist = f => (set, get, store) => { // Part 2: when chrome.storage changes sync select fields to store chrome.storage.onChanged.addListener((changes, area) => { - if (area === 'local') syncLocal(changes, set); - if (area === 'session') syncSession(changes, set); + if (area === 'local') { + syncLocal(changes, set); + } + if (area === 'session') { + syncSession(changes, set); + } }); })(); diff --git a/apps/extension/src/state/seed-phrase/import.ts b/apps/extension/src/state/seed-phrase/import.ts index a329888e..5d4e60ce 100644 --- a/apps/extension/src/state/seed-phrase/import.ts +++ b/apps/extension/src/state/seed-phrase/import.ts @@ -35,7 +35,9 @@ export const createImport: SliceCreator = (set, get) const desiredLength = length === SeedPhraseLength.TWELVE_WORDS ? 12 : 24; const currLength = get().seedPhrase.import.phrase.length; - if (currLength === desiredLength) return; + if (currLength === desiredLength) { + return; + } if (currLength < desiredLength) { set(({ seedPhrase }) => { seedPhrase.import.phrase = seedPhrase.import.phrase.concat( diff --git a/apps/extension/src/state/tx-approval.ts b/apps/extension/src/state/tx-approval.ts index e40b0bb8..5e17897f 100644 --- a/apps/extension/src/state/tx-approval.ts +++ b/apps/extension/src/state/tx-approval.ts @@ -56,7 +56,9 @@ export interface TxApprovalSlice { export const createTxApprovalSlice = (): SliceCreator => (set, get) => ({ acceptRequest: async ({ request: { authorizeRequest: authReqJson } }, responder) => { const existing = get().txApproval; - if (existing.responder) throw new Error('Another request is still pending'); + if (existing.responder) { + throw new Error('Another request is still pending'); + } const authorizeRequest = AuthorizeRequest.fromJson(authReqJson); @@ -118,11 +120,14 @@ export const createTxApprovalSlice = (): SliceCreator => (set, authorizeRequest: authorizeRequestString, } = get().txApproval; - if (!responder) throw new Error('No responder'); + if (!responder) { + throw new Error('No responder'); + } try { - if (choice === undefined || !transactionViewString || !authorizeRequestString) + if (choice === undefined || !transactionViewString || !authorizeRequestString) { throw new Error('Missing response data'); + } // zustand doesn't like jsonvalue so stringify const authorizeRequest = AuthorizeRequest.fromJsonString( diff --git a/apps/extension/src/state/wallets.ts b/apps/extension/src/state/wallets.ts index 7dc53a6b..7ffb26fd 100644 --- a/apps/extension/src/state/wallets.ts +++ b/apps/extension/src/state/wallets.ts @@ -22,7 +22,9 @@ export const createWalletsSlice = const fullViewingKey = getFullViewingKey(spendKey); const passwordKey = get().password.key; - if (passwordKey === undefined) throw new Error('Password Key not in storage'); + if (passwordKey === undefined) { + throw new Error('Password Key not in storage'); + } const key = await Key.fromJson(passwordKey); const encryptedSeedPhrase = await key.seal(seedPhraseStr); @@ -44,14 +46,20 @@ export const createWalletsSlice = }, getSeedPhrase: async () => { const passwordKey = get().password.key; - if (!passwordKey) throw new Error('no password set'); + if (!passwordKey) { + throw new Error('no password set'); + } const key = await Key.fromJson(passwordKey); const activeWallet = getActiveWallet(get()); - if (!activeWallet) throw new Error('no wallet set'); + if (!activeWallet) { + throw new Error('no wallet set'); + } const decryptedSeedPhrase = await key.unseal(activeWallet.custody.encryptedSeedPhrase); - if (!decryptedSeedPhrase) throw new Error('Unable to decrypt seed phrase with password'); + if (!decryptedSeedPhrase) { + throw new Error('Unable to decrypt seed phrase with password'); + } return decryptedSeedPhrase.split(' '); }, diff --git a/apps/extension/src/storage/base.ts b/apps/extension/src/storage/base.ts index 09ea3173..32218ddd 100644 --- a/apps/extension/src/storage/base.ts +++ b/apps/extension/src/storage/base.ts @@ -40,8 +40,11 @@ export class ExtensionStorage { | Record> | EmptyObject; - if (isEmptyObj(result)) return this.defaults[key]; - else return await this.migrateIfNeeded(key, result[key]); + if (isEmptyObj(result)) { + return this.defaults[key]; + } else { + return await this.migrateIfNeeded(key, result[key]); + } } async set(key: K, value: T[K]): Promise { diff --git a/apps/extension/src/storage/onboard.ts b/apps/extension/src/storage/onboard.ts index 00b0fea4..66323a01 100644 --- a/apps/extension/src/storage/onboard.ts +++ b/apps/extension/src/storage/onboard.ts @@ -10,7 +10,9 @@ import { LocalStorageState } from './types'; */ export const onboardGrpcEndpoint = async (): Promise => { const grpcEndpoint = await localExtStorage.get('grpcEndpoint'); - if (grpcEndpoint) return grpcEndpoint; + if (grpcEndpoint) { + return grpcEndpoint; + } return new Promise(resolve => { const storageListener = (changes: Record) => { @@ -29,7 +31,9 @@ export const onboardGrpcEndpoint = async (): Promise => { export const onboardWallet = async (): Promise => { const wallets = await localExtStorage.get('wallets'); - if (wallets[0]) return wallets[0]; + if (wallets[0]) { + return wallets[0]; + } return new Promise(resolve => { const storageListener: Listener = changes => { diff --git a/apps/extension/src/storage/origin.ts b/apps/extension/src/storage/origin.ts index b53b9360..b1404cf9 100644 --- a/apps/extension/src/storage/origin.ts +++ b/apps/extension/src/storage/origin.ts @@ -3,12 +3,15 @@ import { localExtStorage } from './local'; import { OriginRecord } from './types'; export const getOriginRecord = async (getOrigin?: string) => { - if (!getOrigin) return undefined; + if (!getOrigin) { + return undefined; + } const knownSites = await localExtStorage.get('knownSites'); const matchRecords = knownSites.filter(r => r.origin === getOrigin); - if (matchRecords.length > 1) + if (matchRecords.length > 1) { throw new Error(`There are multiple records for origin: ${getOrigin}`); + } return matchRecords[0]; }; @@ -36,7 +39,9 @@ export const removeOriginRecord = async (removeOrigin: string): Promise => const newKnownSites = produce(knownSites, allRecords => { const matchIndex = allRecords.findIndex(r => r.origin === removeOrigin); - if (matchIndex !== -1) allRecords.splice(matchIndex, 1); + if (matchIndex !== -1) { + allRecords.splice(matchIndex, 1); + } }); await localExtStorage.set('knownSites', newKnownSites); diff --git a/apps/extension/src/utils/get-numeraires-from-registry.ts b/apps/extension/src/utils/get-numeraires-from-registry.ts index 02a6b0f6..427d5928 100644 --- a/apps/extension/src/utils/get-numeraires-from-registry.ts +++ b/apps/extension/src/utils/get-numeraires-from-registry.ts @@ -2,7 +2,9 @@ import { Metadata } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/ import { ChainRegistryClient } from '@penumbra-labs/registry'; export const getNumeraireFromRegistry = (chainId?: string): Metadata[] => { - if (!chainId) return []; + if (!chainId) { + return []; + } try { const registryClient = new ChainRegistryClient(); const registry = registryClient.get(chainId); diff --git a/apps/extension/src/wallet-services.ts b/apps/extension/src/wallet-services.ts index cb67690c..9965c3a4 100644 --- a/apps/extension/src/wallet-services.ts +++ b/apps/extension/src/wallet-services.ts @@ -45,8 +45,11 @@ const getChainId = async (baseUrl: string) => { .get('params') .then(jsonParams => (jsonParams ? AppParameters.fromJsonString(jsonParams) : undefined))); - if (params?.chainId) void localExtStorage.set('params', params.toJsonString()); - else throw new Error('No chainId available'); + if (params?.chainId) { + void localExtStorage.set('params', params.toJsonString()); + } else { + throw new Error('No chainId available'); + } return params.chainId; }; diff --git a/packages/context/src/index.ts b/packages/context/src/index.ts index 131f189f..3aaeaefb 100644 --- a/packages/context/src/index.ts +++ b/packages/context/src/index.ts @@ -79,7 +79,9 @@ export class Services implements ServicesInterface { } else if (queriedParams?.chainId) { // none stored, but fetched are ok. return queriedParams; - } else throw new Error('No available chainId'); + } else { + throw new Error('No available chainId'); + } } private async initializeWalletServices(): Promise { @@ -93,8 +95,9 @@ export class Services implements ServicesInterface { }); const { sctParams } = await this.getParams(indexedDb, querier); - if (!sctParams?.epochDuration) + if (!sctParams?.epochDuration) { throw new Error('Cannot initialize viewServer without epoch duration'); + } const viewServer = await ViewServer.initialize({ fullViewingKey, diff --git a/packages/ui/components/ui/account-switcher/index.tsx b/packages/ui/components/ui/account-switcher/index.tsx index 13ec9b3d..f7b5f9db 100644 --- a/packages/ui/components/ui/account-switcher/index.tsx +++ b/packages/ui/components/ui/account-switcher/index.tsx @@ -35,7 +35,9 @@ export const AccountSwitcher = ({ const handleClickPrevious = () => { if (sortedFilter) { const previousAccount = sortedFilter[sortedFilter.indexOf(account) - 1]; - if (previousAccount !== undefined) handleChange(previousAccount); + if (previousAccount !== undefined) { + handleChange(previousAccount); + } } else { handleChange(account - 1); } @@ -44,7 +46,9 @@ export const AccountSwitcher = ({ const handleClickNext = () => { if (sortedFilter) { const nextAccount = sortedFilter[sortedFilter.indexOf(account) + 1]; - if (nextAccount !== undefined) handleChange(nextAccount); + if (nextAccount !== undefined) { + handleChange(nextAccount); + } } else { handleChange(account + 1); } @@ -91,12 +95,16 @@ export const AccountSwitcher = ({ * user presses Enter? Then it could validate that the entered * account index is in the filter. */ - if (filter) return; + if (filter) { + return; + } const value = Number(e.target.value); const valueLength = e.target.value.replace(/^0+/, '').length; - if (value > MAX_INDEX || valueLength > MAX_INDEX.toString().length) return; + if (value > MAX_INDEX || valueLength > MAX_INDEX.toString().length) { + return; + } handleChange(value); }} style={{ width: `${inputCharWidth}ch` }} diff --git a/packages/ui/components/ui/address-view/index.tsx b/packages/ui/components/ui/address-view/index.tsx index d6a36dd2..77311edd 100644 --- a/packages/ui/components/ui/address-view/index.tsx +++ b/packages/ui/components/ui/address-view/index.tsx @@ -12,7 +12,9 @@ interface AddressViewProps { // Renders an address or an address view. // If the view is given and is "visible", the account information will be displayed instead. export const AddressViewComponent = ({ view, copyable = true }: AddressViewProps) => { - if (!view?.addressView.value?.address) return <>; + if (!view?.addressView.value?.address) { + return <>; + } const encodedAddress = bech32mAddress(view.addressView.value.address); diff --git a/packages/ui/components/ui/block-sync-status/index.tsx b/packages/ui/components/ui/block-sync-status/index.tsx index 4abaf951..a383b5ea 100644 --- a/packages/ui/components/ui/block-sync-status/index.tsx +++ b/packages/ui/components/ui/block-sync-status/index.tsx @@ -15,9 +15,12 @@ export const CondensedBlockSyncStatus = ({ fullSyncHeight?: bigint; error?: unknown; }) => { - if (error) return ; - if (!latestKnownBlockHeight || !fullSyncHeight) + if (error) { + return ; + } + if (!latestKnownBlockHeight || !fullSyncHeight) { return ; + } const isSyncing = latestKnownBlockHeight - fullSyncHeight > 10; diff --git a/packages/ui/components/ui/identicon/index.tsx b/packages/ui/components/ui/identicon/index.tsx index 3a7cbb21..661edc88 100644 --- a/packages/ui/components/ui/identicon/index.tsx +++ b/packages/ui/components/ui/identicon/index.tsx @@ -3,7 +3,9 @@ import { generateGradient, generateSolidColor } from './generate'; import { IdenticonProps } from './types'; export const Identicon = ({ type, ...props }: IdenticonProps & { type: 'gradient' | 'solid' }) => { - if (type === 'gradient') return ; + if (type === 'gradient') { + return ; + } return ; }; diff --git a/packages/ui/components/ui/select/select-list.tsx b/packages/ui/components/ui/select/select-list.tsx index ca12f3e7..e0fff3f6 100644 --- a/packages/ui/components/ui/select/select-list.tsx +++ b/packages/ui/components/ui/select/select-list.tsx @@ -86,8 +86,11 @@ const Option = ({ label, secondary, isSelected, image, ...rest }: OptionProp role='button' aria-selected={isSelected} onClick={() => { - if ('value' in rest && 'onSelect' in rest) rest.onSelect(rest.value); - else if (rest.onSelect) rest.onSelect(); + if ('value' in rest && 'onSelect' in rest) { + rest.onSelect(rest.value); + } else if (rest.onSelect) { + rest.onSelect(); + } }} > {image &&
{image}
} diff --git a/packages/ui/components/ui/tx/action-view.tsx b/packages/ui/components/ui/tx/action-view.tsx index 8aec7d01..a8494473 100644 --- a/packages/ui/components/ui/tx/action-view.tsx +++ b/packages/ui/components/ui/tx/action-view.tsx @@ -37,10 +37,14 @@ const CASE_TO_LABEL: Record = { }; const getLabelForActionCase = (actionCase: string | undefined): string => { - if (!actionCase) return ''; + if (!actionCase) { + return ''; + } const label = CASE_TO_LABEL[actionCase]; - if (label) return label; + if (label) { + return label; + } return String(actionCase); }; diff --git a/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx b/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx index a939cd58..b9716948 100644 --- a/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx +++ b/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx @@ -17,8 +17,12 @@ const getClaimLabel = ( output1Amount?: Amount, output2Amount?: Amount, ): 'Claimed Amount' | 'Claimed Amounts' => { - if (!output1Amount || !output2Amount) return 'Claimed Amount'; - if (isZero(output1Amount) || isZero(output2Amount)) return 'Claimed Amount'; + if (!output1Amount || !output2Amount) { + return 'Claimed Amount'; + } + if (isZero(output1Amount) || isZero(output2Amount)) { + return 'Claimed Amount'; + } return 'Claimed Amounts'; }; diff --git a/packages/ui/components/ui/tx/auction-id-component/index.tsx b/packages/ui/components/ui/tx/auction-id-component/index.tsx index 42488917..75a14b7c 100644 --- a/packages/ui/components/ui/tx/auction-id-component/index.tsx +++ b/packages/ui/components/ui/tx/auction-id-component/index.tsx @@ -17,7 +17,9 @@ const SEPARATOR_INDEX = PENUMBRA_BECH32M_AUCTION_PREFIX.length + 1; export const AuctionIdComponent = ({ auctionId }: { auctionId?: AuctionId }) => { const id = useMemo(() => (auctionId ? bech32mAuctionId(auctionId) : undefined), [auctionId]); - if (!id) return null; + if (!id) { + return null; + } return (
diff --git a/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-price.ts b/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-price.ts index 1d95cd61..74911ea6 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-price.ts +++ b/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-price.ts @@ -30,8 +30,9 @@ export const getPrice = ( !auctionDescription.maxOutput || !auctionDescription.minOutput || !auctionDescription.input?.amount - ) + ) { return undefined; + } const maxOutput = joinLoHiAmount(auctionDescription.maxOutput); const minOutput = joinLoHiAmount(auctionDescription.minOutput); diff --git a/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-step-index.ts b/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-step-index.ts index 0cdab945..f1cf8a5e 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-step-index.ts +++ b/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/get-step-index.ts @@ -15,9 +15,15 @@ export const getStepIndex = ( }: Pick, fullSyncHeight?: bigint, ): bigint | undefined => { - if (fullSyncHeight === undefined) return undefined; - if (fullSyncHeight >= endHeight) return stepCount - 1n; // zero-indexed - if (fullSyncHeight <= startHeight) return 0n; + if (fullSyncHeight === undefined) { + return undefined; + } + if (fullSyncHeight >= endHeight) { + return stepCount - 1n; + } // zero-indexed + if (fullSyncHeight <= startHeight) { + return 0n; + } const currentDistanceFromStartHeight = fullSyncHeight - startHeight; const endHeightDistanceFromStartHeightInclusive = endHeight - startHeight + 1n; diff --git a/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/index.tsx b/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/index.tsx index c9e725bb..b745986b 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/index.tsx +++ b/packages/ui/components/ui/tx/dutch-auction-component/expanded-details/index.tsx @@ -25,7 +25,9 @@ export const ExpandedDetails = ({ fullSyncHeight?: bigint; }) => { const { description } = dutchAuction; - if (!description) return null; + if (!description) { + return null; + } const maxPrice = getPrice(description, inputMetadata, description.startHeight); const currentPrice = getPrice(description, inputMetadata, fullSyncHeight); diff --git a/packages/ui/components/ui/tx/dutch-auction-component/index.tsx b/packages/ui/components/ui/tx/dutch-auction-component/index.tsx index 304dddb4..b839276a 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/index.tsx +++ b/packages/ui/components/ui/tx/dutch-auction-component/index.tsx @@ -50,7 +50,9 @@ export const DutchAuctionComponent = ({ const [isExpanded, setIsExpanded] = useState(false); const { description } = dutchAuction; - if (!description) return null; + if (!description) { + return null; + } return ( diff --git a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/get-human-readable-interval.ts b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/get-human-readable-interval.ts index 40e1887b..5e113d60 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/get-human-readable-interval.ts +++ b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/get-human-readable-interval.ts @@ -10,23 +10,37 @@ export const getHumanReadableInterval = (seconds: number): string => { const parts: string[] = []; const days = seconds / DAY_IN_SECONDS; const daysRounded = Math.floor(days); - if (days >= 1) parts.push(`${daysRounded}d`); - if (days === daysRounded) return parts.join(' '); + if (days >= 1) { + parts.push(`${daysRounded}d`); + } + if (days === daysRounded) { + return parts.join(' '); + } let remainder = seconds % DAY_IN_SECONDS; const hours = remainder / HOUR_IN_SECONDS; const hoursRounded = Math.floor(hours); - if (hours >= 1 || parts.length > 0) parts.push(`${hoursRounded}h`); - if (hours === hoursRounded) return parts.join(' '); + if (hours >= 1 || parts.length > 0) { + parts.push(`${hoursRounded}h`); + } + if (hours === hoursRounded) { + return parts.join(' '); + } remainder = remainder % HOUR_IN_SECONDS; const minutes = remainder / MINUTE_IN_SECONDS; const minutesRounded = Math.floor(minutes); - if (minutes >= 1 || parts.length > 0) parts.push(`${minutesRounded}m`); - if (minutes === minutesRounded) return parts.join(' '); + if (minutes >= 1 || parts.length > 0) { + parts.push(`${minutesRounded}m`); + } + if (minutes === minutesRounded) { + return parts.join(' '); + } remainder = remainder % MINUTE_IN_SECONDS; - if (remainder >= 1 || parts.length > 0) parts.push(`${remainder}s`); + if (remainder >= 1 || parts.length > 0) { + parts.push(`${remainder}s`); + } return parts.join(' '); }; diff --git a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/get-progress.ts b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/get-progress.ts index 5d8280a0..cf192ce2 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/get-progress.ts +++ b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/get-progress.ts @@ -14,8 +14,12 @@ export const getProgress = ( fullSyncHeight?: bigint, seqNum?: bigint, ): number => { - if (seqNum) return 1; - if (!fullSyncHeight) return 0; + if (seqNum) { + return 1; + } + if (!fullSyncHeight) { + return 0; + } const currentDistanceFromStartHeightInclusive = Number(fullSyncHeight) - Number(startHeight) + 1; const endHeightDistanceFromStartHeightInclusive = Number(endHeight) - Number(startHeight) + 1; diff --git a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/index.tsx b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/index.tsx index d12a6942..29841c10 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/index.tsx +++ b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/indicator/index.tsx @@ -13,7 +13,9 @@ export const Indicator = ({ }) => { const description = getDescription(dutchAuction); const seqNum = dutchAuction.state?.seq; - if (seqNum === undefined) return null; + if (seqNum === undefined) { + return null; + } const auctionEnded = (!!seqNum && seqNum > 0n) || (!!fullSyncHeight && fullSyncHeight >= description.endHeight); diff --git a/packages/ui/components/ui/tx/index.tsx b/packages/ui/components/ui/tx/index.tsx index a5613974..d8ef12df 100644 --- a/packages/ui/components/ui/tx/index.tsx +++ b/packages/ui/components/ui/tx/index.tsx @@ -7,8 +7,12 @@ import { ValueView } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core import { ValueViewComponent } from '../value'; export const TransactionViewComponent = ({ txv }: { txv: TransactionView }) => { - if (!txv.bodyView) throw new Error('transaction view missing body view'); - if (!txv.bodyView.transactionParameters?.fee?.amount) throw new Error('Missing fee amount'); + if (!txv.bodyView) { + throw new Error('transaction view missing body view'); + } + if (!txv.bodyView.transactionParameters?.fee?.amount) { + throw new Error('Missing fee amount'); + } // Request the fee 'Metadata' and construct a 'ValueView' object const chainId = txv.bodyView.transactionParameters.chainId; diff --git a/packages/ui/components/ui/value/index.tsx b/packages/ui/components/ui/value/index.tsx index e7aa98c6..6ec9e95a 100644 --- a/packages/ui/components/ui/value/index.tsx +++ b/packages/ui/components/ui/value/index.tsx @@ -19,7 +19,9 @@ export const ValueViewComponent = ({ showIcon = true, size = 'default', }: ValueViewProps) => { - if (!view) return null; + if (!view) { + return null; + } const formattedAmount = getFormattedAmtFromValueView(view, true); diff --git a/packages/ui/lib/toast/toast.ts b/packages/ui/lib/toast/toast.ts index 8c21d742..a048758d 100644 --- a/packages/ui/lib/toast/toast.ts +++ b/packages/ui/lib/toast/toast.ts @@ -145,8 +145,11 @@ export class Toast { * always be rendered inside a button. */ action(label?: ReactNode, onClick?: (event: React.MouseEvent) => void): this { - if (typeof label === 'undefined') this._action = undefined; - else this._action = { label, onClick: onClick ?? noOp }; + if (typeof label === 'undefined') { + this._action = undefined; + } else { + this._action = { label, onClick: onClick ?? noOp }; + } return this; } diff --git a/packages/ui/lib/toast/transaction-toast.tsx b/packages/ui/lib/toast/transaction-toast.tsx index 1820323c..d6a33f48 100644 --- a/packages/ui/lib/toast/transaction-toast.tsx +++ b/packages/ui/lib/toast/transaction-toast.tsx @@ -15,15 +15,16 @@ type BroadcastStatus = BroadcastTransactionResponse['status']; type BuildStatus = (AuthorizeAndBuildResponse | WitnessAndBuildResponse)['status']; const getBroadcastStatusMessage = (label: string, status?: BroadcastStatus) => { - if (status?.case === 'broadcastSuccess' || status?.case === 'confirmed') + if (status?.case === 'broadcastSuccess' || status?.case === 'confirmed') { return 'Waiting for confirmation'; + } return `Emitting ${label} transaction`; }; const getBuildStatusDescription = ( status?: Exclude, ): ReactNode | undefined => { - if (status?.case === 'buildProgress') + if (status?.case === 'buildProgress') { return (
); - if (status?.case === 'complete') + } + if (status?.case === 'complete') { return (
); + } return undefined; }; @@ -123,10 +126,11 @@ export class TransactionToast { */ detectionHeight?: bigint, ): void { - if (!this._txHash) + if (!this._txHash) { throw new Error( 'You called TransactionToast.onSuccess() without first calling `TransactionToast.txHash()`. You must first call `TransactionToast.txHash()` with the transaction hash, so that the success toast can construct a link to the transaction.', ); + } this.toast .success()