@fleet-sdk/serializer 0.4.0 → 0.5.0
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 +17 -0
- package/dist/index.d.mts +38 -35
- package/dist/index.d.ts +38 -35
- package/dist/index.js +216 -199
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -200
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# @fleet-sdk/serializer
|
2
2
|
|
3
|
+
## 0.5.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 9dd0b55: Export `SigmaByteWriter` and `SigmaByteReader` classes
|
8
|
+
- Updated dependencies [6ecfd2e]
|
9
|
+
- @fleet-sdk/crypto@0.5.0
|
10
|
+
|
11
|
+
## 0.4.1
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- d6ef248: Fix: export `decode()` function
|
16
|
+
- Updated dependencies [28e3467]
|
17
|
+
- @fleet-sdk/common@0.4.1
|
18
|
+
- @fleet-sdk/crypto@0.4.1
|
19
|
+
|
3
20
|
## 0.4.0
|
4
21
|
|
5
22
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
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
|
4
|
+
declare class SigmaByteReader {
|
5
5
|
#private;
|
6
6
|
get isEmpty(): boolean;
|
7
|
-
constructor(bytes:
|
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
|
19
|
+
declare class SigmaByteWriter {
|
20
20
|
#private;
|
21
21
|
get length(): number;
|
22
|
-
constructor(
|
23
|
-
writeBoolean(value: boolean):
|
24
|
-
writeVLQ(value: number):
|
25
|
-
writeBigVLQ(value: bigint):
|
26
|
-
writeShort(value: number):
|
27
|
-
writeInt(value: number):
|
28
|
-
writeLong(value: bigint):
|
29
|
-
write(byte: number):
|
30
|
-
writeBytes(bytes:
|
31
|
-
writeHex(bytesHex: string):
|
32
|
-
writeBits(bits: ArrayLike<boolean>):
|
33
|
-
writeBigInt(value: bigint):
|
34
|
-
|
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,22 +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:
|
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
|
}
|
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;
|
161
164
|
/** @deprecated use `decode` instead */
|
162
|
-
declare function parse<T>(constant:
|
165
|
+
declare function parse<T>(constant: ByteInput$1): T;
|
163
166
|
/** @deprecated use `decode` instead */
|
164
|
-
declare function parse<T>(constant:
|
167
|
+
declare function parse<T>(constant: ByteInput$1, mode: "strict"): T;
|
165
168
|
/** @deprecated use `decode` instead */
|
166
|
-
declare function parse<T>(constant:
|
169
|
+
declare function parse<T>(constant: ByteInput$1 | undefined, mode: "safe"): T | undefined;
|
167
170
|
|
168
|
-
declare function serializeBox(box: Box<Amount>):
|
169
|
-
declare function serializeBox(box: Box<Amount>, writer:
|
170
|
-
declare function serializeBox(box: BoxCandidate<Amount>, writer:
|
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;
|
171
174
|
/**
|
172
175
|
* Estimates the byte size a box.
|
173
176
|
* @returns byte size of the box.
|
@@ -179,16 +182,16 @@ type MinimalUnsignedTransaction = {
|
|
179
182
|
dataInputs: readonly DataInput[];
|
180
183
|
outputs: readonly BoxCandidate<Amount>[];
|
181
184
|
};
|
182
|
-
declare function serializeTransaction(transaction: MinimalUnsignedTransaction):
|
185
|
+
declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaByteWriter;
|
183
186
|
|
184
|
-
declare
|
185
|
-
|
186
|
-
|
187
|
-
}
|
187
|
+
declare const dataSerializer: {
|
188
|
+
serialize(data: unknown, type: SType, writer: SigmaByteWriter): SigmaByteWriter;
|
189
|
+
deserialize(type: SType, reader: SigmaByteReader): unknown;
|
190
|
+
};
|
188
191
|
|
189
|
-
declare
|
190
|
-
|
191
|
-
|
192
|
-
}
|
192
|
+
declare const typeSerializer: {
|
193
|
+
serialize(type: SType, writer: SigmaByteWriter): void;
|
194
|
+
deserialize(r: SigmaByteReader): SType;
|
195
|
+
};
|
193
196
|
|
194
|
-
export {
|
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 {
|
2
|
-
import {
|
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
|
4
|
+
declare class SigmaByteReader {
|
5
5
|
#private;
|
6
6
|
get isEmpty(): boolean;
|
7
|
-
constructor(bytes:
|
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
|
19
|
+
declare class SigmaByteWriter {
|
20
20
|
#private;
|
21
21
|
get length(): number;
|
22
|
-
constructor(
|
23
|
-
writeBoolean(value: boolean):
|
24
|
-
writeVLQ(value: number):
|
25
|
-
writeBigVLQ(value: bigint):
|
26
|
-
writeShort(value: number):
|
27
|
-
writeInt(value: number):
|
28
|
-
writeLong(value: bigint):
|
29
|
-
write(byte: number):
|
30
|
-
writeBytes(bytes:
|
31
|
-
writeHex(bytesHex: string):
|
32
|
-
writeBits(bits: ArrayLike<boolean>):
|
33
|
-
writeBigInt(value: bigint):
|
34
|
-
|
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,22 +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:
|
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
|
}
|
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;
|
161
164
|
/** @deprecated use `decode` instead */
|
162
|
-
declare function parse<T>(constant:
|
165
|
+
declare function parse<T>(constant: ByteInput$1): T;
|
163
166
|
/** @deprecated use `decode` instead */
|
164
|
-
declare function parse<T>(constant:
|
167
|
+
declare function parse<T>(constant: ByteInput$1, mode: "strict"): T;
|
165
168
|
/** @deprecated use `decode` instead */
|
166
|
-
declare function parse<T>(constant:
|
169
|
+
declare function parse<T>(constant: ByteInput$1 | undefined, mode: "safe"): T | undefined;
|
167
170
|
|
168
|
-
declare function serializeBox(box: Box<Amount>):
|
169
|
-
declare function serializeBox(box: Box<Amount>, writer:
|
170
|
-
declare function serializeBox(box: BoxCandidate<Amount>, writer:
|
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;
|
171
174
|
/**
|
172
175
|
* Estimates the byte size a box.
|
173
176
|
* @returns byte size of the box.
|
@@ -179,16 +182,16 @@ type MinimalUnsignedTransaction = {
|
|
179
182
|
dataInputs: readonly DataInput[];
|
180
183
|
outputs: readonly BoxCandidate<Amount>[];
|
181
184
|
};
|
182
|
-
declare function serializeTransaction(transaction: MinimalUnsignedTransaction):
|
185
|
+
declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaByteWriter;
|
183
186
|
|
184
|
-
declare
|
185
|
-
|
186
|
-
|
187
|
-
}
|
187
|
+
declare const dataSerializer: {
|
188
|
+
serialize(data: unknown, type: SType, writer: SigmaByteWriter): SigmaByteWriter;
|
189
|
+
deserialize(type: SType, reader: SigmaByteReader): unknown;
|
190
|
+
};
|
188
191
|
|
189
|
-
declare
|
190
|
-
|
191
|
-
|
192
|
-
}
|
192
|
+
declare const typeSerializer: {
|
193
|
+
serialize(type: SType, writer: SigmaByteWriter): void;
|
194
|
+
deserialize(r: SigmaByteReader): SType;
|
195
|
+
};
|
193
196
|
|
194
|
-
export {
|
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 };
|