-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solana get account info to replace shyft
- Loading branch information
1 parent
d3f407d
commit c9d3ce4
Showing
2 changed files
with
24 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters