updatePoolTokenMetadata static method
Future<List<TransactionInstruction> >
updatePoolTokenMetadata({
- required SolanaRPC rpc,
- required SolAddress stakePoolAddress,
- required String name,
- required String symbol,
- 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 const 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;
}