@btc-vision/btc-runtime 1.2.0 → 1.2.1
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,7 @@ export class BytesWriter {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
public writeU256(value: u256): void {
|
|
67
|
-
this.writeBytesU8Array(value.
|
|
67
|
+
this.writeBytesU8Array(value.toUint8Array());
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
public writeTuple(value: u256[]): void {
|
|
@@ -77,19 +77,16 @@ export class BytesWriter {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
public writeBytes(value: Uint8Array): void {
|
|
80
|
-
this.writeBytesU8Array(
|
|
80
|
+
this.writeBytesU8Array(value);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
@inline
|
|
84
|
-
public writeBytesU8Array(value:
|
|
84
|
+
public writeBytesU8Array(value: Uint8Array): void {
|
|
85
85
|
this.allocSafe(value.length);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<usize>value.length,
|
|
91
|
-
);
|
|
92
|
-
this.currentOffset += value.length;
|
|
86
|
+
|
|
87
|
+
for (let i = 0; i < value.length; i++) {
|
|
88
|
+
this.writeU8(value[i]);
|
|
89
|
+
}
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
public writeBytesWithLength(value: Uint8Array): void {
|
|
@@ -155,10 +155,10 @@ export class BlockchainEnvironment {
|
|
|
155
155
|
|
|
156
156
|
public emit(event: NetEvent): void {
|
|
157
157
|
const data = event.getEventData();
|
|
158
|
-
const buffer = new BytesWriter(
|
|
158
|
+
const buffer = new BytesWriter(event.eventType.length + 6 + data.byteLength);
|
|
159
159
|
|
|
160
160
|
buffer.writeStringWithLength(event.eventType);
|
|
161
|
-
buffer.writeBytesWithLength(
|
|
161
|
+
buffer.writeBytesWithLength(data);
|
|
162
162
|
|
|
163
163
|
emit(buffer.getBuffer());
|
|
164
164
|
}
|
|
@@ -7,6 +7,7 @@ import { Address, ADDRESS_BYTE_LENGTH } from '../../types/Address';
|
|
|
7
7
|
export class MintEvent extends NetEvent {
|
|
8
8
|
constructor(address: Address, amount: u256) {
|
|
9
9
|
const data: BytesWriter = new BytesWriter(32 + ADDRESS_BYTE_LENGTH);
|
|
10
|
+
|
|
10
11
|
data.writeAddress(address);
|
|
11
12
|
data.writeU256(amount);
|
|
12
13
|
|