commit 4e92f53c42f59a1a032c1dbaa7e98650390c0ca3
parent 6802d8018d8b85e7e119a0f1d136a0cdb21c664a
Author: lash <dev@holbrook.no>
Date: Mon, 13 Mar 2023 12:22:15 +0000
Make core abstract
Diffstat:
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/solidity/OfflineMinter.sol b/solidity/OfflineMinter.sol
@@ -1,10 +1,12 @@
pragma solidity ^0.8.0;
-contract OfflineMinter {
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+abstract contract OfflineMinter {
bytes26 constant prefix = bytes26(abi.encodePacked("0x19457468657265756d205369676e6564204d6573736167653a0a"));
- function verifyRequest(address _owner, bytes memory _data, bytes memory _signature) public pure returns(bool) {
+ function verifyRequest(address _owner, bytes memory _data, bytes memory _signature) public view returns(bool) {
address beneficiary;
bytes memory extra;
bytes memory message;
@@ -13,11 +15,11 @@ contract OfflineMinter {
uint256 messageLengthLength;
(beneficiary, extra) = splitData(_data);
- messageLength = uintToString(uint(_data.length));
+ messageLength = uintToString(uint(_data.length + 20));
messageLengthLength = bytes(messageLength).length;
- message = new bytes(_data.length + 26 + messageLengthLength);
- messageDigest = keccak256(abi.encodePacked(prefix, messageLength, _data));
+ message = new bytes(_data.length + 46 + messageLengthLength);
+ messageDigest = keccak256(abi.encodePacked(prefix, messageLength, address(this), _data));
return _owner == recoverSigner(messageDigest, _signature);
}
@@ -41,9 +43,7 @@ contract OfflineMinter {
return (address(bytes20(beneficiary)), extra);
}
- function verifyExtraData(bytes memory _data) public pure {
- revert('verification not implemented');
- }
+ function verifyExtraData(bytes memory _data) public virtual pure;
// from https://solidity-by-example.org/signature/
function recoverSigner(bytes32 _ethSignedMessageHash, bytes memory _signature) public pure returns (address) {
@@ -76,6 +76,7 @@ contract OfflineMinter {
// implicitly return (r, s, v)
}
+ // https://ethereum.stackexchange.com/questions/10811/solidity-concatenate-uint-into-a-string
function uintToString(uint v) public pure returns (string memory str) {
uint maxlength = 100;
bytes memory reversed = new bytes(maxlength);
diff --git a/solidity/OfflineMinterImplement.sol b/solidity/OfflineMinterImplement.sol
@@ -0,0 +1,12 @@
+pragma solidity ^0.8.0;
+
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+import './OfflineMinter.sol';
+
+contract OfflineMinterImpl is OfflineMinter {
+
+ function verifyExtraData(bytes memory _data) public override pure {
+ _data;
+ }
+}