Socket
Socket
Sign inDemoInstall

@mysten/bcs

Package Overview
Dependencies
Maintainers
7
Versions
518
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mysten/bcs - npm Package Compare versions

Comparing version 0.0.0-experimental-20240603195201 to 0.0.0-experimental-20240709191650

41

CHANGELOG.md
# Change Log
## 0.0.0-experimental-20240603195201
## 0.0.0-experimental-20240709191650
### Patch Changes
- 369b924343: Improve error messages when attempting to serialze non-array values that should be arrays
- 0f27a97: Update dependencies
## 1.0.2
### Patch Changes
- 369b924343: Improve error messages when attempting to serialze non-array values that should be
arrays
## 1.0.1

@@ -19,4 +26,6 @@

- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features and breaking changes.
See the [full migration guide](https://sdk.mystenlabs.com/typescript/migrations/sui-1.0) for details on how to upgrade.
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
and breaking changes. See the
[full migration guide](https://sdk.mystenlabs.com/typescript/migrations/sui-1.0) for details on
how to upgrade.

@@ -57,3 +66,4 @@ ## 0.11.1

- fce0a08d0f: Deprecate the bcs.generic helper. This helper causes typescript performance issues, and the generated generics can't be exported
- fce0a08d0f: Deprecate the bcs.generic helper. This helper causes typescript performance issues,
and the generated generics can't be exported

@@ -70,3 +80,4 @@ ## 0.8.1

- 1bc430161: Add new type-safe schema builder. See https://sdk.mystenlabs.com/bcs for updated documentation
- 1bc430161: Add new type-safe schema builder. See https://sdk.mystenlabs.com/bcs for updated
documentation
- e4484852b: Add isSerializedBcs helper

@@ -103,10 +114,13 @@

- 19b567f21: Unified self- and delegated staking flows. Removed fields from `Validator` (`stake_amount`, `pending_stake`, and `pending_withdraw`) and renamed `delegation_staking_pool` to `staking_pool`. Additionally removed the `validator_stake` and `delegated_stake` fields in the `ValidatorSet` type and replaced them with a `total_stake` field.
- 19b567f21: Unified self- and delegated staking flows. Removed fields from `Validator`
(`stake_amount`, `pending_stake`, and `pending_withdraw`) and renamed `delegation_staking_pool` to
`staking_pool`. Additionally removed the `validator_stake` and `delegated_stake` fields in the
`ValidatorSet` type and replaced them with a `total_stake` field.
- 5c3b00cde: Add object id to staking pool and pool id to staked sui.
- 3d9a04648: Adds `deactivation_epoch` to staking pool object, and adds `inactive_pools` to the validator set object.
- 3d9a04648: Adds `deactivation_epoch` to staking pool object, and adds `inactive_pools` to the
validator set object.
- a8049d159: Fixes the issue with deep nested generics by introducing array type names
- all of the methods (except for aliasing) now allow passing in arrays instead
of strings to allow for easier composition of generics and avoid using template
strings
- all of the methods (except for aliasing) now allow passing in arrays instead of strings to allow
for easier composition of generics and avoid using template strings

@@ -130,3 +144,6 @@ ```js

- a0955c479: Switch from 20 to 32-byte address. Match Secp256k1.deriveKeypair with Ed25519.
- 0a7b42a6d: This changes almost all occurences of "delegate", "delegation" (and various capitalizations/forms) to their equivalent "stake"-based name. Function names, function argument names, RPC endpoints, Move functions, and object fields have been updated with this new naming convention.
- 0a7b42a6d: This changes almost all occurences of "delegate", "delegation" (and various
capitalizations/forms) to their equivalent "stake"-based name. Function names, function argument
names, RPC endpoints, Move functions, and object fields have been updated with this new naming
convention.
- 77bdf907f: When parsing u64, u128, and u256 values with bcs, they are now string encoded.

@@ -133,0 +150,0 @@

@@ -6,2 +6,5 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __typeError = (msg) => {
throw TypeError(msg);
};
var __export = (target, all) => {

@@ -20,20 +23,6 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var bcs_type_exports = {};

@@ -59,6 +48,6 @@ __export(bcs_type_exports, {

var _write, _serialize, _schema, _bytes;
const _BcsType = class {
const _BcsType = class _BcsType {
constructor(options) {
__privateAdd(this, _write, void 0);
__privateAdd(this, _serialize, void 0);
__privateAdd(this, _write);
__privateAdd(this, _serialize);
this.name = options.name;

@@ -119,5 +108,5 @@ this.read = options.read;

};
let BcsType = _BcsType;
_write = new WeakMap();
_serialize = new WeakMap();
let BcsType = _BcsType;
const SERIALIZED_BCS_BRAND = Symbol.for("@mysten/serialized-bcs");

@@ -129,4 +118,4 @@ function isSerializedBcs(obj) {

constructor(type, schema) {
__privateAdd(this, _schema, void 0);
__privateAdd(this, _bytes, void 0);
__privateAdd(this, _schema);
__privateAdd(this, _bytes);
__privateSet(this, _schema, type);

@@ -133,0 +122,0 @@ __privateSet(this, _bytes, schema);

@@ -73,5 +73,5 @@ import type { BcsTypeOptions } from './bcs-type.js';

*/
fixedArray<T_1, Input>(size: number, type: BcsType<T_1, Input>, options?: BcsTypeOptions<T_1[], Iterable<Input> & {
fixedArray<T, Input>(size: number, type: BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & {
length: number;
}> | undefined): BcsType<T_1[], Iterable<Input> & {
}>): BcsType<T[], Iterable<Input> & {
length: number;

@@ -86,3 +86,3 @@ }>;

*/
option<T_2, Input_1>(type: BcsType<T_2, Input_1>): BcsType<T_2 | null, Input_1 | null | undefined>;
option<T, Input>(type: BcsType<T, Input>): BcsType<T | null, Input | null | undefined>;
/**

@@ -95,5 +95,5 @@ * Creates a BcsType representing a variable length vector of a given type

*/
vector<T_3, Input_2>(type: BcsType<T_3, Input_2>, options?: BcsTypeOptions<T_3[], Iterable<Input_2> & {
vector<T, Input>(type: BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & {
length: number;
}> | undefined): BcsType<T_3[], Iterable<Input_2> & {
}>): BcsType<T[], Iterable<Input> & {
length: number;

@@ -109,3 +109,3 @@ }>;

*/
tuple<const Types extends readonly BcsType<any, any>[]>(types: Types, options?: BcsTypeOptions<{ -readonly [K in keyof Types]: Types[K] extends BcsType<infer T_4, any> ? T_4 : never; }, { [K_1 in keyof Types]: Types[K_1] extends BcsType<any, infer T_5> ? T_5 : never; }> | undefined): BcsType<{ -readonly [K_2 in keyof Types]: Types[K_2] extends BcsType<infer T_6, any> ? T_6 : never; }, { [K_3 in keyof Types]: Types[K_3] extends BcsType<any, infer T_7> ? T_7 : never; }>;
tuple<const Types extends readonly BcsType<any>[]>(types: Types, options?: BcsTypeOptions<{ -readonly [K in keyof Types]: Types[K] extends BcsType<infer T, any> ? T : never; }, { [K in keyof Types]: Types[K] extends BcsType<any, infer T> ? T : never; }>): BcsType<{ -readonly [K in keyof Types]: Types[K] extends BcsType<infer T, any> ? T : never; }, { [K_1 in keyof Types]: Types[K_1] extends BcsType<any, infer T_1> ? T_1 : never; }>;
/**

@@ -123,3 +123,3 @@ * Creates a BcsType representing a struct of a given set of fields

*/
struct<T_8 extends Record<string, BcsType<any, any>>>(name: string, fields: T_8, options?: Omit<BcsTypeOptions<{ [K_4 in keyof T_8]: T_8[K_4] extends BcsType<infer U, any> ? U : never; }, { [K_5 in keyof T_8]: T_8[K_5] extends BcsType<any, infer U_1> ? U_1 : never; }>, "name"> | undefined): BcsType<{ [K_6 in keyof T_8]: T_8[K_6] extends BcsType<infer U_2, any> ? U_2 : never; }, { [K_7 in keyof T_8]: T_8[K_7] extends BcsType<any, infer U_3> ? U_3 : never; }>;
struct<T extends Record<string, BcsType<any>>>(name: string, fields: T, options?: Omit<BcsTypeOptions<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never; }, { [K in keyof T]: T[K] extends BcsType<any, infer U> ? U : never; }>, "name">): BcsType<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never; }, { [K_1 in keyof T]: T[K_1] extends BcsType<any, infer U_1> ? U_1 : never; }>;
/**

@@ -141,3 +141,3 @@ * Creates a BcsType representing an enum of a given set of options

*/
enum<T_9 extends Record<string, BcsType<any, any> | null>>(name: string, values: T_9, options?: Omit<BcsTypeOptions<EnumOutputShape<{ [K_8 in keyof T_9]: T_9[K_8] extends BcsType<infer U_4, any> ? U_4 : true; }>, EnumInputShape<{ [K_9 in keyof T_9]: T_9[K_9] extends BcsType<any, infer U_5> ? U_5 : boolean | object | null; }>>, "name"> | undefined): BcsType<EnumOutputShape<{ [K_10 in keyof T_9]: T_9[K_10] extends BcsType<infer U_6, any> ? U_6 : true; }>, EnumInputShape<{ [K_11 in keyof T_9]: T_9[K_11] extends BcsType<any, infer U_7> ? U_7 : boolean | object | null; }>>;
enum<T extends Record<string, BcsType<any> | null>>(name: string, values: T, options?: Omit<BcsTypeOptions<EnumOutputShape<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : true; }>, EnumInputShape<{ [K in keyof T]: T[K] extends BcsType<any, infer U> ? U : boolean | object | null; }>>, "name">): BcsType<EnumOutputShape<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : true; }>, EnumInputShape<{ [K_1 in keyof T]: T[K_1] extends BcsType<any, infer U_1> ? U_1 : boolean | object | null; }>>;
/**

@@ -151,3 +151,3 @@ * Creates a BcsType representing a map of a given key and value type

*/
map<K_12, V, InputK = K_12, InputV = V>(keyType: BcsType<K_12, InputK>, valueType: BcsType<V, InputV>): BcsType<Map<K_12, V>, Map<InputK, InputV>>;
map<K, V, InputK = K, InputV = V>(keyType: BcsType<K, InputK>, valueType: BcsType<V, InputV>): BcsType<Map<K, V>, Map<InputK, InputV>>;
/**

@@ -157,3 +157,3 @@ * Creates a BcsType that wraps another BcsType which is lazily evaluated. This is useful for creating recursive types.

*/
lazy<T_10 extends BcsType<any, any>>(cb: () => T_10): T_10;
lazy<T extends BcsType<any>>(cb: () => T): T;
};

@@ -1,19 +0,8 @@

var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
var __typeError = (msg) => {
throw TypeError(msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var _write, _serialize, _schema, _bytes;

@@ -26,6 +15,6 @@ import { fromB58, toB58 } from "./b58.js";

import { BcsWriter } from "./writer.js";
const _BcsType = class {
const _BcsType = class _BcsType {
constructor(options) {
__privateAdd(this, _write, void 0);
__privateAdd(this, _serialize, void 0);
__privateAdd(this, _write);
__privateAdd(this, _serialize);
this.name = options.name;

@@ -86,5 +75,5 @@ this.read = options.read;

};
let BcsType = _BcsType;
_write = new WeakMap();
_serialize = new WeakMap();
let BcsType = _BcsType;
const SERIALIZED_BCS_BRAND = Symbol.for("@mysten/serialized-bcs");

@@ -96,4 +85,4 @@ function isSerializedBcs(obj) {

constructor(type, schema) {
__privateAdd(this, _schema, void 0);
__privateAdd(this, _bytes, void 0);
__privateAdd(this, _schema);
__privateAdd(this, _bytes);
__privateSet(this, _schema, type);

@@ -100,0 +89,0 @@ __privateSet(this, _bytes, schema);

@@ -73,5 +73,5 @@ import type { BcsTypeOptions } from './bcs-type.js';

*/
fixedArray<T_1, Input>(size: number, type: BcsType<T_1, Input>, options?: BcsTypeOptions<T_1[], Iterable<Input> & {
fixedArray<T, Input>(size: number, type: BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & {
length: number;
}> | undefined): BcsType<T_1[], Iterable<Input> & {
}>): BcsType<T[], Iterable<Input> & {
length: number;

@@ -86,3 +86,3 @@ }>;

*/
option<T_2, Input_1>(type: BcsType<T_2, Input_1>): BcsType<T_2 | null, Input_1 | null | undefined>;
option<T, Input>(type: BcsType<T, Input>): BcsType<T | null, Input | null | undefined>;
/**

@@ -95,5 +95,5 @@ * Creates a BcsType representing a variable length vector of a given type

*/
vector<T_3, Input_2>(type: BcsType<T_3, Input_2>, options?: BcsTypeOptions<T_3[], Iterable<Input_2> & {
vector<T, Input>(type: BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & {
length: number;
}> | undefined): BcsType<T_3[], Iterable<Input_2> & {
}>): BcsType<T[], Iterable<Input> & {
length: number;

@@ -109,3 +109,3 @@ }>;

*/
tuple<const Types extends readonly BcsType<any, any>[]>(types: Types, options?: BcsTypeOptions<{ -readonly [K in keyof Types]: Types[K] extends BcsType<infer T_4, any> ? T_4 : never; }, { [K_1 in keyof Types]: Types[K_1] extends BcsType<any, infer T_5> ? T_5 : never; }> | undefined): BcsType<{ -readonly [K_2 in keyof Types]: Types[K_2] extends BcsType<infer T_6, any> ? T_6 : never; }, { [K_3 in keyof Types]: Types[K_3] extends BcsType<any, infer T_7> ? T_7 : never; }>;
tuple<const Types extends readonly BcsType<any>[]>(types: Types, options?: BcsTypeOptions<{ -readonly [K in keyof Types]: Types[K] extends BcsType<infer T, any> ? T : never; }, { [K in keyof Types]: Types[K] extends BcsType<any, infer T> ? T : never; }>): BcsType<{ -readonly [K in keyof Types]: Types[K] extends BcsType<infer T, any> ? T : never; }, { [K_1 in keyof Types]: Types[K_1] extends BcsType<any, infer T_1> ? T_1 : never; }>;
/**

@@ -123,3 +123,3 @@ * Creates a BcsType representing a struct of a given set of fields

*/
struct<T_8 extends Record<string, BcsType<any, any>>>(name: string, fields: T_8, options?: Omit<BcsTypeOptions<{ [K_4 in keyof T_8]: T_8[K_4] extends BcsType<infer U, any> ? U : never; }, { [K_5 in keyof T_8]: T_8[K_5] extends BcsType<any, infer U_1> ? U_1 : never; }>, "name"> | undefined): BcsType<{ [K_6 in keyof T_8]: T_8[K_6] extends BcsType<infer U_2, any> ? U_2 : never; }, { [K_7 in keyof T_8]: T_8[K_7] extends BcsType<any, infer U_3> ? U_3 : never; }>;
struct<T extends Record<string, BcsType<any>>>(name: string, fields: T, options?: Omit<BcsTypeOptions<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never; }, { [K in keyof T]: T[K] extends BcsType<any, infer U> ? U : never; }>, "name">): BcsType<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never; }, { [K_1 in keyof T]: T[K_1] extends BcsType<any, infer U_1> ? U_1 : never; }>;
/**

@@ -141,3 +141,3 @@ * Creates a BcsType representing an enum of a given set of options

*/
enum<T_9 extends Record<string, BcsType<any, any> | null>>(name: string, values: T_9, options?: Omit<BcsTypeOptions<EnumOutputShape<{ [K_8 in keyof T_9]: T_9[K_8] extends BcsType<infer U_4, any> ? U_4 : true; }>, EnumInputShape<{ [K_9 in keyof T_9]: T_9[K_9] extends BcsType<any, infer U_5> ? U_5 : boolean | object | null; }>>, "name"> | undefined): BcsType<EnumOutputShape<{ [K_10 in keyof T_9]: T_9[K_10] extends BcsType<infer U_6, any> ? U_6 : true; }>, EnumInputShape<{ [K_11 in keyof T_9]: T_9[K_11] extends BcsType<any, infer U_7> ? U_7 : boolean | object | null; }>>;
enum<T extends Record<string, BcsType<any> | null>>(name: string, values: T, options?: Omit<BcsTypeOptions<EnumOutputShape<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : true; }>, EnumInputShape<{ [K in keyof T]: T[K] extends BcsType<any, infer U> ? U : boolean | object | null; }>>, "name">): BcsType<EnumOutputShape<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : true; }>, EnumInputShape<{ [K_1 in keyof T]: T[K_1] extends BcsType<any, infer U_1> ? U_1 : boolean | object | null; }>>;
/**

@@ -151,3 +151,3 @@ * Creates a BcsType representing a map of a given key and value type

*/
map<K_12, V, InputK = K_12, InputV = V>(keyType: BcsType<K_12, InputK>, valueType: BcsType<V, InputV>): BcsType<Map<K_12, V>, Map<InputK, InputV>>;
map<K, V, InputK = K, InputV = V>(keyType: BcsType<K, InputK>, valueType: BcsType<V, InputV>): BcsType<Map<K, V>, Map<InputK, InputV>>;
/**

@@ -157,3 +157,3 @@ * Creates a BcsType that wraps another BcsType which is lazily evaluated. This is useful for creating recursive types.

*/
lazy<T_10 extends BcsType<any, any>>(cb: () => T_10): T_10;
lazy<T extends BcsType<any>>(cb: () => T): T;
};
{
"name": "@mysten/bcs",
"version": "0.0.0-experimental-20240603195201",
"version": "0.0.0-experimental-20240709191650",
"description": "BCS - Canonical Binary Serialization implementation for JavaScript",

@@ -50,10 +50,10 @@ "license": "Apache-2.0",

"devDependencies": {
"@size-limit/preset-small-lib": "^8.2.6",
"size-limit": "^8.2.6",
"typescript": "^5.3.3",
"vitest": "^1.6.0",
"@size-limit/preset-small-lib": "^11.1.4",
"size-limit": "^11.1.4",
"typescript": "^5.5.3",
"vitest": "^2.0.1",
"@mysten/build-scripts": "0.0.0"
},
"dependencies": {
"bs58": "^5.0.0"
"bs58": "^6.0.0"
},

@@ -60,0 +60,0 @@ "scripts": {

@@ -13,5 +13,4 @@ // Copyright (c) Mysten Labs, Inc.

export type InferBcsType<T extends BcsType<any>> = T extends BcsType<infer U, any> ? U : never;
export type InferBcsInput<T extends BcsType<any, any>> = T extends BcsType<any, infer U>
? U
: never;
export type InferBcsInput<T extends BcsType<any, any>> =
T extends BcsType<any, infer U> ? U : never;

@@ -26,8 +25,8 @@ type Merge<T> = T extends object ? { [K in keyof T]: T[K] } : never;

: 0n extends Values
? EnumOutputShapeWithKeys<T, never>
: '' extends Values
? EnumOutputShapeWithKeys<T, never>
: false extends Values
? EnumOutputShapeWithKeys<T, never>
: EnumOutputShapeWithKeys<T, Keys>;
? EnumOutputShapeWithKeys<T, never>
: '' extends Values
? EnumOutputShapeWithKeys<T, never>
: false extends Values
? EnumOutputShapeWithKeys<T, never>
: EnumOutputShapeWithKeys<T, Keys>;

@@ -40,3 +39,3 @@ export type EnumOutputShapeWithKeys<T extends Record<string, unknown>, Keys extends string> = {

}
>
>
: never;

@@ -43,0 +42,0 @@ }[keyof T];

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc