Skip to content

Commit

Permalink
remove a few miscellaneous libs references
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra committed Dec 13, 2024
1 parent b2b8eb7 commit f32f52b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
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 (
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

0 comments on commit f32f52b

Please sign in to comment.