From 7d87d69ed41b6d845d9adfd88f0b8ab97413ef16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezi=C5=84ski?= Date: Wed, 28 Jun 2023 18:44:20 +0200 Subject: [PATCH 1/3] fix refresh of voting power to fresh governance account (#188) --- components/governance/GovernanceDelegate.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/governance/GovernanceDelegate.tsx b/components/governance/GovernanceDelegate.tsx index d5852bd5..d5a6a3d5 100644 --- a/components/governance/GovernanceDelegate.tsx +++ b/components/governance/GovernanceDelegate.tsx @@ -15,7 +15,6 @@ const GovernanceDelegate = () => { const connectionContext = GovernanceStore((s) => s.connectionContext) const vsrClient = GovernanceStore((s) => s.vsrClient) const getCurrentVotingPower = GovernanceStore((s) => s.getCurrentVotingPower) - const voter = GovernanceStore((s) => s.voter.tokenOwnerRecord) const [selectedDelegatePk, setSelectedDelegatePk] = useLocalStorageState( `${publicKey?.toBase58()}${GOVERNANCE_DELEGATE_KEY}` @@ -28,8 +27,7 @@ const GovernanceDelegate = () => { if ( publicKey?.toBase58() && connectionContext?.endpoint && - vsrClient?.program.programId.toBase58() && - voter + vsrClient?.program.programId.toBase58() ) { getCurrentVotingPower(publicKey, vsrClient, connectionContext) } From e5273f9620dee3c5cc226560f6102a15497ecdbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezi=C5=84ski?= Date: Wed, 28 Jun 2023 19:19:02 +0200 Subject: [PATCH 2/3] Delegate swap (#186) * allow swap button for delegate * restrict routes to jupiter only when using delegate * fix --------- Co-authored-by: saml33 --- components/swap/SwapForm.tsx | 14 ++++---------- components/swap/SwapReviewRouteInfo.tsx | 22 +++++++++++++++++++--- components/swap/useQuoteRoutes.ts | 9 +++++++-- package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/components/swap/SwapForm.tsx b/components/swap/SwapForm.tsx index 8b7e11d4..483d5667 100644 --- a/components/swap/SwapForm.tsx +++ b/components/swap/SwapForm.tsx @@ -73,7 +73,7 @@ const SwapForm = () => { const { group } = useMangoGroup() const [swapFormSizeUi] = useLocalStorageState(SIZE_INPUT_UI_KEY, 'slider') const { ipAllowed, ipCountry } = useIpAddress() - const { isUnownedAccount } = useUnownedAccount() + const { isUnownedAccount, isDelegatedAccount } = useUnownedAccount() const { margin: useMargin, @@ -87,7 +87,6 @@ const SwapForm = () => { const [debouncedAmountIn] = useDebounce(amountInFormValue, 300) const [debouncedAmountOut] = useDebounce(amountOutFormValue, 300) const { mangoAccount } = useMangoAccount() - const { isDelegatedAccount } = useUnownedAccount() const { connected, publicKey } = useWallet() const amountInAsDecimal: Decimal | null = useMemo(() => { @@ -109,6 +108,7 @@ const SwapForm = () => { slippage, swapMode, wallet: publicKey?.toBase58(), + mode: isDelegatedAccount ? 'JUPITER' : 'ALL', }) const setAmountInFormValue = useCallback( @@ -458,7 +458,6 @@ const SwapForm = () => { amountOut={ selectedRoute ? amountOutAsDecimal.toNumber() : undefined } - isDelegatedAccount={isDelegatedAccount} /> ) : (