-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 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,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "./gwt.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract PSTBridge is Ownable { | ||
GWT public gwt; | ||
|
||
// PST到GWT的兑换 | ||
mapping(bytes32 => uint256) public pst_to_gwt; | ||
|
||
constructor(address _gwt) Ownable(msg.sender) { | ||
gwt = GWT(_gwt); | ||
} | ||
|
||
function getClaimableGWT(string calldata cookie) public view returns (uint256) { | ||
return pst_to_gwt[keccak256(abi.encodePacked(msg.sender, cookie))]; | ||
} | ||
|
||
function registerPST(address[] calldata recvAddress, string[] calldata cookie, uint256[] calldata pstAmount) onlyOwner public { | ||
for (uint i = 0; i < recvAddress.length; i++) { | ||
pst_to_gwt[keccak256(abi.encodePacked(recvAddress[i], cookie[i]))] = pstAmount[i] / 210; | ||
} | ||
} | ||
|
||
function claimGWT(string calldata cookie) public { | ||
bytes32 key = keccak256(abi.encodePacked(msg.sender, cookie)); | ||
require(pst_to_gwt[key] > 0, "no dmc1 amount"); | ||
uint256 gwtAmount = pst_to_gwt[key]; | ||
pst_to_gwt[key] = 0; | ||
|
||
gwt.mint(msg.sender, gwtAmount); | ||
} | ||
} |