From d3f407d90c3ff02eb9c21e7eb174dd8210a7ab9f Mon Sep 17 00:00:00 2001 From: shan Date: Wed, 30 Oct 2024 09:49:28 +0800 Subject: [PATCH] solana get account info --- .../src/solana/utils/accountUtils.ts | 20 +++++++++++++++++++ .../huma-shared/src/solana/utils/index.ts | 1 + 2 files changed, 21 insertions(+) create mode 100644 packages/huma-shared/src/solana/utils/accountUtils.ts diff --git a/packages/huma-shared/src/solana/utils/accountUtils.ts b/packages/huma-shared/src/solana/utils/accountUtils.ts new file mode 100644 index 00000000..4af3e675 --- /dev/null +++ b/packages/huma-shared/src/solana/utils/accountUtils.ts @@ -0,0 +1,20 @@ +import { AnchorProvider, Program } from '@coral-xyz/anchor' +import { Connection, PublicKey } from '@solana/web3.js' +import { SolanaChainEnum } from '../chain' +import { Huma as HumaProgram } from '../idl/huma' +import HumaIDL from '../idl/huma.json' + +export const getHumaConfigAccountInfo = async ( + _chainId: SolanaChainEnum, + connection: Connection, +) => { + // @ts-ignore + const provider = new AnchorProvider(connection, null) + const humaProgram = new Program(HumaIDL as HumaProgram, provider) + + const humaConfigAccountResult = await humaProgram.account.humaConfig.fetch( + new PublicKey('F2it2fBcdjeX9KCaEAWcQ1H8LnMB2zPn3nrPpHc7J8vL'), + ) + + console.log('humaConfigAccountResult', humaConfigAccountResult) +} diff --git a/packages/huma-shared/src/solana/utils/index.ts b/packages/huma-shared/src/solana/utils/index.ts index 85f1c4dd..122df84e 100644 --- a/packages/huma-shared/src/solana/utils/index.ts +++ b/packages/huma-shared/src/solana/utils/index.ts @@ -1,3 +1,4 @@ +export * from './accountUtils' export * from './poolUtils' export * from './programUtils' export * from './siwsUtils'