@mysten/bcs
Advanced tools
Comparing version 0.0.0-experimental-20231003170037 to 0.0.0-experimental-20231003172522
@@ -64,2 +64,3 @@ "use strict"; | ||
getSuiMoveConfig: () => getSuiMoveConfig, | ||
isSerializedBcs: () => isSerializedBcs, | ||
registerPrimitives: () => registerPrimitives, | ||
@@ -525,2 +526,6 @@ splitGenericParameters: () => splitGenericParameters, | ||
var BcsType = _BcsType; | ||
var SERIALIZED_BCS_BRAND = Symbol.for("@mysten/serialized-bcs"); | ||
function isSerializedBcs(obj) { | ||
return !!obj && typeof obj === "object" && obj[SERIALIZED_BCS_BRAND] === true; | ||
} | ||
var _schema, _bytes; | ||
@@ -534,2 +539,7 @@ var SerializedBcs = class { | ||
} | ||
// Used to brand SerializedBcs so that they can be identified, even between multiple copies | ||
// of the @mysten/bcs package are installed | ||
get [SERIALIZED_BCS_BRAND]() { | ||
return true; | ||
} | ||
toBytes() { | ||
@@ -1974,2 +1984,3 @@ return __privateGet(this, _bytes); | ||
getSuiMoveConfig, | ||
isSerializedBcs, | ||
registerPrimitives, | ||
@@ -1976,0 +1987,0 @@ splitGenericParameters, |
# Change Log | ||
## 0.0.0-experimental-20231003170037 | ||
## 0.0.0-experimental-20231003172522 | ||
@@ -8,2 +8,3 @@ ### Minor Changes | ||
- 1bc430161: Add new type-safe schema builder. See https://sui-typescript-docs.vercel.app/bcs for updated documentation | ||
- e4484852b: Add isSerializedBcs helper | ||
@@ -10,0 +11,0 @@ ## 0.7.4 |
@@ -31,4 +31,7 @@ import { BcsReader } from './reader'; | ||
} | ||
declare const SERIALIZED_BCS_BRAND: unique symbol; | ||
export declare function isSerializedBcs(obj: unknown): obj is SerializedBcs<unknown>; | ||
export declare class SerializedBcs<T, Input = T> { | ||
#private; | ||
get [SERIALIZED_BCS_BRAND](): boolean; | ||
constructor(type: BcsType<T, Input>, schema: Uint8Array); | ||
@@ -73,1 +76,2 @@ toBytes(): Uint8Array; | ||
export declare function lazyBcsType<T, Input>(cb: () => BcsType<T, Input>): BcsType<T, Input>; | ||
export {}; |
@@ -61,3 +61,12 @@ // Copyright (c) Mysten Labs, Inc. | ||
_BcsType_write = new WeakMap(), _BcsType_serialize = new WeakMap(); | ||
const SERIALIZED_BCS_BRAND = Symbol.for('@mysten/serialized-bcs'); | ||
export function isSerializedBcs(obj) { | ||
return !!obj && typeof obj === 'object' && obj[SERIALIZED_BCS_BRAND] === true; | ||
} | ||
export class SerializedBcs { | ||
// Used to brand SerializedBcs so that they can be identified, even between multiple copies | ||
// of the @mysten/bcs package are installed | ||
get [(_SerializedBcs_schema = new WeakMap(), _SerializedBcs_bytes = new WeakMap(), SERIALIZED_BCS_BRAND)]() { | ||
return true; | ||
} | ||
constructor(type, schema) { | ||
@@ -85,3 +94,2 @@ _SerializedBcs_schema.set(this, void 0); | ||
} | ||
_SerializedBcs_schema = new WeakMap(), _SerializedBcs_bytes = new WeakMap(); | ||
export function fixedSizeBcsType({ size, ...options }) { | ||
@@ -88,0 +96,0 @@ return new BcsType({ |
import { fromB58, toB58 } from './b58.js'; | ||
import { fromB64, toB64 } from './b64.js'; | ||
import { BcsType, BcsTypeOptions, SerializedBcs } from './bcs-type.js'; | ||
import { BcsType, BcsTypeOptions, isSerializedBcs, SerializedBcs } from './bcs-type.js'; | ||
import { bcs } from './bcs.js'; | ||
@@ -11,2 +11,2 @@ import { fromHEX, toHEX } from './hex.js'; | ||
export * from './legacy-registry.js'; | ||
export { bcs, BcsType, type BcsTypeOptions, SerializedBcs, toB58, fromB58, toB64, fromB64, fromHEX, toHEX, encodeStr, decodeStr, splitGenericParameters, BcsReader, BcsWriter, type BcsWriterOptions, type InferBcsInput, type InferBcsType, }; | ||
export { bcs, BcsType, type BcsTypeOptions, SerializedBcs, isSerializedBcs, toB58, fromB58, toB64, fromB64, fromHEX, toHEX, encodeStr, decodeStr, splitGenericParameters, BcsReader, BcsWriter, type BcsWriterOptions, type InferBcsInput, type InferBcsType, }; |
@@ -64,2 +64,3 @@ "use strict"; | ||
getSuiMoveConfig: () => getSuiMoveConfig, | ||
isSerializedBcs: () => isSerializedBcs, | ||
registerPrimitives: () => registerPrimitives, | ||
@@ -525,2 +526,6 @@ splitGenericParameters: () => splitGenericParameters, | ||
var BcsType = _BcsType; | ||
var SERIALIZED_BCS_BRAND = Symbol.for("@mysten/serialized-bcs"); | ||
function isSerializedBcs(obj) { | ||
return !!obj && typeof obj === "object" && obj[SERIALIZED_BCS_BRAND] === true; | ||
} | ||
var _schema, _bytes; | ||
@@ -534,2 +539,7 @@ var SerializedBcs = class { | ||
} | ||
// Used to brand SerializedBcs so that they can be identified, even between multiple copies | ||
// of the @mysten/bcs package are installed | ||
get [SERIALIZED_BCS_BRAND]() { | ||
return true; | ||
} | ||
toBytes() { | ||
@@ -1974,2 +1984,3 @@ return __privateGet(this, _bytes); | ||
getSuiMoveConfig, | ||
isSerializedBcs, | ||
registerPrimitives, | ||
@@ -1976,0 +1987,0 @@ splitGenericParameters, |
{ | ||
"name": "@mysten/bcs", | ||
"version": "0.0.0-experimental-20231003170037", | ||
"version": "0.0.0-experimental-20231003172522", | ||
"description": "BCS - Canonical Binary Serialization implementation for JavaScript", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -85,2 +85,7 @@ // Copyright (c) Mysten Labs, Inc. | ||
const SERIALIZED_BCS_BRAND = Symbol.for('@mysten/serialized-bcs'); | ||
export function isSerializedBcs(obj: unknown): obj is SerializedBcs<unknown> { | ||
return !!obj && typeof obj === 'object' && (obj as any)[SERIALIZED_BCS_BRAND] === true; | ||
} | ||
export class SerializedBcs<T, Input = T> { | ||
@@ -90,2 +95,8 @@ #schema: BcsType<T, Input>; | ||
// Used to brand SerializedBcs so that they can be identified, even between multiple copies | ||
// of the @mysten/bcs package are installed | ||
get [SERIALIZED_BCS_BRAND]() { | ||
return true; | ||
} | ||
constructor(type: BcsType<T, Input>, schema: Uint8Array) { | ||
@@ -92,0 +103,0 @@ this.#schema = type; |
@@ -16,3 +16,3 @@ // Copyright (c) Mysten Labs, Inc. | ||
import { fromB64, toB64 } from './b64.js'; | ||
import { BcsType, BcsTypeOptions, SerializedBcs } from './bcs-type.js'; | ||
import { BcsType, BcsTypeOptions, isSerializedBcs, SerializedBcs } from './bcs-type.js'; | ||
import { bcs } from './bcs.js'; | ||
@@ -33,2 +33,3 @@ import { fromHEX, toHEX } from './hex.js'; | ||
SerializedBcs, | ||
isSerializedBcs, | ||
toB58, | ||
@@ -35,0 +36,0 @@ fromB58, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
627853
11088