@aptos-labs/ts-sdk
Version:
Aptos TypeScript SDK
18 lines • 728 B
JavaScript
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
import { Deserializer } from "../bcs/index.js";
/**
* Normalizes an instance of a class by deserializing it from its byte representation.
* This function allows the `instanceof` operator to work correctly when the input objects originate from a different bundle.
*
* @param cls - The class of the object to normalize.
* @param value - The instance to normalize.
* @group Implementation
* @category Utils
*/
export function normalizeBundle(cls, value) {
const serializedBytes = value.bcsToBytes();
const deserializer = new Deserializer(serializedBytes);
return cls.deserialize(deserializer);
}
//# sourceMappingURL=normalizeBundle.js.map