assertIsKeyPairSigner function

void assertIsKeyPairSigner(
  1. Object? value
)

Asserts that the provided value implements the KeyPairSigner interface.

Throws a SolanaError with code SolanaErrorCode.signerExpectedKeyPairSigner if the check fails.

Implementation

void assertIsKeyPairSigner(Object? value) {
  if (!isKeyPairSigner(value)) {
    final address = switch (value) {
      MessagePartialSigner(:final address) => address,
      TransactionPartialSigner(:final address) => address,
      _ => null,
    };
    throw SolanaError(SolanaErrorCode.signerExpectedKeyPairSigner, {
      'address': ?address,
    });
  }
}