@btc-vision/btc-runtime 1.0.18 → 1.0.19

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.18",
3
+ "version": "1.0.19",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "types": "btc/index.ts",
@@ -157,13 +157,13 @@ export class BlockchainEnvironment {
157
157
  }
158
158
 
159
159
  public getEvents(): Uint8Array {
160
- const eventLength: u8 = u8(this.events.length);
160
+ const eventLength: u16 = u16(this.events.length);
161
161
  if (eventLength > MAX_EVENTS) {
162
162
  throw this.error('Too many events');
163
163
  }
164
164
 
165
165
  const buffer: BytesWriter = new BytesWriter();
166
- buffer.writeU8(eventLength);
166
+ buffer.writeU16(eventLength);
167
167
 
168
168
  for (let i: u8 = 0; i < eventLength; i++) {
169
169
  const event: NetEvent = this.events[i];
@@ -188,7 +188,7 @@ export class BlockchainEnvironment {
188
188
  return reader.readAddress();
189
189
  }
190
190
 
191
- public deployContract(hash: u256, bytecode: Uint8Array): BytesReader {
191
+ public deployContract(hash: u256, bytecode: Uint8Array): DeployContractResponse {
192
192
  const writer = new BytesWriter();
193
193
  writer.writeU256(hash);
194
194
  writer.writeBytes(bytecode);
@@ -196,7 +196,11 @@ export class BlockchainEnvironment {
196
196
  const cb: Potential<Uint8Array> = deploy(writer.getBuffer());
197
197
  if (!cb) throw this.error('Failed to deploy contract');
198
198
 
199
- return new BytesReader(cb as Uint8Array);
199
+ const reader: BytesReader = new BytesReader(cb as Uint8Array);
200
+ const virtualAddress: u256 = reader.readU256();
201
+ const contractAddress: Address = reader.readAddress();
202
+
203
+ return new DeployContractResponse(virtualAddress, contractAddress);
200
204
  }
201
205
 
202
206
  public deployContractFromExisting(
@@ -236,7 +240,7 @@ export class BlockchainEnvironment {
236
240
  public hasStorageAt(pointer: u16, subPointer: MemorySlotPointer): bool {
237
241
  // We mark zero as the default value for the storage, if something is 0, the storage slot get deleted or is non-existent
238
242
  const val: u256 = this.getStorageAt(pointer, subPointer, u256.Zero);
239
-
243
+
240
244
  return u256.ne(val, u256.Zero);
241
245
  }
242
246
 
@@ -1,7 +1,7 @@
1
1
  import { BytesWriter } from '../buffer/BytesWriter';
2
2
 
3
3
  export const MAX_EVENT_DATA_SIZE: u32 = 352; // 352 bytes max per event.
4
- export const MAX_EVENTS: u8 = 8; // 8 events max per transactions.
4
+ export const MAX_EVENTS: u16 = 1000; // 1000 events max per transactions.
5
5
 
6
6
  export abstract class NetEvent {
7
7
  protected constructor(
@@ -14,7 +14,6 @@ export class MapU256 extends Map<u256, u256> {
14
14
  }
15
15
 
16
16
  public indexOf(pointerHash: u256): i32 {
17
- // Delete the old value
18
17
  for (let i: i32 = 0; i < this._keys.length; i++) {
19
18
  const key = this._keys[i];
20
19