@btc-vision/btc-runtime 1.3.21 → 1.4.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.3.21",
3
+ "version": "1.4.1",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "scripts": {
@@ -17,6 +17,7 @@ import { IOP_20 } from './interfaces/IOP_20';
17
17
  import { OP20InitParameters } from './interfaces/OP20InitParameters';
18
18
  import { OP_NET } from './OP_NET';
19
19
  import { sha256 } from '../env/global';
20
+ import { ApproveStr, TransferFromStr, TransferStr } from '../shared-libraries/TransferHelper';
20
21
 
21
22
  const maxSupplyPointer: u16 = Blockchain.nextPointer;
22
23
  const decimalsPointer: u16 = Blockchain.nextPointer;
@@ -206,19 +207,19 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
206
207
  response = new BytesWriter(U256_BYTE_LENGTH);
207
208
  response.writeU256(this.maxSupply);
208
209
  break;
209
- case encodeSelector('allowance'):
210
+ case encodeSelector('allowance(address,address)'):
210
211
  return this.allowance(calldata);
211
- case encodeSelector('approve'):
212
+ case encodeSelector(ApproveStr):
212
213
  return this.approve(calldata);
213
- case encodeSelector('approveFrom'):
214
+ case encodeSelector('approveFrom(address,address,uint256,bytes)'):
214
215
  return this.approveFrom(calldata);
215
- case encodeSelector('balanceOf'):
216
+ case encodeSelector('balanceOf(address)'):
216
217
  return this.balanceOf(calldata);
217
- case encodeSelector('burn'):
218
+ case encodeSelector('burn(uint256)'):
218
219
  return this.burn(calldata);
219
- case encodeSelector('transfer'):
220
+ case encodeSelector(TransferStr):
220
221
  return this.transfer(calldata);
221
- case encodeSelector('transferFrom'):
222
+ case encodeSelector(TransferFromStr):
222
223
  return this.transferFrom(calldata);
223
224
  default:
224
225
  return super.execute(method, calldata);
@@ -6,7 +6,7 @@ import { encodeSelector, Selector } from '../math/abi';
6
6
  import { Calldata } from '../types';
7
7
  import { Address } from '../types/Address';
8
8
  import { Revert } from '../types/Revert';
9
- import { ADDRESS_BYTE_LENGTH } from '../utils/lengths';
9
+ import { ADDRESS_BYTE_LENGTH } from '../utils';
10
10
 
11
11
  export class OP_NET implements IBTC {
12
12
  public get address(): Address {
@@ -17,9 +17,11 @@ export class OP_NET implements IBTC {
17
17
  return Blockchain.contractDeployer;
18
18
  }
19
19
 
20
- public onDeployment(_calldata: Calldata): void {}
20
+ public onDeployment(_calldata: Calldata): void {
21
+ }
21
22
 
22
- public onExecutionCompleted(): void {}
23
+ public onExecutionCompleted(): void {
24
+ }
23
25
 
24
26
  public execute(method: Selector, _calldata: Calldata): BytesWriter {
25
27
  let response: BytesWriter;
@@ -4,19 +4,23 @@ import { Blockchain } from '../env';
4
4
  import { encodeSelector, Selector } from '../math/abi';
5
5
  import { Address } from '../types/Address';
6
6
  import { Revert } from '../types/Revert';
7
- import { ADDRESS_BYTE_LENGTH, SELECTOR_BYTE_LENGTH, U256_BYTE_LENGTH } from '../utils/lengths';
7
+ import { ADDRESS_BYTE_LENGTH, SELECTOR_BYTE_LENGTH, U256_BYTE_LENGTH } from '../utils';
8
+
9
+ export const TransferStr = 'transfer(address,uint256)';
10
+ export const ApproveStr = 'approve(address,uint256)';
11
+ export const TransferFromStr = 'transferFrom(address,address,uint256)';
8
12
 
9
13
  export class TransferHelper {
10
14
  public static get APPROVE_SELECTOR(): Selector {
11
- return encodeSelector('approve');
15
+ return encodeSelector(ApproveStr);
12
16
  }
13
17
 
14
18
  public static get TRANSFER_SELECTOR(): Selector {
15
- return encodeSelector('transfer');
19
+ return encodeSelector(TransferStr);
16
20
  }
17
21
 
18
22
  public static get TRANSFER_FROM_SELECTOR(): Selector {
19
- return encodeSelector('transferFrom');
23
+ return encodeSelector(TransferFromStr);
20
24
  }
21
25
 
22
26
  public static safeApprove(token: Address, spender: Address, amount: u256): void {