Skip to content

Commit 5db3597

Browse files
committed
fix(xc-admin-frontend): fixed build
1 parent 3594fa0 commit 5db3597

File tree

26 files changed

+327
-321
lines changed

26 files changed

+327
-321
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "*next-seo.config.js";

governance/xc_admin/packages/xc_admin_frontend/components/ClusterSwitch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
33
import { Fragment, useCallback, useContext, useEffect } from 'react'
44
import { ClusterContext, DEFAULT_CLUSTER } from '../contexts/ClusterContext'
55
import Arrow from '@images/icons/down.inline.svg'
6-
import { PythCluster } from '@pythnetwork/client'
6+
import type { PythCluster } from '@pythnetwork/client'
77

88
const ClusterSwitch = ({ light }: { light?: boolean | null }) => {
99
const router = useRouter()

governance/xc_admin/packages/xc_admin_frontend/components/InstructionViews/WormholeInstructionView.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
EvmUpgradeContract,
77
ExecutePostedVaa,
88
MultisigParser,
9-
PythGovernanceAction,
9+
type PythGovernanceAction,
1010
RequestGovernanceDataSourceTransfer,
1111
SetDataSources,
1212
SetFee,
@@ -15,13 +15,13 @@ import {
1515
WormholeMultisigInstruction,
1616
getProgramName,
1717
} from '@pythnetwork/xc-admin-common'
18-
import { AccountMeta, PublicKey } from '@solana/web3.js'
18+
import { type AccountMeta, PublicKey } from '@solana/web3.js'
1919
import type { ReactNode } from 'react'
2020
import CopyText from '../common/CopyText'
2121
import { ParsedAccountPubkeyRow, SignerTag, WritableTag } from './AccountUtils'
2222
import { usePythContext } from '../../contexts/PythContext'
2323
import { getMappingCluster, isPubkey } from './utils'
24-
import { PythCluster } from '@pythnetwork/client'
24+
import type { PythCluster } from '@pythnetwork/client'
2525
import { lamportsToSol } from '../../utils/lamportsToSol'
2626
import { parseEvmExecuteCallData } from '../../utils/parseEvmExecuteCallData'
2727

@@ -149,7 +149,7 @@ export const WormholeInstructionView = ({
149149
)}
150150
</div>
151151
{key === 'pub' &&
152-
parsedInstruction.args[key].toBase58() in
152+
publisherKeyToNameMappingCluster && parsedInstruction.args[key].toBase58() in
153153
publisherKeyToNameMappingCluster ? (
154154
<ParsedAccountPubkeyRow
155155
key={`${index}_${parsedInstruction.args[
@@ -192,46 +192,46 @@ export const WormholeInstructionView = ({
192192
<div className="space-y-2 sm:flex sm:space-y-0 sm:space-x-2">
193193
<div className="flex items-center space-x-2 sm:ml-2">
194194
{parsedInstruction.accounts.named[key]
195-
.isSigner ? (
195+
?.isSigner ? (
196196
<SignerTag />
197197
) : null}
198198
{parsedInstruction.accounts.named[key]
199-
.isWritable ? (
199+
?.isWritable ? (
200200
<WritableTag />
201201
) : null}
202202
</div>
203203
<CopyText
204204
text={parsedInstruction.accounts.named[
205205
key
206-
].pubkey.toBase58()}
206+
]?.pubkey.toBase58() ?? ''}
207207
/>
208208
</div>
209209
</div>
210210
{key === 'priceAccount' &&
211211
parsedInstruction.accounts.named[
212212
key
213-
].pubkey.toBase58() in
213+
]!.pubkey.toBase58() in
214214
priceAccountKeyToSymbolMapping ? (
215215
<ParsedAccountPubkeyRow
216216
key="priceAccountPubkey"
217217
mapping={priceAccountKeyToSymbolMapping}
218218
title="symbol"
219219
pubkey={parsedInstruction.accounts.named[
220220
key
221-
].pubkey.toBase58()}
221+
]?.pubkey.toBase58() ?? ''}
222222
/>
223223
) : key === 'productAccount' &&
224224
parsedInstruction.accounts.named[
225225
key
226-
].pubkey.toBase58() in
226+
]!.pubkey.toBase58() in
227227
productAccountKeyToSymbolMapping ? (
228228
<ParsedAccountPubkeyRow
229229
key="productAccountPubkey"
230230
mapping={productAccountKeyToSymbolMapping}
231231
title="symbol"
232232
pubkey={parsedInstruction.accounts.named[
233233
key
234-
].pubkey.toBase58()}
234+
]?.pubkey.toBase58() ?? ''}
235235
/>
236236
) : null}
237237
</>
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { PublicKey } from '@solana/web3.js'
1+
import { PublicKey } from "@solana/web3.js";
22

3-
export const getMappingCluster = (cluster: string) => {
4-
if (cluster === 'mainnet-beta' || cluster === 'pythnet') {
5-
return 'pythnet'
3+
export const getMappingCluster = (cluster: string | undefined) => {
4+
if (cluster === "mainnet-beta" || cluster === "pythnet") {
5+
return "pythnet";
66
} else {
7-
return 'pythtest'
7+
return "pythtest";
88
}
9-
}
9+
};
1010

1111
// check if a string is a pubkey
1212
export const isPubkey = (str: string) => {
1313
try {
14-
new PublicKey(str)
15-
return true
14+
new PublicKey(str);
15+
return true;
1616
} catch (e) {
17-
return false
17+
return false;
1818
}
19-
}
19+
};

governance/xc_admin/packages/xc_admin_frontend/components/PermissionDepermissionKey.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Program } from '@coral-xyz/anchor'
22
import { Dialog, Menu, Transition } from '@headlessui/react'
3-
import { PythOracle } from '@pythnetwork/client/lib/anchor'
3+
import type { PythOracle } from '@pythnetwork/client/lib/anchor'
44
import * as Label from '@radix-ui/react-label'
55
import { PublicKey, TransactionInstruction } from '@solana/web3.js'
66
import SquadsMesh from '@sqds/mesh'
@@ -18,7 +18,7 @@ import {
1818
} from '@pythnetwork/xc-admin-common'
1919
import { ClusterContext } from '../contexts/ClusterContext'
2020
import { usePythContext } from '../contexts/PythContext'
21-
import { ProductRawConfig } from '../hooks/usePyth'
21+
import type { ProductRawConfig } from '../hooks/usePyth'
2222
import Arrow from '@images/icons/down.inline.svg'
2323
import { capitalizeFirstLetter } from '../utils/capitalizeFirstLetter'
2424
import Spinner from './common/Spinner'

governance/xc_admin/packages/xc_admin_frontend/components/common/Modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Dialog, Transition } from '@headlessui/react'
2-
import { Dispatch, Fragment, SetStateAction } from 'react'
2+
import { type Dispatch, Fragment, type SetStateAction } from 'react'
33
import CloseIcon from '../icons/CloseIcon'
44

55
const Modal: React.FC<{

governance/xc_admin/packages/xc_admin_frontend/components/layout/MobileMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Link from 'next/link'
44
import { useRouter } from 'next/router'
55
import { useContext, useEffect, useRef } from 'react'
66
import { ClusterContext, DEFAULT_CLUSTER } from '../../contexts/ClusterContext'
7-
import { BurgerState } from './Header'
7+
import type { BurgerState } from './Header'
88

99
import orb from '@images/burger.png'
1010

governance/xc_admin/packages/xc_admin_frontend/components/programs/PythCore.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { AnchorProvider, Idl, Program } from '@coral-xyz/anchor'
1+
import { AnchorProvider, type Idl, Program } from '@coral-xyz/anchor'
22
import { getPythProgramKeyForCluster } from '@pythnetwork/client'
3-
import { PythOracle, pythOracleProgram } from '@pythnetwork/client/lib/anchor'
3+
import { type PythOracle, pythOracleProgram } from '@pythnetwork/client/lib/anchor'
44
import { PublicKey } from '@solana/web3.js'
55
import messageBuffer from 'message_buffer/idl/message_buffer.json'
6-
import { MessageBuffer } from 'message_buffer/idl/message_buffer'
6+
import type { MessageBuffer } from 'message_buffer/idl/message_buffer'
77
import axios from 'axios'
88
import { useContext, useEffect, useState } from 'react'
99
import toast from 'react-hot-toast'
@@ -18,9 +18,9 @@ import {
1818
ProgramType,
1919
validateUploadedConfig,
2020
generateInstructions,
21-
DownloadableConfig,
22-
DownloadableProduct,
23-
DownloadablePriceAccount,
21+
type DownloadableConfig,
22+
type DownloadableProduct,
23+
type DownloadablePriceAccount,
2424
} from '@pythnetwork/xc-admin-common'
2525
import { ClusterContext } from '../../contexts/ClusterContext'
2626
import { useMultisigContext } from '../../contexts/MultisigContext'
@@ -31,7 +31,7 @@ import Modal from '../common/Modal'
3131
import Spinner from '../common/Spinner'
3232
import Loadbar from '../loaders/Loadbar'
3333
import PermissionDepermissionKey from '../PermissionDepermissionKey'
34-
import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider'
34+
import type { Wallet } from '@coral-xyz/anchor/dist/cjs/provider'
3535

3636
interface PriceAccountMetadata extends DownloadablePriceAccount {
3737
[key: string]: string | string[] | number

governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/InstructionsSummary.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Listbox, Transition } from '@headlessui/react'
2-
import { PythCluster } from '@pythnetwork/client'
3-
import { MultisigInstruction } from '@pythnetwork/xc-admin-common'
2+
import type { PythCluster } from '@pythnetwork/client'
3+
import type { MultisigInstruction } from '@pythnetwork/xc-admin-common'
44
import { getInstructionsSummary } from './utils'
55
import { getMappingCluster } from '../../InstructionViews/utils'
66
import CopyText from '../../common/CopyText'
@@ -14,10 +14,10 @@ export const InstructionsSummary = ({
1414
cluster,
1515
}: {
1616
instructions: MultisigInstruction[]
17-
cluster: PythCluster
17+
cluster: PythCluster | undefined;
1818
}) => (
1919
<div className="space-y-4">
20-
{getInstructionsSummary({ instructions, cluster }).map((instruction) => (
20+
{cluster && getInstructionsSummary({ instructions, cluster }).map((instruction) => (
2121
<SummaryItem instruction={instruction} key={instruction.name} />
2222
))}
2323
</div>
@@ -113,7 +113,7 @@ const AddRemovePublisherDetails = ({
113113
<KeyAndName
114114
mapping={
115115
groupBy === 'publisher'
116-
? publisherKeyToName
116+
? publisherKeyToName ?? {}
117117
: priceAccountKeyToSymbolMapping
118118
}
119119
>
@@ -127,7 +127,7 @@ const AddRemovePublisherDetails = ({
127127
mapping={
128128
groupBy === 'publisher'
129129
? priceAccountKeyToSymbolMapping
130-
: publisherKeyToName
130+
: publisherKeyToName ?? {}
131131
}
132132
>
133133
{groupBy === 'publisher'

governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useWallet } from '@solana/wallet-adapter-react'
22
import {
3-
AccountMeta,
3+
type AccountMeta,
44
PublicKey,
55
SystemProgram,
66
TransactionInstruction,
77
} from '@solana/web3.js'
88
import SquadsMesh from '@sqds/mesh'
9-
import { MultisigAccount, TransactionAccount } from '@sqds/mesh/lib/types'
9+
import type { MultisigAccount, TransactionAccount } from '@sqds/mesh/lib/types'
1010
import {
1111
type ReactNode,
1212
Fragment,
@@ -18,7 +18,7 @@ import toast from 'react-hot-toast'
1818
import {
1919
AnchorMultisigInstruction,
2020
ExecutePostedVaa,
21-
MultisigInstruction,
21+
type MultisigInstruction,
2222
MultisigParser,
2323
PythMultisigInstruction,
2424
WormholeMultisigInstruction,
@@ -41,7 +41,7 @@ import Spinner from '../../common/Spinner'
4141
import Loadbar from '../../loaders/Loadbar'
4242

4343
import { Wallet } from '@coral-xyz/anchor'
44-
import { PythCluster, getPythProgramKeyForCluster } from '@pythnetwork/client'
44+
import { type PythCluster, getPythProgramKeyForCluster } from '@pythnetwork/client'
4545
import { TransactionBuilder, sendTransactions } from '@pythnetwork/solana-utils'
4646
import { getMappingCluster, isPubkey } from '../../InstructionViews/utils'
4747
import { StatusTag } from './StatusTag'
@@ -207,9 +207,9 @@ export const Proposal = ({
207207
ix.name === 'postMessage' &&
208208
ix.governanceAction instanceof ExecutePostedVaa &&
209209
ix.governanceAction.instructions.every((remoteIx) => {
210-
const innerMultisigParser = MultisigParser.fromCluster(cluster)
210+
const innerMultisigParser = cluster ? MultisigParser.fromCluster(cluster) : undefined;
211211
const parsedRemoteInstruction =
212-
innerMultisigParser.parseInstruction({
212+
innerMultisigParser?.parseInstruction({
213213
programId: remoteIx.programId,
214214
data: remoteIx.data as Buffer,
215215
keys: remoteIx.keys as AccountMeta[],
@@ -242,16 +242,16 @@ export const Proposal = ({
242242
const proposalInstructions = (
243243
await getManyProposalsInstructions(readOnlySquads, [proposal])
244244
)[0]
245-
const multisigParser = MultisigParser.fromCluster(
245+
const multisigParser = cluster ? MultisigParser.fromCluster(
246246
getMultisigCluster(cluster)
247-
)
248-
const parsedInstructions = proposalInstructions.map((ix) =>
249-
multisigParser.parseInstruction({
247+
) : undefined;
248+
const parsedInstructions = (proposalInstructions?.map((ix) =>
249+
multisigParser?.parseInstruction({
250250
programId: ix.programId,
251251
data: ix.data as Buffer,
252252
keys: ix.keys as AccountMeta[],
253253
})
254-
)
254+
) ?? []).filter((instruction): instruction is MultisigInstruction => Boolean(instruction));
255255
if (!isCancelled) setInstructions(parsedInstructions)
256256
} else {
257257
if (!isCancelled) setInstructions([])
@@ -339,7 +339,7 @@ export const Proposal = ({
339339
await handleClick(
340340
async (
341341
squad: SquadsMesh,
342-
vaultKey: PublicKey,
342+
_: PublicKey,
343343
proposalKey: PublicKey
344344
): Promise<TransactionInstruction> => {
345345
return await squad.buildExecuteTransaction(proposalKey)
@@ -558,7 +558,7 @@ export const Proposal = ({
558558
)}
559559
</div>
560560
{key === 'pub' &&
561-
instruction.args[key].toBase58() in
561+
publisherKeyToNameMappingCluster && instruction.args[key].toBase58() in
562562
publisherKeyToNameMappingCluster ? (
563563
<ParsedAccountPubkeyRow
564564
key={`${index}_${instruction.args[key].toBase58()}`}
@@ -575,7 +575,7 @@ export const Proposal = ({
575575
)}
576576
</div>
577577
)}
578-
{instruction instanceof WormholeMultisigInstruction && (
578+
{cluster && instruction instanceof WormholeMultisigInstruction && (
579579
<WormholeInstructionView
580580
cluster={cluster}
581581
instruction={instruction}
@@ -605,41 +605,41 @@ export const Proposal = ({
605605
</div>
606606
<div className="space-y-2 sm:flex sm:space-y-0 sm:space-x-2">
607607
<div className="flex items-center space-x-2 sm:ml-2">
608-
{instruction.accounts.named[key].isSigner ? (
608+
{instruction.accounts.named[key]?.isSigner ? (
609609
<SignerTag />
610610
) : null}
611-
{instruction.accounts.named[key].isWritable ? (
611+
{instruction.accounts.named[key]?.isWritable ? (
612612
<WritableTag />
613613
) : null}
614614
</div>
615615
<CopyText
616616
text={instruction.accounts.named[
617617
key
618-
].pubkey.toBase58()}
618+
]?.pubkey.toBase58() ?? ''}
619619
/>
620620
</div>
621621
</div>
622622
{key === 'priceAccount' &&
623-
instruction.accounts.named[key].pubkey.toBase58() in
623+
instruction.accounts.named[key]!.pubkey.toBase58() in
624624
priceAccountKeyToSymbolMapping ? (
625625
<ParsedAccountPubkeyRow
626626
key="priceAccountPubkey"
627627
mapping={priceAccountKeyToSymbolMapping}
628628
title="symbol"
629629
pubkey={instruction.accounts.named[
630630
key
631-
].pubkey.toBase58()}
631+
]?.pubkey.toBase58() ?? ''}
632632
/>
633633
) : key === 'productAccount' &&
634-
instruction.accounts.named[key].pubkey.toBase58() in
634+
instruction.accounts.named[key]!.pubkey.toBase58() in
635635
productAccountKeyToSymbolMapping ? (
636636
<ParsedAccountPubkeyRow
637637
key="productAccountPubkey"
638638
mapping={productAccountKeyToSymbolMapping}
639639
title="symbol"
640640
pubkey={instruction.accounts.named[
641641
key
642-
].pubkey.toBase58()}
642+
]?.pubkey.toBase58() ?? ''}
643643
/>
644644
) : null}
645645
</>

0 commit comments

Comments
 (0)