Skip to content

Commit

Permalink
solana get account info to replace shyft
Browse files Browse the repository at this point in the history
  • Loading branch information
shan57blocks committed Nov 1, 2024
1 parent d3f407d commit c9d3ce4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 23 additions & 7 deletions packages/huma-shared/src/solana/utils/accountUtils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
import { AnchorProvider, Program } from '@coral-xyz/anchor'
import { Connection, PublicKey } from '@solana/web3.js'
import { Connection } from '@solana/web3.js'
import { POOL_NAME } from '../../utils'
import { SolanaChainEnum } from '../chain'
import { Huma as HumaProgram } from '../idl/huma'
import HumaIDL from '../idl/huma.json'
import { getSolanaPoolInfo } from './programUtils'

export const getHumaConfigAccountInfo = async (
_chainId: SolanaChainEnum,
export const getPoolAccountInfos = async (
chainId: SolanaChainEnum,
poolName: POOL_NAME,
connection: Connection,
) => {
const poolInfo = getSolanaPoolInfo(chainId, poolName)

if (!poolInfo) {
return null
}

// @ts-ignore
const provider = new AnchorProvider(connection, null)
const humaProgram = new Program<HumaProgram>(HumaIDL as HumaProgram, provider)

const humaConfigAccountResult = await humaProgram.account.humaConfig.fetch(
new PublicKey('F2it2fBcdjeX9KCaEAWcQ1H8LnMB2zPn3nrPpHc7J8vL'),
)
const [humaConfigAccount, poolConfigAccount, poolStateAccount] =
await Promise.all([
humaProgram.account.humaConfig.fetch(poolInfo.humaConfig),
humaProgram.account.poolConfig.fetch(poolInfo.poolConfig),
humaProgram.account.poolState.fetch(poolInfo.poolState),
])

console.log('humaConfigAccountResult', humaConfigAccountResult)
return {
humaConfigAccount,
poolConfigAccount,
poolStateAccount,
}
}
2 changes: 1 addition & 1 deletion packages/huma-shared/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const checkIsDev = () =>
!process.env.REACT_APP_FORCE_IS_DEV_FALSE &&
process.env.REACT_APP_FORCE_IS_DEV_FALSE !== 'true' &&
!!(
window.location.hostname.startsWith('dev') ||
window.location.hostname.startsWith('v2') ||
Expand Down

0 comments on commit c9d3ce4

Please sign in to comment.