Skip to content

Commit 3fde53c

Browse files
committed
expand test coverage
1 parent a381041 commit 3fde53c

File tree

3 files changed

+355
-10
lines changed

3 files changed

+355
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Contracts may also be deployed locally using `$ node scripts/deploy.js`.
9999
* remove attributes from participants as required.
100100

101101

102-
* A **TPLToken** is a standard [OpenZeppelin ERC20 token](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol) that enforces attribute checks during every token transfer. For this [implementation](https://github.com/TPL-protocol/tpl-contracts/blob/master/contracts/token/TPLRestrictedReceiverToken.sol), the token checks the jurisdiction's registry for an attribute used to whitelist valid token recipients. The additional overhead for each transaction in the minimum-case is **4156 gas**, with 1512 used to execute jurisdiction contract logic and 2644 for general "plumbing" (the overhead of checking against an external call to the registry that simply returns `true`). *(NOTE: the attributes defined in the jurisdiction and required by TPLToken have been arbitrarily defined for this PoC, and are not intended to serve as a proposal for the attributes that will be used for validating transactions.)*
102+
* An example **TPL-enabled ERC20** that uses a standard [OpenZeppelin ERC20 token](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol) to enforce attribute checks during every token transfer is also included. For this [implementation](https://github.com/TPL-protocol/tpl-contracts/blob/master/contracts/token/TPLRestrictedReceiverToken.sol), the token checks the jurisdiction's registry for an attribute used to whitelist valid token recipients. The additional overhead for each transaction in the minimum-case is **4156 gas**, with 1512 used to execute jurisdiction contract logic and 2644 for general "plumbing" (the overhead of checking against an external call to the registry that simply returns `true`). *(NOTE: the attributes defined in the jurisdiction and required by TPLToken have been arbitrarily defined for this PoC, and are not intended to serve as a proposal for the attributes that will be used for validating transactions.)*
103103

104104

105105
#### Attribute scope

contracts/Jurisdiction.sol

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ contract Jurisdiction is Ownable, Pausable, AttributeRegistryInterface, BasicJur
12961296
);
12971297
}
12981298

1299-
// users can check whether a signature for adding an attribute is still valid
1299+
// users can check whether a signed attribute approval is currently valid
13001300
function canAddAttribute(
13011301
uint256 attributeTypeID,
13021302
uint256 value,
@@ -1322,15 +1322,17 @@ contract Jurisdiction is Ownable, Pausable, AttributeRegistryInterface, BasicJur
13221322
uint256 minimumStake = _attributeTypes[attributeTypeID].minimumStake;
13231323
uint256 jurisdictionFee = _attributeTypes[attributeTypeID].jurisdictionFee;
13241324

1325-
// determine if the attribute can still be added
1325+
// determine if the attribute can currently be added.
1326+
// NOTE: consider returning an error code along with the boolean.
13261327
return (
13271328
fundsRequired >= minimumStake.add(jurisdictionFee).add(validatorFee) &&
13281329
_invalidAttributeApprovalHashes[hash] == false &&
1329-
canValidate(validator, attributeTypeID)
1330+
canValidate(validator, attributeTypeID) &&
1331+
_issuedAttributes[msg.sender][attributeTypeID].exists == false
13301332
);
13311333
}
13321334

1333-
// operators can check whether an attribute approval signature is still valid
1335+
// operators can check whether a signed attribute approval is currently valid
13341336
function canAddAttributeFor(
13351337
address account,
13361338
uint256 attributeTypeID,
@@ -1357,11 +1359,13 @@ contract Jurisdiction is Ownable, Pausable, AttributeRegistryInterface, BasicJur
13571359
uint256 minimumStake = _attributeTypes[attributeTypeID].minimumStake;
13581360
uint256 jurisdictionFee = _attributeTypes[attributeTypeID].jurisdictionFee;
13591361

1360-
// determine if the attribute can still be added
1362+
// determine if the attribute can currently be added.
1363+
// NOTE: consider returning an error code along with the boolean.
13611364
return (
13621365
fundsRequired >= minimumStake.add(jurisdictionFee).add(validatorFee) &&
13631366
_invalidAttributeApprovalHashes[hash] == false &&
1364-
canValidate(validator, attributeTypeID)
1367+
canValidate(validator, attributeTypeID) &&
1368+
_issuedAttributes[account][attributeTypeID].exists == false
13651369
);
13661370
}
13671371

0 commit comments

Comments
 (0)