Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back accidentally deleted deserializeOptionStr and mark deprecated #597

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 17 additions & 1 deletion src/bcs/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -101,6 +100,23 @@ export class Deserializer {
return textDecoder.decode(value);
}

/**
* @deprecated use `deserializeOption("string")` instead.
*
* The BCS layout for Optional<String> 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.
*
Expand Down
Loading