@btc-vision/btc-runtime 1.2.2 → 1.2.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/package.json
CHANGED
|
@@ -64,7 +64,12 @@ export class BytesWriter {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
public writeU256(value: u256): void {
|
|
67
|
-
this.
|
|
67
|
+
this.allocSafe(32);
|
|
68
|
+
|
|
69
|
+
const bytes = value.toUint8Array(true);
|
|
70
|
+
for (let i: i32 = 0; i < 32; i++) {
|
|
71
|
+
this.writeU8(bytes[i] || 0);
|
|
72
|
+
}
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
public writeTuple(value: u256[]): void {
|
|
@@ -77,11 +82,15 @@ export class BytesWriter {
|
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
public writeBytes(value: Uint8Array): void {
|
|
80
|
-
this.
|
|
85
|
+
this.allocSafe(value.length);
|
|
86
|
+
|
|
87
|
+
for (let i = 0; i < value.length; i++) {
|
|
88
|
+
this.writeU8(value[i]);
|
|
89
|
+
}
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
@inline
|
|
84
|
-
public writeBytesU8Array(value:
|
|
93
|
+
public writeBytesU8Array(value: u8[]): void {
|
|
85
94
|
this.allocSafe(value.length);
|
|
86
95
|
|
|
87
96
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -233,7 +242,7 @@ export class BytesWriter {
|
|
|
233
242
|
}
|
|
234
243
|
|
|
235
244
|
private fromAddress(value: Address): Uint8Array {
|
|
236
|
-
if (value.length >
|
|
245
|
+
if (value.length > ADDRESS_BYTE_LENGTH) {
|
|
237
246
|
throw new Revert(`Address is too long ${value.length} > ${ADDRESS_BYTE_LENGTH} bytes`);
|
|
238
247
|
}
|
|
239
248
|
|
|
@@ -243,7 +252,7 @@ export class BytesWriter {
|
|
|
243
252
|
bytes[i] = value.charCodeAt(i);
|
|
244
253
|
}
|
|
245
254
|
|
|
246
|
-
if (value.length <
|
|
255
|
+
if (value.length < ADDRESS_BYTE_LENGTH) {
|
|
247
256
|
bytes[value.length] = 0;
|
|
248
257
|
}
|
|
249
258
|
|
package/runtime/types/Address.ts
CHANGED