@btc-vision/btc-runtime 1.9.2 → 1.9.3

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.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "scripts": {
@@ -380,8 +380,18 @@ export class BlockchainEnvironment {
380
380
  private _internalSetStorageAt(pointerHash: Uint8Array, value: Uint8Array): void {
381
381
  this.storage.set(pointerHash, value);
382
382
 
383
- if (pointerHash.buffer.byteLength !== 32 || value.buffer.byteLength !== 32) {
384
- throw new Revert('Pointer and value must be 32 bytes long');
383
+ if (pointerHash.buffer.byteLength !== 32) {
384
+ throw new Revert('Pointer must be 32 bytes long');
385
+ }
386
+
387
+ let finalValue: Uint8Array = value;
388
+ if (value.buffer.byteLength !== 32) {
389
+ // TODO: Probably force this?
390
+ finalValue = new Uint8Array(32);
391
+
392
+ for (let i = 0; i < value.buffer.byteLength && i < 32; i++) {
393
+ finalValue[i] = value[i];
394
+ }
385
395
  }
386
396
 
387
397
  storePointer(pointerHash.buffer, value.buffer);