@btc-vision/btc-runtime 1.0.0 → 1.0.2

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.0",
3
+ "version": "1.0.2",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "types": "btc/index.ts",
@@ -210,7 +210,7 @@ export abstract class OP_20 extends OP_NET implements IOP_20 {
210
210
  return this.balanceOfMap.get(owner);
211
211
  }
212
212
 
213
- protected _burn(value: u256): boolean {
213
+ protected _burn(value: u256, onlyOwner: boolean = true): boolean {
214
214
  if (u256.eq(value, u256.Zero)) {
215
215
  throw new Revert(`No tokens`);
216
216
  }
@@ -218,7 +218,7 @@ export abstract class OP_20 extends OP_NET implements IOP_20 {
218
218
  const callee = Blockchain.callee();
219
219
  const caller = Blockchain.caller();
220
220
 
221
- this.onlyOwner(callee); // only indexers can burn tokens
221
+ if (onlyOwner) this.onlyOwner(callee); // only indexers can burn tokens
222
222
 
223
223
  if (this._totalSupply.value < value) throw new Revert(`Insufficient total supply.`);
224
224
  if (!this.balanceOfMap.has(caller)) throw new Revert('Empty');
@@ -236,11 +236,11 @@ export abstract class OP_20 extends OP_NET implements IOP_20 {
236
236
  return true;
237
237
  }
238
238
 
239
- protected _mint(to: Address, value: u256): boolean {
239
+ protected _mint(to: Address, value: u256, onlyOwner: boolean = true): boolean {
240
240
  const callee = Blockchain.callee();
241
241
  const caller = Blockchain.caller();
242
242
 
243
- this.onlyOwner(callee);
243
+ if (onlyOwner) this.onlyOwner(callee);
244
244
 
245
245
  if (caller !== callee) throw new Revert(`callee != caller`);
246
246
  if (callee !== this.owner) throw new Revert('Only indexers can mint tokens');
@@ -32,17 +32,17 @@ export class BlockchainEnvironment {
32
32
 
33
33
  constructor() {}
34
34
 
35
- private _contract: Potential<OP_NET> = null;
35
+ private _contract: Potential<() => OP_NET> = null;
36
36
 
37
37
  public get contract(): OP_NET {
38
38
  if (!this._contract) {
39
39
  throw this.error('Contract is required');
40
40
  }
41
41
 
42
- return this._contract as OP_NET;
42
+ return this._contract();
43
43
  }
44
44
 
45
- public set contract(contract: OP_NET) {
45
+ public set contract(contract: () => OP_NET) {
46
46
  this._contract = contract;
47
47
  }
48
48