@btc-vision/btc-runtime 1.11.0-rc.7 → 1.11.0-rc.8

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.11.0-rc.7",
3
+ "version": "1.11.0-rc.8",
4
4
  "description": "Bitcoin L1 Smart Contract Runtime for OPNet. Build decentralized applications on Bitcoin using AssemblyScript and WebAssembly. Fully audited.",
5
5
  "main": "btc/index.ts",
6
6
  "types": "btc/index.ts",
@@ -5,12 +5,14 @@ export enum Networks {
5
5
  Mainnet = 0,
6
6
  Testnet = 1,
7
7
  Regtest = 2,
8
+ OpnetTestnet = 3,
8
9
  }
9
10
 
10
11
  @final
11
12
  export class NetworkManager {
12
13
  private readonly mainnet: Uint8Array;
13
14
  private readonly testnet: Uint8Array;
15
+ private readonly opnetTestnet: Uint8Array;
14
16
  private readonly regtest: Uint8Array;
15
17
 
16
18
  constructor() {
@@ -35,8 +37,16 @@ export class NetworkManager {
35
37
  0x46, 0x6e, 0x22, 0x06,
36
38
  ]);
37
39
 
40
+ const opnetTestnet = new Uint8Array(32);
41
+ opnetTestnet.set([
42
+ 0x73, 0x32, 0xf1, 0x3c, 0x2f, 0x3d, 0x75, 0xa5, 0x0b, 0x9b, 0x8f, 0xf8, 0x75, 0xb5,
43
+ 0x5b, 0x98, 0x05, 0xb8, 0xe2, 0xf1, 0x70, 0x2f, 0xaf, 0xee, 0x1f, 0x6b, 0x10, 0x85,
44
+ 0x7f, 0x01, 0x00, 0x00,
45
+ ]);
46
+
38
47
  this.mainnet = mainnet;
39
48
  this.testnet = testnet;
49
+ this.opnetTestnet = opnetTestnet;
40
50
  this.regtest = regtest;
41
51
  }
42
52
 
@@ -48,6 +58,8 @@ export class NetworkManager {
48
58
  return 'tb';
49
59
  case Networks.Regtest:
50
60
  return 'bcrt';
61
+ case Networks.OpnetTestnet:
62
+ return 'opt1';
51
63
  default:
52
64
  throw new Revert('Unknown network');
53
65
  }
@@ -65,6 +77,9 @@ export class NetworkManager {
65
77
  case Networks.Regtest:
66
78
  out.set(this.regtest);
67
79
  return out;
80
+ case Networks.OpnetTestnet:
81
+ out.set(this.opnetTestnet);
82
+ return out;
68
83
  default:
69
84
  throw new Revert('Unknown network');
70
85
  }
@@ -78,6 +93,7 @@ export class NetworkManager {
78
93
  if (this.equals(chainId, this.mainnet)) return Networks.Mainnet;
79
94
  if (this.equals(chainId, this.testnet)) return Networks.Testnet;
80
95
  if (this.equals(chainId, this.regtest)) return Networks.Regtest;
96
+ if (this.equals(chainId, this.opnetTestnet)) return Networks.OpnetTestnet;
81
97
 
82
98
  throw new Revert('Unknown chain id');
83
99
  }
@@ -1,6 +1,7 @@
1
1
  import { Blockchain } from '../env';
2
- import { GET_EMPTY_BUFFER } from '../math/bytes';
2
+ import { EMPTY_POINTER, GET_EMPTY_BUFFER } from '../math/bytes';
3
3
  import { Revert } from '../types/Revert';
4
+ import { encodePointer } from '../math/abi';
4
5
 
5
6
  @final
6
7
  export class StoredBoolean {
@@ -10,11 +11,7 @@ export class StoredBoolean {
10
11
  public pointer: u16,
11
12
  defaultValue: bool,
12
13
  ) {
13
- const pointerBuffer = GET_EMPTY_BUFFER();
14
- pointerBuffer[0] = pointer & 255;
15
- pointerBuffer[1] = (pointer >> 8) & 255;
16
-
17
- this.pointerBuffer = pointerBuffer;
14
+ this.pointerBuffer = encodePointer(pointer, EMPTY_POINTER, true, 'StoredBoolean');
18
15
 
19
16
  const value = GET_EMPTY_BUFFER();
20
17
  if (defaultValue) {
@@ -113,7 +113,7 @@ export class StoredU32 {
113
113
  @inline
114
114
  public toString(): string {
115
115
  this.ensureValues();
116
- return `[${this._values[0].toString()}, ${this._values[1].toString()}, ${this._values[2].toString()}, ${this._values[3].toString()},, ${this._values[4].toString()},, ${this._values[5].toString()},, ${this._values[6].toString()},, ${this._values[7].toString()}]`;
116
+ return `[${this._values[0].toString()}, ${this._values[1].toString()}, ${this._values[2].toString()}, ${this._values[3].toString()}, ${this._values[4].toString()}, ${this._values[5].toString()}, ${this._values[6].toString()}, ${this._values[7].toString()}]`;
117
117
  }
118
118
 
119
119
  /**