createVerifiedTwitterRegistry static method

Future<List<TransactionInstruction>> createVerifiedTwitterRegistry({
  1. required SolanaRPC rpc,
  2. required String twitterHandle,
  3. required SolAddress verifiedPubkey,
  4. required int space,
  5. required SolAddress payerKey,
})

Signed by the authority, the payer and the verified pubkey

Implementation

static Future<List<TransactionInstruction>> createVerifiedTwitterRegistry({
  required SolanaRPC rpc,
  required String twitterHandle,
  required SolAddress verifiedPubkey,
  required int space,
  required SolAddress payerKey,
}) async {
  final hashedTwitterHandle =
      NameServiceProgramUtils.getHashedName(twitterHandle);
  final twitterHandleRegistryKey =
      NameServiceProgramUtils.getNameAccountProgram(
    hashedName: hashedTwitterHandle,
    nameParent: NameServiceProgramConst.twitterRootPrentRegisteryKey,
  );

  List<TransactionInstruction> instructions = [
    NameServiceProgram.create(
      nameKey: twitterHandleRegistryKey,
      nameOwnerKey: verifiedPubkey,
      payerKey: payerKey,
      layout: NameServiceCreateLayout(
          lamports: await rpc.request(
              SolanaRPCGetMinimumBalanceForRentExemption(size: space)),
          hashedName: hashedTwitterHandle,
          space: space),
      nameParent: NameServiceProgramConst.twitterRootPrentRegisteryKey,
      nameParentOwner: NameServiceProgramConst.twitterVerificationAuthority,
    ),
  ];

  instructions.addAll(await createReverseTwitterRegistry(
    rpc: rpc,
    twitterHandle: twitterHandle,
    twitterRegistryKey: twitterHandleRegistryKey,
    verifiedPubkey: verifiedPubkey,
    payerKey: payerKey,
  ));

  return instructions;
}