@btc-vision/btc-runtime 1.6.0 → 1.6.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btc-vision/btc-runtime",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "scripts": {},
@@ -13,17 +13,17 @@ import {
13
13
  deployFromAddress,
14
14
  emit,
15
15
  env_exit,
16
+ getAccountType,
17
+ getBlockHash,
16
18
  getCallResult,
17
19
  loadPointer,
18
- tLoadPointer,
19
20
  log,
20
21
  sha256,
21
22
  storePointer,
23
+ tLoadPointer,
22
24
  tStorePointer,
23
25
  validateBitcoinAddress,
24
26
  verifySchnorrSignature,
25
- getAccountType,
26
- getBlockHash,
27
27
  } from './global';
28
28
  import { eqUint, MapUint8Array } from '../generic/MapUint8Array';
29
29
  import { EMPTY_BUFFER } from '../math/bytes';
@@ -258,8 +258,7 @@ export class BlockchainEnvironment {
258
258
  public getTransientStorageAt(
259
259
  pointerHash: Uint8Array,
260
260
  ): Uint8Array {
261
- this.hasPointerTransientStorageHash(pointerHash);
262
- if (this.transientStorage.has(pointerHash)) {
261
+ if (this.hasPointerTransientStorageHash(pointerHash)) {
263
262
  return this.transientStorage.get(pointerHash);
264
263
  }
265
264
 
@@ -306,6 +305,16 @@ export class BlockchainEnvironment {
306
305
  this._internalSetTransientStorageAt(pointerHash, value);
307
306
  }
308
307
 
308
+ public getAccountType(address: Address): u32 {
309
+ return getAccountType(address.buffer);
310
+ }
311
+
312
+ public getBlockHash(blockNumber: u64): Uint8Array {
313
+ const hash = new ArrayBuffer(32);
314
+ getBlockHash(blockNumber, hash);
315
+ return Uint8Array.wrap(hash);
316
+ }
317
+
309
318
  private createContractIfNotExists(): void {
310
319
  if (!this._contract) {
311
320
  throw new Revert('Contract is required');
@@ -344,7 +353,7 @@ export class BlockchainEnvironment {
344
353
  }
345
354
 
346
355
  private hasPointerTransientStorageHash(pointer: Uint8Array): bool {
347
- if (this.storage.has(pointer)) {
356
+ if (this.transientStorage.has(pointer)) {
348
357
  return true;
349
358
  }
350
359
 
@@ -353,18 +362,8 @@ export class BlockchainEnvironment {
353
362
  tLoadPointer(pointer.buffer, resultBuffer);
354
363
 
355
364
  const value: Uint8Array = Uint8Array.wrap(resultBuffer);
356
- this.storage.set(pointer, value); // cache the value
365
+ this.transientStorage.set(pointer, value); // cache the value
357
366
 
358
367
  return !eqUint(value, EMPTY_BUFFER);
359
368
  }
360
-
361
- public getAccountType(address: Address): u32 {
362
- return getAccountType(address.buffer)
363
- }
364
-
365
- public getBlockHash(blockNumber: u64): Uint8Array {
366
- const hash = new ArrayBuffer(32);
367
- getBlockHash(blockNumber, hash);
368
- return Uint8Array.wrap(hash);
369
- }
370
369
  }