updatePoolTokenMetadata static method

Future<List<TransactionInstruction>> updatePoolTokenMetadata({
  1. required SolanaRPC rpc,
  2. required SolAddress stakePoolAddress,
  3. required String name,
  4. required String symbol,
  5. required String uri,
})

Creates instructions required to update pool token metadata.

Implementation

static Future<List<TransactionInstruction>> updatePoolTokenMetadata({
  required SolanaRPC rpc,
  required SolAddress stakePoolAddress,
  required String name,
  required String symbol,
  required String uri,
}) async {
  final stakePool = await rpc
      .request(SolanaRPCGetStakePoolAccount(address: stakePoolAddress));
  if (stakePool == null) {
    throw MessageException("Stake pool account does not found.");
  }

  final withdrawAuthority =
      StakePoolProgramUtils.findWithdrawAuthorityProgramAddress(
          stakePoolAddress: stakePoolAddress);

  final tokenMetadata = StakePoolProgramUtils.findMetadataAddress(
      stakePoolMintAddress: stakePool.poolMint);

  final instructions = <TransactionInstruction>[];
  instructions.add(
    StakePoolProgram.updateTokenMetadata(
        stakePool: stakePoolAddress,
        manager: stakePool.manager,
        tokenMetadata: tokenMetadata.address,
        withdrawAuthority: withdrawAuthority.address,
        layout: StakePoolUpdateTokenMetaDataLayout(
            name: name, uri: uri, symbol: symbol)),
  );

  return instructions;
}