@fleet-sdk/serializer 0.4.1 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @fleet-sdk/serializer
2
2
 
3
+ ## 0.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [504974e]
8
+ - @fleet-sdk/common@0.6.4
9
+ - @fleet-sdk/crypto@0.6.4
10
+
11
+ ## 0.5.0
12
+
13
+ ### Patch Changes
14
+
15
+ - 9dd0b55: Export `SigmaByteWriter` and `SigmaByteReader` classes
16
+ - Updated dependencies [6ecfd2e]
17
+ - @fleet-sdk/crypto@0.5.0
18
+
3
19
  ## 0.4.1
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- import { BytesInput } from '@fleet-sdk/crypto';
2
- import { HexString, Box, Amount, BoxCandidate, UnsignedInput, DataInput } from '@fleet-sdk/common';
1
+ import { ByteInput as ByteInput$1, blake2b256, Coder } from '@fleet-sdk/crypto';
2
+ import { Box, Amount, BoxCandidate, UnsignedInput, DataInput } from '@fleet-sdk/common';
3
3
 
4
- declare class SigmaReader {
4
+ declare class SigmaByteReader {
5
5
  #private;
6
6
  get isEmpty(): boolean;
7
- constructor(bytes: HexString | Uint8Array);
7
+ constructor(bytes: ByteInput$1);
8
8
  readBoolean(): boolean;
9
9
  readBits(length: number): ArrayLike<boolean>;
10
10
  readByte(): number;
@@ -16,22 +16,23 @@ declare class SigmaReader {
16
16
  readBigInt(): bigint;
17
17
  }
18
18
 
19
- declare class SigmaWriter {
19
+ declare class SigmaByteWriter {
20
20
  #private;
21
21
  get length(): number;
22
- constructor(maxLength: number);
23
- writeBoolean(value: boolean): SigmaWriter;
24
- writeVLQ(value: number): SigmaWriter;
25
- writeBigVLQ(value: bigint): SigmaWriter;
26
- writeShort(value: number): SigmaWriter;
27
- writeInt(value: number): SigmaWriter;
28
- writeLong(value: bigint): SigmaWriter;
29
- write(byte: number): SigmaWriter;
30
- writeBytes(bytes: Uint8Array): SigmaWriter;
31
- writeHex(bytesHex: string): SigmaWriter;
32
- writeBits(bits: ArrayLike<boolean>): SigmaWriter;
33
- writeBigInt(value: bigint): SigmaWriter;
34
- toHex(): string;
22
+ constructor(length: number);
23
+ writeBoolean(value: boolean): SigmaByteWriter;
24
+ writeVLQ(value: number): SigmaByteWriter;
25
+ writeBigVLQ(value: bigint): SigmaByteWriter;
26
+ writeShort(value: number): SigmaByteWriter;
27
+ writeInt(value: number): SigmaByteWriter;
28
+ writeLong(value: bigint): SigmaByteWriter;
29
+ write(byte: number): SigmaByteWriter;
30
+ writeBytes(bytes: ArrayLike<number>): SigmaByteWriter;
31
+ writeHex(bytesHex: string): SigmaByteWriter;
32
+ writeBits(bits: ArrayLike<boolean>): SigmaByteWriter;
33
+ writeBigInt(value: bigint): SigmaByteWriter;
34
+ writeChecksum(length?: number, hashFn?: typeof blake2b256): SigmaByteWriter;
35
+ encode<T>(coder: Coder<Uint8Array, T>): T;
35
36
  toBytes(): Uint8Array;
36
37
  }
37
38
 
@@ -152,24 +153,24 @@ declare function isTuple(type: SType): type is STupleType;
152
153
  declare class SConstant<D = unknown, T extends SType = SType> {
153
154
  #private;
154
155
  constructor(type: T, data: D);
155
- static from<D, T extends SType = SType>(bytes: BytesInput): SConstant<D, T>;
156
+ static from<D, T extends SType = SType>(bytes: ByteInput$1): SConstant<D, T>;
156
157
  get type(): T;
157
158
  get data(): D;
158
159
  toBytes(): Uint8Array;
159
160
  toHex(): string;
160
161
  }
161
- declare function decode<T>(value: BytesInput | undefined): T | undefined;
162
- declare function decode<T, K>(value: BytesInput | undefined, coder: (input: T) => K): K | undefined;
162
+ declare function decode<T>(value: ByteInput$1 | undefined): T | undefined;
163
+ declare function decode<T, K>(value: ByteInput$1 | undefined, coder: (input: T) => K): K | undefined;
163
164
  /** @deprecated use `decode` instead */
164
- declare function parse<T>(constant: BytesInput): T;
165
+ declare function parse<T>(constant: ByteInput$1): T;
165
166
  /** @deprecated use `decode` instead */
166
- declare function parse<T>(constant: BytesInput, mode: "strict"): T;
167
+ declare function parse<T>(constant: ByteInput$1, mode: "strict"): T;
167
168
  /** @deprecated use `decode` instead */
168
- declare function parse<T>(constant: BytesInput | undefined, mode: "safe"): T | undefined;
169
+ declare function parse<T>(constant: ByteInput$1 | undefined, mode: "safe"): T | undefined;
169
170
 
170
- declare function serializeBox(box: Box<Amount>): SigmaWriter;
171
- declare function serializeBox(box: Box<Amount>, writer: SigmaWriter): SigmaWriter;
172
- declare function serializeBox(box: BoxCandidate<Amount>, writer: SigmaWriter, distinctTokenIds: string[]): SigmaWriter;
171
+ declare function serializeBox(box: Box<Amount>): SigmaByteWriter;
172
+ declare function serializeBox(box: Box<Amount>, writer: SigmaByteWriter): SigmaByteWriter;
173
+ declare function serializeBox(box: BoxCandidate<Amount>, writer: SigmaByteWriter, distinctTokenIds: string[]): SigmaByteWriter;
173
174
  /**
174
175
  * Estimates the byte size a box.
175
176
  * @returns byte size of the box.
@@ -181,16 +182,16 @@ type MinimalUnsignedTransaction = {
181
182
  dataInputs: readonly DataInput[];
182
183
  outputs: readonly BoxCandidate<Amount>[];
183
184
  };
184
- declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaWriter;
185
+ declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaByteWriter;
185
186
 
186
- declare class DataSerializer {
187
- static serialize(data: unknown, type: SType, writer: SigmaWriter): SigmaWriter;
188
- static deserialize(type: SType, reader: SigmaReader): unknown;
189
- }
187
+ declare const dataSerializer: {
188
+ serialize(data: unknown, type: SType, writer: SigmaByteWriter): SigmaByteWriter;
189
+ deserialize(type: SType, reader: SigmaByteReader): unknown;
190
+ };
190
191
 
191
- declare class TypeSerializer {
192
- static serialize(type: SType, writer: SigmaWriter): void;
193
- static deserialize(r: SigmaReader): SType;
194
- }
192
+ declare const typeSerializer: {
193
+ serialize(type: SType, writer: SigmaByteWriter): void;
194
+ deserialize(r: SigmaByteReader): SType;
195
+ };
195
196
 
196
- export { DataSerializer, MinimalUnsignedTransaction, SBigInt, SBigIntType, SBool, SBoolType, SByte, SByteType, SColl, SCollType, SConstant, SGenericType, SGroupElement, SGroupElementType, SInt, SIntType, SLong, SLongType, SMonomorphicType, SPair, SPrimitiveType, SShort, SShortType, SSigmaProp, SSigmaPropType, STupleType, SType, SUnit, SUnitType, TypeSerializer, decode, estimateBoxSize, estimateVLQSize, isColl, isTuple, parse, serializeBox, serializeTransaction };
197
+ export { type MinimalUnsignedTransaction, SBigInt, SBigIntType, SBool, SBoolType, SByte, SByteType, SColl, SCollType, SConstant, SGenericType, SGroupElement, SGroupElementType, SInt, SIntType, SLong, SLongType, SMonomorphicType, SPair, SPrimitiveType, SShort, SShortType, SSigmaProp, SSigmaPropType, STupleType, SType, SUnit, SUnitType, SigmaByteReader, SigmaByteWriter, dataSerializer, decode, estimateBoxSize, estimateVLQSize, isColl, isTuple, parse, serializeBox, serializeTransaction, typeSerializer };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { BytesInput } from '@fleet-sdk/crypto';
2
- import { HexString, Box, Amount, BoxCandidate, UnsignedInput, DataInput } from '@fleet-sdk/common';
1
+ import { ByteInput as ByteInput$1, blake2b256, Coder } from '@fleet-sdk/crypto';
2
+ import { Box, Amount, BoxCandidate, UnsignedInput, DataInput } from '@fleet-sdk/common';
3
3
 
4
- declare class SigmaReader {
4
+ declare class SigmaByteReader {
5
5
  #private;
6
6
  get isEmpty(): boolean;
7
- constructor(bytes: HexString | Uint8Array);
7
+ constructor(bytes: ByteInput$1);
8
8
  readBoolean(): boolean;
9
9
  readBits(length: number): ArrayLike<boolean>;
10
10
  readByte(): number;
@@ -16,22 +16,23 @@ declare class SigmaReader {
16
16
  readBigInt(): bigint;
17
17
  }
18
18
 
19
- declare class SigmaWriter {
19
+ declare class SigmaByteWriter {
20
20
  #private;
21
21
  get length(): number;
22
- constructor(maxLength: number);
23
- writeBoolean(value: boolean): SigmaWriter;
24
- writeVLQ(value: number): SigmaWriter;
25
- writeBigVLQ(value: bigint): SigmaWriter;
26
- writeShort(value: number): SigmaWriter;
27
- writeInt(value: number): SigmaWriter;
28
- writeLong(value: bigint): SigmaWriter;
29
- write(byte: number): SigmaWriter;
30
- writeBytes(bytes: Uint8Array): SigmaWriter;
31
- writeHex(bytesHex: string): SigmaWriter;
32
- writeBits(bits: ArrayLike<boolean>): SigmaWriter;
33
- writeBigInt(value: bigint): SigmaWriter;
34
- toHex(): string;
22
+ constructor(length: number);
23
+ writeBoolean(value: boolean): SigmaByteWriter;
24
+ writeVLQ(value: number): SigmaByteWriter;
25
+ writeBigVLQ(value: bigint): SigmaByteWriter;
26
+ writeShort(value: number): SigmaByteWriter;
27
+ writeInt(value: number): SigmaByteWriter;
28
+ writeLong(value: bigint): SigmaByteWriter;
29
+ write(byte: number): SigmaByteWriter;
30
+ writeBytes(bytes: ArrayLike<number>): SigmaByteWriter;
31
+ writeHex(bytesHex: string): SigmaByteWriter;
32
+ writeBits(bits: ArrayLike<boolean>): SigmaByteWriter;
33
+ writeBigInt(value: bigint): SigmaByteWriter;
34
+ writeChecksum(length?: number, hashFn?: typeof blake2b256): SigmaByteWriter;
35
+ encode<T>(coder: Coder<Uint8Array, T>): T;
35
36
  toBytes(): Uint8Array;
36
37
  }
37
38
 
@@ -152,24 +153,24 @@ declare function isTuple(type: SType): type is STupleType;
152
153
  declare class SConstant<D = unknown, T extends SType = SType> {
153
154
  #private;
154
155
  constructor(type: T, data: D);
155
- static from<D, T extends SType = SType>(bytes: BytesInput): SConstant<D, T>;
156
+ static from<D, T extends SType = SType>(bytes: ByteInput$1): SConstant<D, T>;
156
157
  get type(): T;
157
158
  get data(): D;
158
159
  toBytes(): Uint8Array;
159
160
  toHex(): string;
160
161
  }
161
- declare function decode<T>(value: BytesInput | undefined): T | undefined;
162
- declare function decode<T, K>(value: BytesInput | undefined, coder: (input: T) => K): K | undefined;
162
+ declare function decode<T>(value: ByteInput$1 | undefined): T | undefined;
163
+ declare function decode<T, K>(value: ByteInput$1 | undefined, coder: (input: T) => K): K | undefined;
163
164
  /** @deprecated use `decode` instead */
164
- declare function parse<T>(constant: BytesInput): T;
165
+ declare function parse<T>(constant: ByteInput$1): T;
165
166
  /** @deprecated use `decode` instead */
166
- declare function parse<T>(constant: BytesInput, mode: "strict"): T;
167
+ declare function parse<T>(constant: ByteInput$1, mode: "strict"): T;
167
168
  /** @deprecated use `decode` instead */
168
- declare function parse<T>(constant: BytesInput | undefined, mode: "safe"): T | undefined;
169
+ declare function parse<T>(constant: ByteInput$1 | undefined, mode: "safe"): T | undefined;
169
170
 
170
- declare function serializeBox(box: Box<Amount>): SigmaWriter;
171
- declare function serializeBox(box: Box<Amount>, writer: SigmaWriter): SigmaWriter;
172
- declare function serializeBox(box: BoxCandidate<Amount>, writer: SigmaWriter, distinctTokenIds: string[]): SigmaWriter;
171
+ declare function serializeBox(box: Box<Amount>): SigmaByteWriter;
172
+ declare function serializeBox(box: Box<Amount>, writer: SigmaByteWriter): SigmaByteWriter;
173
+ declare function serializeBox(box: BoxCandidate<Amount>, writer: SigmaByteWriter, distinctTokenIds: string[]): SigmaByteWriter;
173
174
  /**
174
175
  * Estimates the byte size a box.
175
176
  * @returns byte size of the box.
@@ -181,16 +182,16 @@ type MinimalUnsignedTransaction = {
181
182
  dataInputs: readonly DataInput[];
182
183
  outputs: readonly BoxCandidate<Amount>[];
183
184
  };
184
- declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaWriter;
185
+ declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaByteWriter;
185
186
 
186
- declare class DataSerializer {
187
- static serialize(data: unknown, type: SType, writer: SigmaWriter): SigmaWriter;
188
- static deserialize(type: SType, reader: SigmaReader): unknown;
189
- }
187
+ declare const dataSerializer: {
188
+ serialize(data: unknown, type: SType, writer: SigmaByteWriter): SigmaByteWriter;
189
+ deserialize(type: SType, reader: SigmaByteReader): unknown;
190
+ };
190
191
 
191
- declare class TypeSerializer {
192
- static serialize(type: SType, writer: SigmaWriter): void;
193
- static deserialize(r: SigmaReader): SType;
194
- }
192
+ declare const typeSerializer: {
193
+ serialize(type: SType, writer: SigmaByteWriter): void;
194
+ deserialize(r: SigmaByteReader): SType;
195
+ };
195
196
 
196
- export { DataSerializer, MinimalUnsignedTransaction, SBigInt, SBigIntType, SBool, SBoolType, SByte, SByteType, SColl, SCollType, SConstant, SGenericType, SGroupElement, SGroupElementType, SInt, SIntType, SLong, SLongType, SMonomorphicType, SPair, SPrimitiveType, SShort, SShortType, SSigmaProp, SSigmaPropType, STupleType, SType, SUnit, SUnitType, TypeSerializer, decode, estimateBoxSize, estimateVLQSize, isColl, isTuple, parse, serializeBox, serializeTransaction };
197
+ export { type MinimalUnsignedTransaction, SBigInt, SBigIntType, SBool, SBoolType, SByte, SByteType, SColl, SCollType, SConstant, SGenericType, SGroupElement, SGroupElementType, SInt, SIntType, SLong, SLongType, SMonomorphicType, SPair, SPrimitiveType, SShort, SShortType, SSigmaProp, SSigmaPropType, STupleType, SType, SUnit, SUnitType, SigmaByteReader, SigmaByteWriter, dataSerializer, decode, estimateBoxSize, estimateVLQSize, isColl, isTuple, parse, serializeBox, serializeTransaction, typeSerializer };