@btc-vision/btc-runtime 1.11.2 → 1.11.4

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.2",
3
+ "version": "1.11.4",
4
4
  "description": "Bitcoin L1 Smart Contract Runtime for OP_NET. Build decentralized applications on Bitcoin using AssemblyScript and WebAssembly. Fully audited.",
5
5
  "main": "btc/index.ts",
6
6
  "types": "btc/index.ts",
@@ -68,8 +68,7 @@
68
68
  "gulplog": "^2.2.0",
69
69
  "ts-node": "^10.9.2",
70
70
  "typescript": "^6.0.3",
71
- "typescript-eslint": "^8.59.2",
72
- "yaml": "^2.8.4"
71
+ "typescript-eslint": "^8.59.2"
73
72
  },
74
73
  "devDependencies": {
75
74
  "@btc-vision/as-covers-assembly": "^0.4.5",
@@ -77,6 +76,7 @@
77
76
  "@btc-vision/as-pect-assembly": "^8.3.0",
78
77
  "@btc-vision/as-pect-cli": "^8.3.0",
79
78
  "@btc-vision/as-pect-transform": "^8.3.0",
80
- "@types/node": "^25.6.2"
79
+ "@types/node": "^25.6.2",
80
+ "yaml": "^2.8.4"
81
81
  }
82
82
  }
@@ -21,7 +21,7 @@ import {
21
21
  } from '../constants/Exports';
22
22
  import { Blockchain } from '../env';
23
23
  import { sha256, sha256String } from '../env/global';
24
- import { OP20ApprovedEvent, OP20BurnedEvent, OP20MintedEvent, OP20TransferredEvent } from '../events/predefined';
24
+ import { OP20ApprovedEvent, OP20BurnedEvent, OP20MintedEvent, OP20TransferredEvent, } from '../events/predefined';
25
25
  import { Selector } from '../math/abi';
26
26
  import { EMPTY_POINTER } from '../math/bytes';
27
27
  import { AddressMemoryMap } from '../memory/AddressMemoryMap';
@@ -476,74 +476,6 @@ export abstract class OP20 extends ReentrancyGuard implements IOP20 {
476
476
  return new BytesWriter(0);
477
477
  }
478
478
 
479
- /**
480
- * Increases allowance using an EIP-712 typed signature (gasless approval).
481
- *
482
- * @param calldata - Contains owner, spender, amount, deadline, and signature
483
- * @emits Approved event
484
- *
485
- * @throws {Revert} If signature is invalid or expired
486
- *
487
- * @remarks
488
- * Enables gasless approvals where a third party can submit the transaction.
489
- * Uses Schnorr signatures now, will support ML-DSA after quantum transition.
490
- */
491
- @method(
492
- { name: 'owner', type: ABIDataTypes.BYTES32 },
493
- { name: 'ownerTweakedPublicKey', type: ABIDataTypes.BYTES32 },
494
- { name: 'spender', type: ABIDataTypes.ADDRESS },
495
- { name: 'amount', type: ABIDataTypes.UINT256 },
496
- { name: 'deadline', type: ABIDataTypes.UINT64 },
497
- { name: 'signature', type: ABIDataTypes.BYTES },
498
- )
499
- @emit('Approved')
500
- public increaseAllowanceBySignature(calldata: Calldata): BytesWriter {
501
- const ownerAddress = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
502
- const ownerTweakedPublicKey = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
503
-
504
- const owner = new ExtendedAddress(ownerTweakedPublicKey, ownerAddress);
505
-
506
- const spender: Address = calldata.readAddress();
507
- const amount: u256 = calldata.readU256();
508
- const deadline: u64 = calldata.readU64();
509
- const signature = calldata.readBytesWithLength();
510
-
511
- this._increaseAllowanceBySignature(owner, spender, amount, deadline, signature);
512
- return new BytesWriter(0);
513
- }
514
-
515
- /**
516
- * Decreases allowance using an EIP-712 typed signature.
517
- *
518
- * @param calldata - Contains owner, spender, amount, deadline, and signature
519
- * @emits Approved event
520
- *
521
- * @throws {Revert} If signature is invalid or expired
522
- */
523
- @method(
524
- { name: 'owner', type: ABIDataTypes.BYTES32 },
525
- { name: 'ownerTweakedPublicKey', type: ABIDataTypes.BYTES32 },
526
- { name: 'spender', type: ABIDataTypes.ADDRESS },
527
- { name: 'amount', type: ABIDataTypes.UINT256 },
528
- { name: 'deadline', type: ABIDataTypes.UINT64 },
529
- { name: 'signature', type: ABIDataTypes.BYTES },
530
- )
531
- @emit('Approved')
532
- public decreaseAllowanceBySignature(calldata: Calldata): BytesWriter {
533
- const ownerAddress = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
534
- const ownerTweakedPublicKey = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
535
-
536
- const owner = new ExtendedAddress(ownerTweakedPublicKey, ownerAddress);
537
-
538
- const spender: Address = calldata.readAddress();
539
- const amount: u256 = calldata.readU256();
540
- const deadline: u64 = calldata.readU64();
541
- const signature = calldata.readBytesWithLength();
542
-
543
- this._decreaseAllowanceBySignature(owner, spender, amount, deadline, signature);
544
- return new BytesWriter(0);
545
- }
546
-
547
479
  /**
548
480
  * Burns tokens from the sender's balance.
549
481
  *
@@ -861,6 +793,7 @@ export abstract class OP20 extends ReentrancyGuard implements IOP20 {
861
793
  if (owner === Address.zero()) {
862
794
  throw new Revert('Invalid approver');
863
795
  }
796
+
864
797
  if (spender === Address.zero()) {
865
798
  throw new Revert('Invalid spender');
866
799
  }
@@ -410,66 +410,6 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
410
410
  return w;
411
411
  }
412
412
 
413
- @method(
414
- { name: 'owner', type: ABIDataTypes.BYTES32 },
415
- { name: 'ownerTweakedPublicKey', type: ABIDataTypes.BYTES32 },
416
- { name: 'operator', type: ABIDataTypes.ADDRESS },
417
- { name: 'tokenId', type: ABIDataTypes.UINT256 },
418
- { name: 'deadline', type: ABIDataTypes.UINT64 },
419
- { name: 'signature', type: ABIDataTypes.BYTES },
420
- )
421
- @emit('Approved')
422
- public approveBySignature(calldata: Calldata): BytesWriter {
423
- const ownerAddress = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
424
- const ownerTweakedPublicKey = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
425
-
426
- const owner = new ExtendedAddress(ownerTweakedPublicKey, ownerAddress);
427
-
428
- const operator = calldata.readAddress();
429
- const tokenId = calldata.readU256();
430
- const deadline = calldata.readU64();
431
- const signature = calldata.readBytesWithLength();
432
-
433
- // Verify ownership
434
- const tokenOwner = this._ownerOf(tokenId);
435
- if (tokenOwner !== owner) throw new Revert('Not token owner');
436
-
437
- this._verifyApproveSignature(owner, operator, tokenId, deadline, signature);
438
-
439
- this._approve(operator, tokenId);
440
-
441
- return new BytesWriter(0);
442
- }
443
-
444
- @method(
445
- { name: 'owner', type: ABIDataTypes.BYTES32 },
446
- { name: 'ownerTweakedPublicKey', type: ABIDataTypes.BYTES32 },
447
- { name: 'operator', type: ABIDataTypes.ADDRESS },
448
- { name: 'approved', type: ABIDataTypes.BOOL },
449
- { name: 'deadline', type: ABIDataTypes.UINT64 },
450
- { name: 'signature', type: ABIDataTypes.BYTES },
451
- )
452
- @emit('Approved')
453
- public setApprovalForAllBySignature(calldata: Calldata): BytesWriter {
454
- const ownerAddress = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
455
- const ownerTweakedPublicKey = calldata.readBytesArray(ADDRESS_BYTE_LENGTH);
456
-
457
- const owner = new ExtendedAddress(ownerTweakedPublicKey, ownerAddress);
458
-
459
- const operator = calldata.readAddress();
460
- const approved = calldata.readBoolean();
461
- const deadline = calldata.readU64();
462
- const signature = calldata.readBytesWithLength();
463
-
464
- if (owner === operator) throw new Revert('Cannot approve self');
465
-
466
- this._verifySetApprovalForAllSignature(owner, operator, approved, deadline, signature);
467
-
468
- this._setApprovalForAll(owner, operator, approved);
469
-
470
- return new BytesWriter(0);
471
- }
472
-
473
413
  @method({ name: 'tokenId', type: ABIDataTypes.UINT256 })
474
414
  @emit('Burned')
475
415
  public burn(calldata: Calldata): BytesWriter {
@@ -19,6 +19,4 @@ export interface IOP20 {
19
19
  burn(callData: Calldata): BytesWriter;
20
20
  increaseAllowance(callData: Calldata): BytesWriter;
21
21
  decreaseAllowance(callData: Calldata): BytesWriter;
22
- increaseAllowanceBySignature(callData: Calldata): BytesWriter;
23
- decreaseAllowanceBySignature(callData: Calldata): BytesWriter;
24
22
  }
@@ -21,8 +21,6 @@ export interface IOP721 {
21
21
  getApproved(calldata: Calldata): BytesWriter;
22
22
  setApprovalForAll(calldata: Calldata): BytesWriter;
23
23
  isApprovedForAll(calldata: Calldata): BytesWriter;
24
- approveBySignature(calldata: Calldata): BytesWriter;
25
- setApprovalForAllBySignature(calldata: Calldata): BytesWriter;
26
24
 
27
25
  // Advanced functions
28
26
  burn(calldata: Calldata): BytesWriter;
@@ -14,19 +14,9 @@ export const transferSignature = 'transfer(address,uint256)';
14
14
  export const transferFromSignature = 'transferFrom(address,address,uint256)';
15
15
  export const SafeTransferSignature = 'safeTransfer(address,uint256,bytes)';
16
16
  export const SafeTransferFromSignature = 'safeTransferFrom(address,address,uint256,bytes)';
17
- export const IncreaseAllowanceSignature = 'increaseAllowance(address,uint256)';
18
- export const DecreaseAllowanceSignature = 'decreaseAllowance(address,uint256)';
19
17
  export const BurnSignature = 'burn(uint256)';
20
18
 
21
19
  export class TransferHelper {
22
- public static get INCREASE_ALLOWANCE_SELECTOR(): Selector {
23
- return encodeSelector(IncreaseAllowanceSignature);
24
- }
25
-
26
- public static get DECREASE_ALLOWANCE_SELECTOR(): Selector {
27
- return encodeSelector(DecreaseAllowanceSignature);
28
- }
29
-
30
20
  public static get TRANSFER_SELECTOR(): Selector {
31
21
  return encodeSelector(transferSignature);
32
22
  }
@@ -43,28 +33,6 @@ export class TransferHelper {
43
33
  return encodeSelector(SafeTransferFromSignature);
44
34
  }
45
35
 
46
- public static increaseAllowance(token: Address, spender: Address, amount: u256): void {
47
- const calldata = new BytesWriter(
48
- SELECTOR_BYTE_LENGTH + ADDRESS_BYTE_LENGTH + U256_BYTE_LENGTH,
49
- );
50
- calldata.writeSelector(this.INCREASE_ALLOWANCE_SELECTOR);
51
- calldata.writeAddress(spender);
52
- calldata.writeU256(amount);
53
-
54
- Blockchain.call(token, calldata);
55
- }
56
-
57
- public static decreaseAllowance(token: Address, spender: Address, amount: u256): void {
58
- const calldata = new BytesWriter(
59
- SELECTOR_BYTE_LENGTH + ADDRESS_BYTE_LENGTH + U256_BYTE_LENGTH,
60
- );
61
- calldata.writeSelector(this.DECREASE_ALLOWANCE_SELECTOR);
62
- calldata.writeAddress(spender);
63
- calldata.writeU256(amount);
64
-
65
- Blockchain.call(token, calldata);
66
- }
67
-
68
36
  public static transfer(token: Address, to: Address, amount: u256): void {
69
37
  const calldata = new BytesWriter(
70
38
  SELECTOR_BYTE_LENGTH + ADDRESS_BYTE_LENGTH + U256_BYTE_LENGTH,