@btc-vision/btc-runtime 1.0.27 → 1.0.29

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btc-vision/btc-runtime",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "types": "btc/index.ts",
@@ -308,12 +308,17 @@ export class BytesWriter {
308
308
  }
309
309
  }
310
310
 
311
+ private min(value1: i32, value2: i32): i32 {
312
+ return value1 < value2 ? value1 : value2;
313
+ }
314
+
311
315
  private fromAddress(value: Address): Uint8Array {
312
316
  if (value.length > i32(ADDRESS_BYTE_LENGTH)) {
313
317
  throw new Revert(`Address is too long ${value.length} > ${ADDRESS_BYTE_LENGTH} bytes`);
314
318
  }
315
319
 
316
- const bytes: Uint8Array = new Uint8Array(value.length + 1);
320
+ const length: i32 = this.min(value.length + 1, ADDRESS_BYTE_LENGTH);
321
+ const bytes: Uint8Array = new Uint8Array(length);
317
322
  for (let i: i32 = 0; i < value.length; i++) {
318
323
  bytes[i] = value.charCodeAt(i);
319
324
  }