-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contracts: create account ownership implementation
- Loading branch information
1 parent
4158302
commit 8d0a5fa
Showing
2 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "./Stamp.sol"; | ||
|
||
contract AccountOwnershipStamp is Stamp { | ||
string public PLATFORM; | ||
|
||
error InvalidRecipient(); | ||
|
||
constructor( | ||
address _signer, | ||
string memory _platform | ||
) Stamp("Account Ownership Stamp", "AOS", "0.1.0", _signer) { | ||
PLATFORM = _platform; | ||
} | ||
|
||
function mintStamp( | ||
string calldata id, | ||
uint256 deadline, | ||
bytes calldata signature | ||
) external returns (uint256) { | ||
if (msg.sender == address(0)) revert InvalidRecipient(); | ||
|
||
bytes memory encodedData = abi.encode( | ||
PLATFORM, | ||
id, | ||
msg.sender, | ||
deadline | ||
); | ||
|
||
return _mintStamp(msg.sender, encodedData, signature, deadline); | ||
} | ||
|
||
function getTypedDataHash( | ||
bytes memory data | ||
) public pure override returns (bytes32) { | ||
( | ||
string memory platform, | ||
string memory id, | ||
address recipient, | ||
uint256 deadline | ||
) = abi.decode(data, (string, string, address, uint256)); | ||
|
||
return | ||
keccak256( | ||
abi.encode( | ||
keccak256( | ||
"AccountOwnership(string platform,string id,address recipient,uint256 deadline)" | ||
), | ||
keccak256(bytes(platform)), | ||
keccak256(bytes(id)), | ||
recipient, | ||
deadline | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters