-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the TPLToken #16
Open
come-maiz
wants to merge
1
commit into
TPL-protocol:master
Choose a base branch
from
come-maiz:tpl-token
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Use the TPLToken #16
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,18 +1,34 @@ | ||
pragma solidity ^0.4.21; | ||
|
||
import { Jurisdiction } from "./tpl-contracts/Jurisdiction.sol"; | ||
import { TransactionChecker } from "./tpl-contracts/checks/TransactionChecker.sol"; | ||
|
||
|
||
contract DummyValidator { | ||
contract DummyValidator is TransactionChecker { | ||
|
||
Jurisdiction jurisdiction; | ||
|
||
function DummyValidator(Jurisdiction _jurisdiction) public { | ||
function DummyValidator(Jurisdiction _jurisdiction) | ||
TransactionChecker(_jurisdiction) | ||
public | ||
{ | ||
jurisdiction = _jurisdiction; | ||
} | ||
|
||
function validate() public { | ||
jurisdiction.addAttribute(msg.sender, "VALID", 1); | ||
} | ||
|
||
function transferAllowed( | ||
address _from, | ||
address _to, | ||
uint256 _value | ||
) | ||
public | ||
view | ||
returns (bool) | ||
{ | ||
return registry.hasAttribute(_to, "VALID"); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol"; | ||
import { Jurisdiction } from "./tpl-contracts/Jurisdiction.sol"; | ||
import { TransactionChecker } from "./tpl-contracts/checks/TransactionChecker.sol"; | ||
import { TPLToken } from "./tpl-contracts/TPLToken.sol"; | ||
|
||
|
||
/** | ||
* @title SampleToken | ||
* @dev Mintable ERC20 Token. | ||
*/ | ||
contract SampleToken is MintableToken { | ||
|
||
Jurisdiction jurisdiction; | ||
contract SampleToken is TPLToken, MintableToken { | ||
|
||
string public constant name = "SampleToken"; // solium-disable-line uppercase | ||
string public constant symbol = "TPL"; // solium-disable-line uppercase | ||
uint8 public constant decimals = 18; // solium-disable-line uppercase | ||
|
||
function SampleToken(Jurisdiction _jurisdiction) public { | ||
jurisdiction = _jurisdiction; | ||
function SampleToken(TransactionChecker _validator) | ||
TPLToken(_validator) | ||
public | ||
{ | ||
totalSupply_ = 0; | ||
} | ||
|
||
|
@@ -27,17 +28,8 @@ contract SampleToken is MintableToken { | |
public | ||
returns (bool) | ||
{ | ||
require(jurisdiction.hasAttribute(_to, "VALID")); | ||
require(validator.transferAllowed(msg.sender, _to, _amount)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not clear in the TPL spec, but I think we should be checking |
||
return super.mint(_to, _amount); | ||
} | ||
|
||
function transfer(address _to, uint256 _value) public returns (bool) { | ||
require(jurisdiction.hasAttribute(_to, "VALID")); | ||
return super.transfer(_to, _value); | ||
} | ||
|
||
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { | ||
require(jurisdiction.hasAttribute(_to, "VALID")); | ||
return super.transferFrom(_from, _to, _value); | ||
} | ||
} |
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this weird, because the
Registry
doesn't haveaddAttribute
, justhasAttribute
.Maybe, the idea is to have a checker that just checks
hasAttribute
, and a validator that callsaddAttribute
.Or maybe we should include
addAttribute
toRegistry
, so it's nicer to do both on the same validator.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registry
seems to be the read-only interface ofJurisdiction
. 🤷♂️It looks good to me like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's weird is that now the validator has a variable called registry and another called jurisdiction, and they point to the same instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. I don't see a way out of this. We can't cast the
registry
variable safely because we don't know ifTransactionChecker
ever changes it to be something different.