Skip to content

Commit 479a2d8

Browse files
authored
Make proposer server url a serverside prop (#840)
* Make proposer server url a serverside prop * Make low caps
1 parent 4072520 commit 479a2d8

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

governance/xc_admin/packages/proposer_server/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { getPythClusterApiUrl, PythCluster } from "@pythnetwork/client";
2020
import SquadsMesh from "@sqds/mesh";
2121
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
2222

23-
const PORT: number = Number(process.env.PORT ?? "3000");
23+
const PORT: number = Number(process.env.PORT ?? "4000");
2424
const KEYPAIR: Keypair = Keypair.fromSecretKey(
2525
Uint8Array.from(JSON.parse(fs.readFileSync(envOrErr("WALLET"), "ascii")))
2626
);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ const PermissionDepermissionKey = ({
3131
isPermission,
3232
pythProgramClient,
3333
squads,
34+
proposerServerUrl,
3435
}: {
3536
isPermission: boolean
3637
pythProgramClient?: Program<PythOracle>
3738
squads?: SquadsMesh
39+
proposerServerUrl: string
3840
}) => {
3941
const [publisherKey, setPublisherKey] = useState(
4042
'JTmFx5zX9mM94itfk2nQcJnQQDPjcv4UPD7SYj6xDCV'
@@ -104,10 +106,10 @@ const PermissionDepermissionKey = ({
104106
}
105107
setIsSubmitButtonLoading(true)
106108
try {
107-
const response = await axios.post(
108-
process.env.NEXT_PUBLIC_PROPOSER_SERVER_URL + '/api/propose',
109-
{ instructions, cluster }
110-
)
109+
const response = await axios.post(proposerServerUrl + '/api/propose', {
110+
instructions,
111+
cluster,
112+
})
111113
const { proposalPubkey } = response.data
112114
toast.success(`Proposal sent! 🚀 Proposal Pubkey: ${proposalPubkey}`)
113115
setIsSubmitButtonLoading(false)

governance/xc_admin/packages/xc_admin_frontend/components/tabs/General.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Spinner from '../common/Spinner'
2525
import Loadbar from '../loaders/Loadbar'
2626
import PermissionDepermissionKey from '../PermissionDepermissionKey'
2727

28-
const General = () => {
28+
const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
2929
const [data, setData] = useState<any>({})
3030
const [dataChanges, setDataChanges] = useState<Record<string, any>>()
3131
const [existingSymbols, setExistingSymbols] = useState<Set<string>>(new Set())
@@ -465,10 +465,10 @@ const General = () => {
465465

466466
setIsSendProposalButtonLoading(true)
467467
try {
468-
const response = await axios.post(
469-
process.env.NEXT_PUBLIC_PROPOSER_SERVER_URL + '/api/propose',
470-
{ instructions, cluster }
471-
)
468+
const response = await axios.post(proposerServerUrl + '/api/propose', {
469+
instructions,
470+
cluster,
471+
})
472472
const { proposalPubkey } = response.data
473473
toast.success(`Proposal sent! 🚀 Proposal Pubkey: ${proposalPubkey}`)
474474
setIsSendProposalButtonLoading(false)
@@ -767,11 +767,13 @@ const General = () => {
767767
isPermission={true}
768768
pythProgramClient={pythProgramClient}
769769
squads={proposeSquads}
770+
proposerServerUrl={proposerServerUrl}
770771
/>
771772
<PermissionDepermissionKey
772773
isPermission={false}
773774
pythProgramClient={pythProgramClient}
774775
squads={proposeSquads}
776+
proposerServerUrl={proposerServerUrl}
775777
/>
776778
</div>
777779
<div className="relative mt-6">

governance/xc_admin/packages/xc_admin_frontend/pages/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ export const getServerSideProps: GetServerSideProps = async () => {
4646
)
4747
: {}
4848

49+
const proposerServerUrl =
50+
process.env.PROPOSER_SERVER_URL || 'http://localhost:4000'
4951
return {
5052
props: {
53+
proposerServerUrl,
5154
publisherKeyToNameMapping,
5255
multisigSignerKeyToNameMapping,
5356
},
@@ -77,7 +80,12 @@ const DEFAULT_TAB = 'general'
7780
const Home: NextPage<{
7881
publisherKeyToNameMapping: Record<string, Record<string, string>>
7982
multisigSignerKeyToNameMapping: Record<string, string>
80-
}> = ({ publisherKeyToNameMapping, multisigSignerKeyToNameMapping }) => {
83+
proposerServerUrl: string
84+
}> = ({
85+
publisherKeyToNameMapping,
86+
multisigSignerKeyToNameMapping,
87+
proposerServerUrl,
88+
}) => {
8189
const [currentTabIndex, setCurrentTabIndex] = useState(0)
8290
const tabInfoArray = Object.values(TAB_INFO)
8391
const anchorWallet = useAnchorWallet()
@@ -143,7 +151,7 @@ const Home: NextPage<{
143151
</div>
144152
{tabInfoArray[currentTabIndex].queryString ===
145153
TAB_INFO.General.queryString ? (
146-
<General />
154+
<General proposerServerUrl={proposerServerUrl} />
147155
) : tabInfoArray[currentTabIndex].queryString ===
148156
TAB_INFO.UpdatePermissions.queryString ? (
149157
<UpdatePermissions />

0 commit comments

Comments
 (0)