From 401ee0e9f71fac17f6f8cf7444a07d4e3f2d38c9 Mon Sep 17 00:00:00 2001 From: Oliver He Date: Thu, 28 Nov 2024 17:39:11 -0500 Subject: [PATCH] Add back accidentally deleted deserializeOptionStr and mark deprecated (#597) * Add back function that was supposed to be deprecated * update deprecated comment * update changelog --- CHANGELOG.md | 1 + src/bcs/deserializer.ts | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f48527d6a..f0c356cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T - Add `gasProfile` function to `Move` class to allow for gas profiling of Aptos Move functions - `PrivateKey.formatPrivateKey` now supports formatting AIP-80 strings - Removed strictness warnings for bytes AIP-80 private key parsing formatting. +- Add accidentally deleted `deserializeOptionStr` and mark deprecated to unbreak Wallet Adapter # 1.33.0 (2024-11-13) diff --git a/src/bcs/deserializer.ts b/src/bcs/deserializer.ts index 78d0f2cb7..da4c55439 100644 --- a/src/bcs/deserializer.ts +++ b/src/bcs/deserializer.ts @@ -82,7 +82,6 @@ export class Deserializer { } /** - * @deprecated use `deserializeOption` instead. * Deserializes a UTF-8 encoded string from a byte array. It first reads the length of the string in bytes, * followed by the actual byte content, and decodes it into a string. * @@ -101,6 +100,23 @@ export class Deserializer { return textDecoder.decode(value); } + /** + * @deprecated use `deserializeOption("string")` instead. + * + * The BCS layout for Optional is 0 if none, else 1 followed by the string length and string content. + * @returns The deserialized string if it exists, otherwise undefined. + * @example + * ```typescript + * const deserializer = new Deserializer(new Uint8Array([0x00])); + * assert(deserializer.deserializeOptionStr() === undefined); + * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100])); + * assert(deserializer.deserializeOptionStr() === "1234abcd"); + * ``` + */ + deserializeOptionStr(): string | undefined { + return this.deserializeOption("string"); + } + /** * Deserializes an optional value from the buffer. *