@btc-vision/transaction 1.2.12 → 1.2.13
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/browser/_version.d.ts +1 -1
- package/browser/buffer/BinaryWriter.d.ts +1 -0
- package/browser/index.js +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/buffer/BinaryWriter.d.ts +1 -0
- package/build/buffer/BinaryWriter.js +15 -1
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/buffer/BinaryWriter.ts +21 -0
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.2.
|
|
1
|
+
export declare const version = "1.2.13";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.2.
|
|
1
|
+
export const version = '1.2.13';
|
|
@@ -12,6 +12,7 @@ export declare class BinaryWriter {
|
|
|
12
12
|
writeU64(value: u64): void;
|
|
13
13
|
writeSelector(value: Selector): void;
|
|
14
14
|
writeBoolean(value: boolean): void;
|
|
15
|
+
writeI128(bigIntValue: bigint): void;
|
|
15
16
|
writeU256(bigIntValue: bigint): void;
|
|
16
17
|
writeU128(bigIntValue: bigint): void;
|
|
17
18
|
writeBytes(value: Uint8Array | Buffer): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BufferHelper } from '../utils/BufferHelper.js';
|
|
2
|
-
import { ADDRESS_BYTE_LENGTH, U128_BYTE_LENGTH, U16_BYTE_LENGTH, U256_BYTE_LENGTH, U32_BYTE_LENGTH, U64_BYTE_LENGTH, U8_BYTE_LENGTH, } from '../utils/lengths.js';
|
|
2
|
+
import { ADDRESS_BYTE_LENGTH, I128_BYTE_LENGTH, U128_BYTE_LENGTH, U16_BYTE_LENGTH, U256_BYTE_LENGTH, U32_BYTE_LENGTH, U64_BYTE_LENGTH, U8_BYTE_LENGTH, } from '../utils/lengths.js';
|
|
3
3
|
import { BinaryReader } from './BinaryReader.js';
|
|
4
4
|
export class BinaryWriter {
|
|
5
5
|
constructor(length = 0) {
|
|
@@ -39,6 +39,20 @@ export class BinaryWriter {
|
|
|
39
39
|
writeBoolean(value) {
|
|
40
40
|
this.writeU8(value ? 1 : 0);
|
|
41
41
|
}
|
|
42
|
+
writeI128(bigIntValue) {
|
|
43
|
+
if (bigIntValue > 170141183460469231731687303715884105727n ||
|
|
44
|
+
bigIntValue < -170141183460469231731687303715884105728n) {
|
|
45
|
+
throw new Error('i128 value is too large.');
|
|
46
|
+
}
|
|
47
|
+
this.allocSafe(I128_BYTE_LENGTH);
|
|
48
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, I128_BYTE_LENGTH);
|
|
49
|
+
if (bytesToHex.byteLength !== I128_BYTE_LENGTH) {
|
|
50
|
+
throw new Error(`Invalid i128 value: ${bigIntValue}`);
|
|
51
|
+
}
|
|
52
|
+
for (let i = 0; i < bytesToHex.byteLength; i++) {
|
|
53
|
+
this.writeU8(bytesToHex[i]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
writeU256(bigIntValue) {
|
|
43
57
|
if (bigIntValue >
|
|
44
58
|
115792089237316195423570985008687907853269984665640564039457584007913129639935n) {
|
package/package.json
CHANGED
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.2.
|
|
1
|
+
export const version = '1.2.13';
|
|
@@ -3,6 +3,7 @@ import { Address } from '../keypair/Address.js';
|
|
|
3
3
|
import { BufferHelper } from '../utils/BufferHelper.js';
|
|
4
4
|
import {
|
|
5
5
|
ADDRESS_BYTE_LENGTH,
|
|
6
|
+
I128_BYTE_LENGTH,
|
|
6
7
|
U128_BYTE_LENGTH,
|
|
7
8
|
U16_BYTE_LENGTH,
|
|
8
9
|
U256_BYTE_LENGTH,
|
|
@@ -60,6 +61,26 @@ export class BinaryWriter {
|
|
|
60
61
|
this.writeU8(value ? 1 : 0);
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
public writeI128(bigIntValue: bigint): void {
|
|
65
|
+
if (
|
|
66
|
+
bigIntValue > 170141183460469231731687303715884105727n ||
|
|
67
|
+
bigIntValue < -170141183460469231731687303715884105728n
|
|
68
|
+
) {
|
|
69
|
+
throw new Error('i128 value is too large.');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.allocSafe(I128_BYTE_LENGTH);
|
|
73
|
+
|
|
74
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, I128_BYTE_LENGTH);
|
|
75
|
+
if (bytesToHex.byteLength !== I128_BYTE_LENGTH) {
|
|
76
|
+
throw new Error(`Invalid i128 value: ${bigIntValue}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < bytesToHex.byteLength; i++) {
|
|
80
|
+
this.writeU8(bytesToHex[i]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
public writeU256(bigIntValue: bigint): void {
|
|
64
85
|
if (
|
|
65
86
|
bigIntValue >
|