@btc-vision/btc-runtime 1.9.1 → 1.9.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.
Files changed (31) hide show
  1. package/package.json +13 -4
  2. package/runtime/constants/Exports.ts +86 -0
  3. package/runtime/contracts/OP1155.ts +1042 -0
  4. package/runtime/contracts/OP20.ts +56 -37
  5. package/runtime/contracts/OP721.ts +882 -0
  6. package/runtime/contracts/OP_NET.ts +5 -0
  7. package/runtime/contracts/ReentrancyGuard.ts +136 -0
  8. package/runtime/contracts/interfaces/IOP1155.ts +33 -0
  9. package/runtime/contracts/interfaces/IOP721.ts +29 -0
  10. package/runtime/contracts/interfaces/OP1155InitParameters.ts +11 -0
  11. package/runtime/contracts/interfaces/OP721InitParameters.ts +15 -0
  12. package/runtime/env/BlockchainEnvironment.ts +32 -3
  13. package/runtime/events/predefined/ApprovedForAll.ts +16 -0
  14. package/runtime/events/predefined/TransferredBatchEvent.ts +35 -0
  15. package/runtime/events/predefined/TransferredSingleEvent.ts +18 -0
  16. package/runtime/events/predefined/URIEvent.ts +23 -0
  17. package/runtime/events/predefined/index.ts +4 -0
  18. package/runtime/index.ts +9 -0
  19. package/runtime/math/abi.ts +23 -0
  20. package/runtime/math/bytes.ts +4 -0
  21. package/runtime/memory/AddressMemoryMap.ts +20 -0
  22. package/runtime/nested/storage/StorageMap.ts +3 -23
  23. package/runtime/nested/storage/StorageSet.ts +6 -3
  24. package/runtime/script/Script.ts +1 -1
  25. package/runtime/secp256k1/ECPoint.ts +3 -3
  26. package/runtime/shared-libraries/OP20Utils.ts +1 -2
  27. package/runtime/storage/AdvancedStoredString.ts +8 -189
  28. package/runtime/storage/BaseStoredString.ts +206 -0
  29. package/runtime/storage/StoredString.ts +15 -194
  30. package/runtime/storage/arrays/StoredPackedArray.ts +13 -4
  31. package/runtime/types/SafeMath.ts +125 -94
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@btc-vision/btc-runtime",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
- "scripts": {},
6
+ "scripts": {
7
+ "test": "asp --config as-pect.config.js --verbose --no-logo",
8
+ "test:ci": "asp --config as-pect.config.js --summary --no-logo"
9
+ },
7
10
  "types": "btc/index.ts",
8
11
  "keywords": [
9
12
  "bitcoin",
@@ -17,6 +20,11 @@
17
20
  "author": "BlobMaster41",
18
21
  "license": "MIT",
19
22
  "devDependencies": {
23
+ "@btc-vision/as-covers-assembly": "^0.4.4",
24
+ "@btc-vision/as-covers-transform": "^0.4.4",
25
+ "@btc-vision/as-pect-assembly": "^8.2.0",
26
+ "@btc-vision/as-pect-cli": "^8.2.0",
27
+ "@btc-vision/as-pect-transform": "^8.2.0",
20
28
  "@types/node": "^24.2.1",
21
29
  "assemblyscript": "^0.28.4"
22
30
  },
@@ -37,11 +45,12 @@
37
45
  "dependencies": {
38
46
  "@assemblyscript/loader": "^0.28.4",
39
47
  "@btc-vision/as-bignum": "^0.0.5",
40
- "@btc-vision/opnet-transform": "^0.1.10",
48
+ "@btc-vision/opnet-transform": "^0.1.11",
41
49
  "@eslint/js": "^9.33.0",
42
50
  "gulplog": "^2.2.0",
43
51
  "ts-node": "^10.9.2",
44
52
  "typescript": "^5.9.2",
45
- "typescript-eslint": "^8.39.0"
53
+ "typescript-eslint": "^8.39.0",
54
+ "yaml": "^2.8.1"
46
55
  }
47
56
  }
@@ -0,0 +1,86 @@
1
+ // onOP20Received(address,address,uint256,bytes)
2
+ export const ON_OP20_RECEIVED_SELECTOR: u32 = 0xd83e7dbc;
3
+
4
+ // sha256("OP20AllowanceIncrease(address owner,address spender,uint256 amount,uint256 nonce,uint64 deadline)")
5
+ export const ALLOWANCE_INCREASE_TYPE_HASH: u8[] = [
6
+ 0x7e, 0x88, 0x02, 0xf1, 0xfd, 0x23, 0xe1, 0x0e, 0x0d, 0xde, 0x3f, 0x00, 0xc0, 0xaa, 0x48, 0x15,
7
+ 0xd8, 0x85, 0xec, 0xd9, 0xcd, 0xa0, 0xdf, 0x56, 0xff, 0xa2, 0x5e, 0xcc, 0x70, 0x2d, 0x45, 0x8e,
8
+ ];
9
+
10
+ // sha256("OP20AllowanceDecrease(address owner,address spender,uint256 amount,uint256 nonce,uint64 deadline)")
11
+ export const ALLOWANCE_DECREASE_TYPE_HASH: u8[] = [
12
+ 0x70, 0x87, 0x99, 0x34, 0x92, 0x1c, 0x2f, 0x48, 0x17, 0x78, 0x87, 0x89, 0x77, 0xd5, 0xb4, 0x5e,
13
+ 0x2a, 0x59, 0xda, 0x1d, 0x28, 0x22, 0x41, 0xc9, 0x3f, 0xf1, 0xba, 0x6a, 0xf0, 0x98, 0xfc, 0xd0,
14
+ ];
15
+
16
+ // onOP721Received(address,address,uint256,bytes)
17
+ export const ON_OP721_RECEIVED_SELECTOR: u32 = 0xd83e7dbc;
18
+
19
+ // onOP1155Received(address,address,uint256,uint256,bytes)
20
+ export const ON_OP1155_RECEIVED_MAGIC: u32 = 0xcedc9fdf;
21
+
22
+ // onOP1155BatchReceived(address,address,uint256[],uint256[],bytes)
23
+ export const ON_OP1155_BATCH_RECEIVED_MAGIC: u32 = 0x5d95545f;
24
+
25
+ // Interface IDs
26
+ // balanceOf(address,uint256) -> 0x7ab6c0bc
27
+ // balanceOfBatch(address[],uint256[]) -> 0xed4db4b0
28
+ // safeTransferFrom(address,address,uint256,uint256,bytes) -> 0x0875aead
29
+ // safeBatchTransferFrom(address,address,uint256[],uint256[],bytes) -> 0x1917c486
30
+ // setApprovalForAll(address,bool) -> 0xd97fb4c0
31
+ // isApprovedForAll(address,address) -> 0x67da1fb2
32
+ export const INTERFACE_ID_OP1155: u32 = 0x383cb555;
33
+
34
+ // sha256("uri(uint256)")
35
+ export const INTERFACE_ID_OP1155_METADATA_URI: u32 = 0x31473f54;
36
+
37
+ // sha256("supportsInterface(bytes4)")
38
+ export const INTERFACE_ID_ERC165: u32 = 0x0e2b7fe2;
39
+
40
+ // OP1155Transfer(address from,address to,uint256 id,uint256 amount,uint256 nonce,uint64 deadline)
41
+ export const OP1155_TRANSFER_TYPE_HASH: u8[] = [
42
+ 0x5a, 0x64, 0x2c, 0xa2, 0xd8, 0xfd, 0xe9, 0xe1, 0x28, 0x87, 0x7c, 0xf5, 0x5d, 0x71, 0x96, 0xe3,
43
+ 0x3a, 0xd4, 0x4b, 0xb3, 0x4b, 0x0a, 0x8d, 0x85, 0x8d, 0xa8, 0x04, 0xbd, 0x3b, 0x86, 0x21, 0x0e,
44
+ ];
45
+
46
+ // OP1155BatchTransfer(address from,address to,uint256[] ids,uint256[] amounts,uint256 nonce,uint64 deadline)
47
+ export const OP1155_BATCH_TRANSFER_TYPE_HASH: u8[] = [
48
+ 0x7b, 0xf8, 0xb6, 0x39, 0x5f, 0xea, 0xcc, 0x15, 0x97, 0x12, 0x38, 0x00, 0x91, 0xb9, 0x2b, 0x96,
49
+ 0x67, 0x6b, 0x2b, 0x73, 0x46, 0xff, 0x29, 0x27, 0xbf, 0x1a, 0x54, 0xf8, 0xfc, 0xef, 0x9c, 0x0b,
50
+ ];
51
+
52
+ // sha256("OP712Domain(string name,string version,bytes32 chainId,bytes32 protocolId,address verifyingContract)")
53
+ export const OP712_DOMAIN_TYPE_HASH: u8[] = [
54
+ 0xfe, 0xe8, 0x22, 0x92, 0x35, 0x1d, 0x1a, 0x8b, 0xab, 0x21, 0xc4, 0xef, 0xdd, 0x15, 0x7e, 0x31,
55
+ 0x68, 0xe8, 0xf6, 0x32, 0x3a, 0xd0, 0x4c, 0xba, 0x12, 0xf7, 0x7c, 0x0b, 0xdc, 0x46, 0x22, 0x58,
56
+ ];
57
+
58
+ // sha256("1")
59
+ export const OP712_VERSION_HASH: u8[] = [
60
+ 0x6b, 0x86, 0xb2, 0x73, 0xff, 0x34, 0xfc, 0xe1, 0x9d, 0x6b, 0x80, 0x4e, 0xff, 0x5a, 0x3f, 0x57,
61
+ 0x47, 0xad, 0xa4, 0xea, 0xa2, 0x2f, 0x1d, 0x49, 0xc0, 0x1e, 0x52, 0xdd, 0xb7, 0x87, 0x5b, 0x4b,
62
+ ];
63
+
64
+ // sha256("OP721Approve(address owner,address spender,uint256 tokenId,uint256 nonce,uint64 deadline)")
65
+ export const OP721_APPROVE_TYPE_HASH: u8[] = [
66
+ 0x2e, 0x4b, 0x1b, 0xb9, 0x26, 0xd1, 0xfe, 0x9c, 0x56, 0x8a, 0xca, 0xc1, 0xb9, 0xfc, 0x8b, 0x98,
67
+ 0xf5, 0xfe, 0x67, 0xcb, 0x7b, 0x6d, 0x12, 0x03, 0x69, 0xaf, 0x3d, 0xb8, 0x44, 0x67, 0xb4, 0xcb,
68
+ ];
69
+
70
+ // sha256("OP721Transfer(address from,address to,uint256 tokenId,uint256 nonce,uint64 deadline)")
71
+ export const OP721_TRANSFER_TYPE_HASH: u8[] = [
72
+ 0xf9, 0x03, 0xd7, 0xbe, 0x0c, 0xa4, 0x99, 0xee, 0x6d, 0x7d, 0x46, 0x22, 0xc7, 0x92, 0xb2, 0xea,
73
+ 0x64, 0xab, 0xa6, 0xaf, 0x68, 0x51, 0x03, 0xfe, 0xc4, 0xae, 0x12, 0xd7, 0xa6, 0xa9, 0xb2, 0x0f,
74
+ ];
75
+
76
+ export const BALANCE_OF_SELECTOR: u32 = 0x5b46f8f6; // "balanceOf(address)"
77
+ export const ALLOWANCE_SELECTOR: u32 = 0xd864b7ca; // "allowance(address,address)"
78
+ export const TOTAL_SUPPLY_SELECTOR: u32 = 0xa368022e; // "totalSupply()"
79
+ export const NAME_SELECTOR: u32 = 0x1581f81c; // "name()"
80
+ export const SYMBOL_SELECTOR: u32 = 0x25967ca5; // "symbol()"
81
+ export const DECIMALS_SELECTOR: u32 = 0xbb844440; // "decimals()"
82
+ export const NONCE_OF_SELECTOR: u32 = 0xf6824b65; // "nonceOf(address)"
83
+ export const DOMAIN_SEPARATOR_SELECTOR:u32 = 0xf1bf80e0; // "domainSeparator()"
84
+ export const METADATA_SELECTOR: u32 = 0xfc0d115c; // "metadata()"
85
+ export const MAXIMUM_SUPPLY_SELECTOR: u32 = 0x7d8d5019; // "maximumSupply()"
86
+ export const ICON_SELECTOR: u32 = 0xaaaa50c5; // "icon()"