Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a few miscellaneous libs references #10715

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useContext, useEffect, useState } from 'react'

import { useAudiusQueryContext } from '@audius/common/audius-query'
import { Name } from '@audius/common/models'
import { accountSelectors } from '@audius/common/store'
import { Nullable, shortenSPLAddress } from '@audius/common/utils'
Expand All @@ -9,7 +10,6 @@ import pkg from 'bs58'
import { make, useRecord } from 'common/store/analytics/actions'
import { ToastContext } from 'components/toast/ToastContext'
import { useIsMobile } from 'hooks/useIsMobile'
import { waitForLibsInit } from 'services/audius-backend/eagerLoadUtils'
import { copyToClipboard } from 'utils/clipboardUtil'
import { useSelector } from 'utils/reducer'

Expand Down Expand Up @@ -91,23 +91,18 @@ export const AdvancedWalletDetails = () => {
const [publicKey, setPublicKey] = useState<Nullable<string>>(null)
const [encodedPrivateKey, setEncodedPrivateKey] =
useState<Nullable<string>>(null)
const { solanaWalletService } = useAudiusQueryContext()

useEffect(() => {
const fetchKeypair = async () => {
await waitForLibsInit()
const libs = window.audiusLibs
const privateKey = libs.Account?.hedgehog?.wallet?.getPrivateKey()
if (privateKey) {
const keypair =
libs.solanaWeb3Manager?.solanaWeb3?.Keypair?.fromSeed(privateKey)
if (keypair) {
setPublicKey(keypair.publicKey.toString())
setEncodedPrivateKey(pkg.encode(keypair.secretKey))
}
const keypair = await solanaWalletService.getKeypair()
if (keypair) {
setPublicKey(keypair.publicKey.toString())
setEncodedPrivateKey(pkg.encode(keypair.secretKey))
}
}
fetchKeypair()
}, [])
}, [solanaWalletService])

if (!publicKey || !encodedPrivateKey) {
return null
Expand Down
5 changes: 2 additions & 3 deletions packages/web/src/services/audius-backend/BuyAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
TransactionInstruction
} from '@solana/web3.js'

import { getLibs } from 'services/audius-libs'
import { env } from 'services/env'
import { getSolanaConnection } from 'services/solana/solana'

import { audiusBackendInstance } from './audius-backend-instance'
Expand Down Expand Up @@ -210,8 +210,7 @@ export const createTransferToUserBankTransaction = async ({
amount: bigint
memo: string
}) => {
const libs = await getLibs()
const mintPublicKey = new PublicKey(libs.solanaWeb3Config.mintAddress)
const mintPublicKey = new PublicKey(env.WAUDIO_MINT_ADDRESS)
const associatedTokenAccount = await getAudioAccount({
rootAccount: fromAccount
})
Expand Down
17 changes: 1 addition & 16 deletions packages/web/src/services/solana/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { DEFAULT_MINT, MintName } from '@audius/common/services'
import {
Account,
getMinimumBalanceForRentExemptAccount,
getAccount,
getAssociatedTokenAddressSync
getAccount
} from '@solana/spl-token'
import { PublicKey, Transaction } from '@solana/web3.js'

import { getLibs } from 'services/audius-libs'
import { audiusSdk } from 'services/audius-sdk'

export const ROOT_ACCOUNT_SIZE = 0 // Root account takes 0 bytes, but still pays rent!
Expand Down Expand Up @@ -119,19 +117,6 @@ export const getAssociatedTokenAccountRent = async () => {
return await getMinimumBalanceForRentExemptAccount(connection)
}

/**
* Returns the associated USDC token account for the given solana account.
*/
export const getUSDCAssociatedTokenAccount = async (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't referenced anywhere so I just removed it

solanaRootAccountPubkey: PublicKey
) => {
const libs = await getLibs()
return getAssociatedTokenAddressSync(
libs.solanaWeb3Manager!.mints.usdc,
solanaRootAccountPubkey
)
}

/**
* Returns the owner of the token acccount, if the provided account
* is a token account. Otherwise, just returns the account
Expand Down