@btc-vision/btc-runtime 1.1.1 → 1.1.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.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "types": "btc/index.ts",
@@ -90,7 +90,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
90
90
  }
91
91
 
92
92
  public instantiate(params: OP20InitParameters, skipOwnerVerification: boolean = false): void {
93
- if (!skipOwnerVerification) this.onlyOwner(Blockchain.from());
93
+ if (!skipOwnerVerification) this.onlyOwner(Blockchain.origin());
94
94
 
95
95
  if (!this._maxSupply.value.isZero()) {
96
96
  throw new Revert('Already initialized');
@@ -125,7 +125,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
125
125
  const resp = this._approve(spender, value);
126
126
  response.writeBoolean(resp);
127
127
 
128
- this.createApproveEvent(Blockchain.from(), spender, value);
128
+ this.createApproveEvent(Blockchain.origin(), spender, value);
129
129
 
130
130
  return response;
131
131
  }
@@ -234,7 +234,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
234
234
  }
235
235
 
236
236
  protected _approve(spender: Address, value: u256): boolean {
237
- const callee = Blockchain.from();
237
+ const callee = Blockchain.origin();
238
238
 
239
239
  const senderMap = this.allowanceMap.get(callee);
240
240
  senderMap.set(spender, value);
@@ -254,7 +254,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
254
254
  throw new Revert(`No tokens`);
255
255
  }
256
256
 
257
- const callee = Blockchain.from();
257
+ const callee = Blockchain.origin();
258
258
  const caller = Blockchain.sender();
259
259
 
260
260
  if (onlyOwner) this.onlyOwner(callee); // only indexers can burn tokens
@@ -276,7 +276,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
276
276
  }
277
277
 
278
278
  protected _mint(to: Address, value: u256, onlyOwner: boolean = true): boolean {
279
- const callee = Blockchain.from();
279
+ const callee = Blockchain.origin();
280
280
 
281
281
  if (onlyOwner) this.onlyOwner(callee);
282
282
 
@@ -299,7 +299,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
299
299
  }
300
300
 
301
301
  protected _transfer(to: string, value: u256): boolean {
302
- const caller = Blockchain.from();
302
+ const caller = Blockchain.origin();
303
303
 
304
304
  if (!this.balanceOfMap.has(caller)) throw new Revert();
305
305
  if (this.isSelf(caller)) throw new Revert('Can not transfer from self account');
@@ -355,7 +355,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
355
355
  }
356
356
 
357
357
  protected _transferFrom(from: Address, to: Address, value: u256): boolean {
358
- const spender = Blockchain.from();
358
+ const spender = Blockchain.origin();
359
359
  if (Blockchain.sender() !== from) {
360
360
  throw new Revert('Not caller.');
361
361
  }
@@ -32,7 +32,7 @@ export class BlockchainEnvironment {
32
32
  private storage: PointerStorage = new MapU256();
33
33
  private events: NetEvent[] = [];
34
34
 
35
- private _from: PotentialAddress = null;
35
+ private _origin: PotentialAddress = null;
36
36
  private _sender: PotentialAddress = null;
37
37
  private currentBlock: u256 = u256.Zero;
38
38
 
@@ -98,12 +98,12 @@ export class BlockchainEnvironment {
98
98
  return this.currentBlock.toU64();
99
99
  }
100
100
 
101
- public from(): Address {
102
- if (!this._from) {
101
+ public origin(): Address {
102
+ if (!this._origin) {
103
103
  throw this.error('Callee is required');
104
104
  }
105
105
 
106
- return this._from as Address;
106
+ return this._origin as Address;
107
107
  }
108
108
 
109
109
  public sender(): Address {
@@ -118,7 +118,7 @@ export class BlockchainEnvironment {
118
118
  const reader: BytesReader = new BytesReader(data);
119
119
 
120
120
  this._sender = reader.readAddress();
121
- this._from = reader.readAddress();
121
+ this._origin = reader.readAddress();
122
122
  this.currentBlock = reader.readU256();
123
123
 
124
124
  this._owner = reader.readAddress();
@@ -128,7 +128,7 @@ export class BlockchainEnvironment {
128
128
  }
129
129
 
130
130
  public call(destinationContract: Address, calldata: BytesWriter): BytesReader {
131
- if (destinationContract === this._from) {
131
+ if (destinationContract === this._origin) {
132
132
  throw this.error('Cannot call self');
133
133
  }
134
134