@fleet-sdk/serializer 0.4.1 → 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 +8 -0
- package/dist/index.d.mts +38 -37
- package/dist/index.d.ts +38 -37
- package/dist/index.js +211 -203
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +210 -204
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
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,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:
|
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:
|
162
|
-
declare function decode<T, K>(value:
|
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:
|
165
|
+
declare function parse<T>(constant: ByteInput$1): T;
|
165
166
|
/** @deprecated use `decode` instead */
|
166
|
-
declare function parse<T>(constant:
|
167
|
+
declare function parse<T>(constant: ByteInput$1, mode: "strict"): T;
|
167
168
|
/** @deprecated use `decode` instead */
|
168
|
-
declare function parse<T>(constant:
|
169
|
+
declare function parse<T>(constant: ByteInput$1 | undefined, mode: "safe"): T | undefined;
|
169
170
|
|
170
|
-
declare function serializeBox(box: Box<Amount>):
|
171
|
-
declare function serializeBox(box: Box<Amount>, writer:
|
172
|
-
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;
|
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):
|
185
|
+
declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaByteWriter;
|
185
186
|
|
186
|
-
declare
|
187
|
-
|
188
|
-
|
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
|
192
|
-
|
193
|
-
|
194
|
-
}
|
192
|
+
declare const typeSerializer: {
|
193
|
+
serialize(type: SType, writer: SigmaByteWriter): void;
|
194
|
+
deserialize(r: SigmaByteReader): SType;
|
195
|
+
};
|
195
196
|
|
196
|
-
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,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:
|
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:
|
162
|
-
declare function decode<T, K>(value:
|
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:
|
165
|
+
declare function parse<T>(constant: ByteInput$1): T;
|
165
166
|
/** @deprecated use `decode` instead */
|
166
|
-
declare function parse<T>(constant:
|
167
|
+
declare function parse<T>(constant: ByteInput$1, mode: "strict"): T;
|
167
168
|
/** @deprecated use `decode` instead */
|
168
|
-
declare function parse<T>(constant:
|
169
|
+
declare function parse<T>(constant: ByteInput$1 | undefined, mode: "safe"): T | undefined;
|
169
170
|
|
170
|
-
declare function serializeBox(box: Box<Amount>):
|
171
|
-
declare function serializeBox(box: Box<Amount>, writer:
|
172
|
-
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;
|
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):
|
185
|
+
declare function serializeTransaction(transaction: MinimalUnsignedTransaction): SigmaByteWriter;
|
185
186
|
|
186
|
-
declare
|
187
|
-
|
188
|
-
|
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
|
192
|
-
|
193
|
-
|
194
|
-
}
|
192
|
+
declare const typeSerializer: {
|
193
|
+
serialize(type: SType, writer: SigmaByteWriter): void;
|
194
|
+
deserialize(r: SigmaByteReader): SType;
|
195
|
+
};
|
195
196
|
|
196
|
-
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 };
|