diff --git a/src/main/resources/contract/solidity/0.8.26/BlobHashExample.sol b/src/main/resources/contract/solidity/0.8.26/BlobHashExample.sol new file mode 100644 index 00000000..32155a6c --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/BlobHashExample.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.6.10 <=0.8.26; + +contract BlobHashExample { + bytes public largeData = "This is a very large data blob that needs to be hashed efficiently."; + + function hashData() public view returns (bytes32) { + bytes32 result; + assembly { + result := blobhash(add(sload(largeData.slot), largeData.offset)) + } + return result; + } +} \ No newline at end of file diff --git a/src/main/resources/contract/solidity/0.8.26/ContractA.sol b/src/main/resources/contract/solidity/0.8.26/ContractA.sol new file mode 100644 index 00000000..bce0dba6 --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/ContractA.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.10 <=0.8.26; + +import "./StorageSlot.sol"; +import "./ContractB.sol"; + +contract ContractA { + using StorageSlot for *; + + StorageSlot.Int256SlotType private intSlot; + constructor(int256 value){ + StorageSlot.tstore(intSlot, value); + } + + function getData() public view returns (int256) { + return StorageSlot.tload(intSlot); + } + + function callContractB() public returns (int256){ + ContractB b = new ContractB(); + return b.callContractA(address(this)); + } + +} diff --git a/src/main/resources/contract/solidity/0.8.26/ContractB.sol b/src/main/resources/contract/solidity/0.8.26/ContractB.sol new file mode 100644 index 00000000..fa3ce177 --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/ContractB.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.10 <=0.8.26; + +import "./StorageSlot.sol"; +import "./ContractA.sol"; + + +contract ContractB { + + function callContractA(address a) public returns (int256){ + ContractA a = ContractA(a); + int256 result = a.getData(); + return result; + } + +} diff --git a/src/main/resources/contract/solidity/0.8.26/MainContract.sol b/src/main/resources/contract/solidity/0.8.26/MainContract.sol new file mode 100644 index 00000000..e393e69d --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/MainContract.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.10 <=0.8.26; + +import "./StorageSlot.sol"; +import "./ContractA.sol"; +import "./ContractB.sol"; + +contract MainContract { + + function checkAndVerifyIntValue(int256 value) public returns (bool) { + ContractA a = new ContractA(value); + int256 result = a.callContractB(); + require(result == value, "store value not equal tload result"); + return true; + } +} \ No newline at end of file diff --git a/src/main/resources/contract/solidity/0.8.26/Mcopy.sol b/src/main/resources/contract/solidity/0.8.26/Mcopy.sol new file mode 100644 index 00000000..52928f8f --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/Mcopy.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.10 <=0.8.26; + +contract Mcopy { + function memoryCopy() external pure returns (bytes32 x) { + assembly { + mstore(0x20, 0x50) // Store 0x50 at word 1 in memory + mcopy(0, 0x20, 0x20) // Copies 0x50 to word 0 in memory + x := mload(0) // Returns 32 bytes "0x50" + } + } +} diff --git a/src/main/resources/contract/solidity/0.8.26/StorageContract.sol b/src/main/resources/contract/solidity/0.8.26/StorageContract.sol new file mode 100644 index 00000000..44138493 --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/StorageContract.sol @@ -0,0 +1,78 @@ +pragma solidity >=0.6.10 <=0.8.26; + +import "./StorageSlot.sol"; + +contract StorageContract { + using StorageSlot for *; + + StorageSlot.AddressSlotType private addressSlot = StorageSlot.asAddress(keccak256("address_slot")); + StorageSlot.BooleanSlotType private booleanSlot = StorageSlot.asBoolean(keccak256("boolean_slot")); + StorageSlot.Bytes32SlotType private bytes32Slot = StorageSlot.asBytes32(keccak256("bytes32_slot")); + StorageSlot.Uint256SlotType private uint256Slot = StorageSlot.asUint256(keccak256("uint256_slot")); + StorageSlot.Int256SlotType private int256Slot = StorageSlot.asInt256(keccak256("int256_slot")); + + function setAddress(address _value) public { + addressSlot.tstore(_value); + } + + function getAddress() public view returns (address) { + return addressSlot.tload(); + } + + function setBoolean(bool _value) public { + booleanSlot.tstore(_value); + } + + function getBoolean() public view returns (bool) { + return booleanSlot.tload(); + } + + function setBytes32(bytes32 _value) public { + bytes32Slot.tstore(_value); + } + + function getBytes32() public view returns (bytes32) { + return bytes32Slot.tload(); + } + + function setUint256(uint256 _value) public { + uint256Slot.tstore(_value); + } + + function getUint256() public view returns (uint256) { + return uint256Slot.tload(); + } + + function setInt256(int256 _value) public { + int256Slot.tstore(_value); + } + + function getInt256() public view returns (int256) { + return int256Slot.tload(); + } + + function storeIntTest(int256 _value) public returns (int256) { + int256Slot.tstore(_value); + return int256Slot.tload(); + } + + function storeUintTest(uint256 _value) public returns (uint256) { + uint256Slot.tstore(_value); + return uint256Slot.tload(); + } + + function storeBytes32Test(bytes32 _value) public returns (bytes32) { + bytes32Slot.tstore(_value); + return bytes32Slot.tload(); + } + + function storeBooleanTest(bool _value) public returns (bool) { + booleanSlot.tstore(_value); + return booleanSlot.tload(); + } + + function storeAddressTest(address _value) public returns (address) { + addressSlot.tstore(_value); + return addressSlot.tload(); + } +} \ No newline at end of file diff --git a/src/main/resources/contract/solidity/0.8.26/StorageSlot.sol b/src/main/resources/contract/solidity/0.8.26/StorageSlot.sol new file mode 100644 index 00000000..ac0a2684 --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/StorageSlot.sol @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.10 <=0.8.26; + +library StorageSlot { + struct AddressSlot { + address value; + } + + struct BooleanSlot { + bool value; + } + + struct Bytes32Slot { + bytes32 value; + } + + struct Uint256Slot { + uint256 value; + } + + struct Int256Slot { + int256 value; + } + + struct StringSlot { + string value; + } + + struct BytesSlot { + bytes value; + } + + function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { + assembly { + r.slot := slot + } + } + + function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := store.slot + } + } + + function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := store.slot + } + } + + type AddressSlotType is bytes32; + + function asAddress(bytes32 slot) internal pure returns (AddressSlotType) { + return AddressSlotType.wrap(slot); + } + + type BooleanSlotType is bytes32; + + function asBoolean(bytes32 slot) internal pure returns (BooleanSlotType) { + return BooleanSlotType.wrap(slot); + } + + type Bytes32SlotType is bytes32; + + function asBytes32(bytes32 slot) internal pure returns (Bytes32SlotType) { + return Bytes32SlotType.wrap(slot); + } + + type Uint256SlotType is bytes32; + + function asUint256(bytes32 slot) internal pure returns (Uint256SlotType) { + return Uint256SlotType.wrap(slot); + } + + type Int256SlotType is bytes32; + + function asInt256(bytes32 slot) internal pure returns (Int256SlotType) { + return Int256SlotType.wrap(slot); + } + + function tload(AddressSlotType slot) internal view returns (address value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(AddressSlotType slot, address value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(BooleanSlotType slot) internal view returns (bool value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(BooleanSlotType slot, bool value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(Bytes32SlotType slot) internal view returns (bytes32 value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(Bytes32SlotType slot, bytes32 value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(Uint256SlotType slot) internal view returns (uint256 value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(Uint256SlotType slot, uint256 value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(Int256SlotType slot) internal view returns (int256 value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(Int256SlotType slot, int256 value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } +} diff --git a/src/main/resources/contract/solidity/0.8.26/blobBaseFee.sol b/src/main/resources/contract/solidity/0.8.26/blobBaseFee.sol new file mode 100644 index 00000000..d2b1ca3d --- /dev/null +++ b/src/main/resources/contract/solidity/0.8.26/blobBaseFee.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.10 <=0.8.26; + +contract blobBaseFee { + function getBlobBaseFeeYul() external view returns (uint256 blobBaseFee) { + assembly { + blobBaseFee := blobbasefee() + } + } + + function getBlobBaseFeeSolidity() external view returns (uint256 blobBaseFee) { + blobBaseFee = block.blobbasefee; + } +} \ No newline at end of file diff --git a/src/main/resources/contract/solidity/Asset.sol b/src/main/resources/contract/solidity/Asset.sol index 206c0c37..2bee529b 100644 --- a/src/main/resources/contract/solidity/Asset.sol +++ b/src/main/resources/contract/solidity/Asset.sol @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; + pragma experimental ABIEncoderV2; import "./Table.sol"; diff --git a/src/main/resources/contract/solidity/Cast.sol b/src/main/resources/contract/solidity/Cast.sol index 892ef20e..50ff963e 100644 --- a/src/main/resources/contract/solidity/Cast.sol +++ b/src/main/resources/contract/solidity/Cast.sol @@ -1,12 +1,17 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; + pragma experimental ABIEncoderV2; abstract contract Cast { function stringToS256(string memory) public virtual view returns (int256); + function stringToS64(string memory) public virtual view returns (int64); + function stringToU256(string memory) public virtual view returns (uint256); + function stringToAddr(string memory) public virtual view returns (address); + function stringToBytes32(string memory) public virtual view returns (bytes32); function s256ToString(int256) public virtual view returns (string memory); diff --git a/src/main/resources/contract/solidity/CastTest.sol b/src/main/resources/contract/solidity/CastTest.sol index 05e7f362..584f5877 100644 --- a/src/main/resources/contract/solidity/CastTest.sol +++ b/src/main/resources/contract/solidity/CastTest.sol @@ -1,13 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; import "./Cast.sol"; contract CastTest { - Cast constant cast = Cast(address(0x100f)); + Cast constant cast = Cast(address(0x100f)); + function stringToS256(string memory _s) public virtual view returns (int256){ return cast.stringToS256(_s); } + function stringToS64(string memory _s) public virtual view returns (int64){ return cast.stringToS64(_s); } diff --git a/src/main/resources/contract/solidity/Crypto.sol b/src/main/resources/contract/solidity/Crypto.sol index 8e11f6db..88ef5a64 100644 --- a/src/main/resources/contract/solidity/Crypto.sol +++ b/src/main/resources/contract/solidity/Crypto.sol @@ -1,9 +1,14 @@ -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; + pragma experimental ABIEncoderV2; + abstract contract Crypto { - function sm3(bytes memory data) public view returns(bytes32){} - function keccak256Hash(bytes memory data) public view returns(bytes32){} - function sm2Verify(bytes32 message, bytes memory publicKey, bytes32 r, bytes32 s) public view returns(bool, address){} - function curve25519VRFVerify(bytes memory message, bytes memory publicKey, bytes memory proof) public view returns(bool, uint256){} + function sm3(bytes memory data) public view returns (bytes32){} + + function keccak256Hash(bytes memory data) public view returns (bytes32){} + + function sm2Verify(bytes32 message, bytes memory publicKey, bytes32 r, bytes32 s) public view returns (bool, address){} + + function curve25519VRFVerify(bytes memory message, bytes memory publicKey, bytes memory proof) public view returns (bool, uint256){} } diff --git a/src/main/resources/contract/solidity/DelegateCallTest.sol b/src/main/resources/contract/solidity/DelegateCallTest.sol index 9c1b0314..716baaa8 100644 --- a/src/main/resources/contract/solidity/DelegateCallTest.sol +++ b/src/main/resources/contract/solidity/DelegateCallTest.sol @@ -1,5 +1,4 @@ -pragma solidity>=0.6.10 <0.8.20; - +pragma solidity >=0.6.10 <=0.8.26; contract DelegateCallDest { int public value = 0; diff --git a/src/main/resources/contract/solidity/EntryWrapper.sol b/src/main/resources/contract/solidity/EntryWrapper.sol index 19fac251..b44f0a4b 100644 --- a/src/main/resources/contract/solidity/EntryWrapper.sol +++ b/src/main/resources/contract/solidity/EntryWrapper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; pragma experimental ABIEncoderV2; import "./Cast.sol"; diff --git a/src/main/resources/contract/solidity/EventSubDemo.sol b/src/main/resources/contract/solidity/EventSubDemo.sol index e08eff8f..d6cd08f8 100644 --- a/src/main/resources/contract/solidity/EventSubDemo.sol +++ b/src/main/resources/contract/solidity/EventSubDemo.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity>=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; contract EventSubDemo { diff --git a/src/main/resources/contract/solidity/HelloWorld.sol b/src/main/resources/contract/solidity/HelloWorld.sol index d50f4d7d..1b429432 100644 --- a/src/main/resources/contract/solidity/HelloWorld.sol +++ b/src/main/resources/contract/solidity/HelloWorld.sol @@ -1,4 +1,4 @@ -pragma solidity>=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; contract HelloWorld { string name; diff --git a/src/main/resources/contract/solidity/KVTableTest.sol b/src/main/resources/contract/solidity/KVTableTest.sol index 2f249464..f9a497a9 100644 --- a/src/main/resources/contract/solidity/KVTableTest.sol +++ b/src/main/resources/contract/solidity/KVTableTest.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; pragma experimental ABIEncoderV2; import "./Table.sol"; diff --git a/src/main/resources/contract/solidity/ShaTest.sol b/src/main/resources/contract/solidity/ShaTest.sol index a573d1bf..9b4935c4 100644 --- a/src/main/resources/contract/solidity/ShaTest.sol +++ b/src/main/resources/contract/solidity/ShaTest.sol @@ -1,6 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity>=0.6.10 <0.8.20; - +pragma solidity >=0.6.10 <=0.8.26; pragma experimental ABIEncoderV2; import "./Crypto.sol"; diff --git a/src/main/resources/contract/solidity/Table.sol b/src/main/resources/contract/solidity/Table.sol index 65169a9e..2232a40b 100644 --- a/src/main/resources/contract/solidity/Table.sol +++ b/src/main/resources/contract/solidity/Table.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // 该接口文件定义了FISCO BCOS v3.1.0及以前版本的接口,使用时需要将该文件放在合约目录下 // 若要使用FISCO BCOS v3.2.0及以后版本的接口,请使用TableV320.sol,旧合约仍然能在新节点中使用 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; pragma experimental ABIEncoderV2; // KeyOrder指定Key的排序规则,字典序和数字序,如果指定为数字序,key只能为数字 diff --git a/src/main/resources/contract/solidity/TableTest.sol b/src/main/resources/contract/solidity/TableTest.sol index 05ba86b4..c3779825 100644 --- a/src/main/resources/contract/solidity/TableTest.sol +++ b/src/main/resources/contract/solidity/TableTest.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; pragma experimental ABIEncoderV2; import "./Table.sol"; diff --git a/src/main/resources/contract/solidity/TableTestV320.sol b/src/main/resources/contract/solidity/TableTestV320.sol index e3198c7b..56c9995a 100644 --- a/src/main/resources/contract/solidity/TableTestV320.sol +++ b/src/main/resources/contract/solidity/TableTestV320.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; pragma experimental ABIEncoderV2; import "./TableV320.sol"; diff --git a/src/main/resources/contract/solidity/TableV320.sol b/src/main/resources/contract/solidity/TableV320.sol index 6c8a70c7..9dfb212b 100644 --- a/src/main/resources/contract/solidity/TableV320.sol +++ b/src/main/resources/contract/solidity/TableV320.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // 该接口文件定义了FISCO BCOS v3.2.0及以后版本的接口,使用时需要将该文件放在合约目录下 // 若要使用FISCO BCOS v3.1.0及以前版本的接口,请使用Table.sol,旧合约仍然能在新节点中使用 -pragma solidity >=0.6.10 <0.8.20; +pragma solidity >=0.6.10 <=0.8.26; pragma experimental ABIEncoderV2; import "./EntryWrapper.sol";