From 5324366b6259401c4a6cce552de5276fdeae9dc2 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 27 Nov 2024 15:25:44 -0800 Subject: [PATCH 1/3] Add back function that was supposed to be deprecated --- src/bcs/deserializer.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bcs/deserializer.ts b/src/bcs/deserializer.ts index 78d0f2cb7..85e6bb81f 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,24 @@ export class Deserializer { return textDecoder.decode(value); } + /** + * @deprecated use `deserializeOption` 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 { + const exists = this.deserializeBool(); + return exists ? this.deserializeStr() : undefined; + } + /** * Deserializes an optional value from the buffer. * From 6029901029b7d8b4dd8029bba8676dc62ea476dd Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 27 Nov 2024 15:29:23 -0800 Subject: [PATCH 2/3] update deprecated comment --- src/bcs/deserializer.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bcs/deserializer.ts b/src/bcs/deserializer.ts index 85e6bb81f..da4c55439 100644 --- a/src/bcs/deserializer.ts +++ b/src/bcs/deserializer.ts @@ -101,7 +101,7 @@ export class Deserializer { } /** - * @deprecated use `deserializeOption` instead. + * @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. @@ -114,8 +114,7 @@ export class Deserializer { * ``` */ deserializeOptionStr(): string | undefined { - const exists = this.deserializeBool(); - return exists ? this.deserializeStr() : undefined; + return this.deserializeOption("string"); } /** From 62e8289372def882ad1634fc27e4082837db4edb Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 28 Nov 2024 07:59:44 -0800 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7200a4876..e13bb8ddb 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)