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

[TS SDK] Add the ability to serialize nested vectors #9635

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 12 additions & 0 deletions ecosystem/typescript/sdk/src/bcs/helper.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

import { TypeTag, TypeTagVector } from "../aptos_types";
import { Deserializer } from "./deserializer";
import { Serializer } from "./serializer";
import { AnyNumber, Bytes, Seq, Uint16, Uint32, Uint8 } from "./types";
import { serializeVector as serializeVectorHelper } from "../transaction_builder/builder_utils";

interface Serializable {
serialize(serializer: Serializer): void;
}

/**
* Serializes a vector of any depth with the corresponding serialization function for the specified TypeTag.
*/
export function serializeVectorWithDepth(argVal: any, typeTag: TypeTag): Bytes {
const serializer = new Serializer();
const typeTagVector = new TypeTagVector(typeTag);
serializeVectorHelper(argVal, typeTagVector, serializer, 0);
return serializer.getBytes();
}

/**
* Serializes a vector values that are "Serializable".
*/
Expand Down
Loading