Przeglądaj źródła

Adds getSignatureFromBytes helper to get a Signature from a SignatureBytes (#222)

* Adds getSignatureFromBytes helper to get a Signature from a SignatureBytes

* refactor: nit

---------

Co-authored-by: nickfrosty <75431177+nickfrosty@users.noreply.github.com>
Ian Macalinao 1 miesiąc temu
rodzic
commit
8849226d15

+ 5 - 0
.changeset/curvy-news-speak.md

@@ -0,0 +1,5 @@
+---
+"gill": patch
+---
+
+Adds getSignatureFromBytes helper function

+ 11 - 0
packages/gill/src/core/get-signature-from-bytes.ts

@@ -0,0 +1,11 @@
+import type { Signature, SignatureBytes } from "@solana/kit";
+import { getBase58Decoder } from "@solana/kit";
+
+/**
+ * Converts signature bytes to a {@link Signature} string.
+ * @param sigBytes - The signature bytes to convert
+ * @returns The base58-encoded signature string
+ */
+export function getSignatureFromBytes(sigBytes: SignatureBytes): Signature {
+  return getBase58Decoder().decode(sigBytes) as Signature;
+}

+ 1 - 0
packages/gill/src/core/index.ts

@@ -9,6 +9,7 @@ export * from "./create-solana-client";
 export * from "./create-transaction";
 export * from "./explorer";
 export * from "./get-oldest-signature";
+export * from "./get-signature-from-bytes";
 export * from "./insert-reference-key";
 export * from "./keypairs-base58";
 export * from "./keypairs-extractable";