(save gas) bypass "transaction sstore" if multisigned not required
This commit is contained in:
parent
bcadf42cef
commit
905aff6485
|
@ -34,13 +34,18 @@ contract Identity is ERC725, ERC735 {
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier selfOnly {
|
modifier managementOnly {
|
||||||
require(
|
if(msg.sender == address(this)) {
|
||||||
msg.sender == address(this)
|
_;
|
||||||
);
|
} else {
|
||||||
_;
|
require(isKeyPurpose(bytes32(msg.sender), MANAGEMENT_KEY));
|
||||||
|
if (minimumApprovalsByKeyPurpose[MANAGEMENT_KEY] == 1) {
|
||||||
|
_;
|
||||||
|
} else {
|
||||||
|
execute(address(this), 0, msg.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier recoveryOnly {
|
modifier recoveryOnly {
|
||||||
require(
|
require(
|
||||||
recoveryContract != address(0) &&
|
recoveryContract != address(0) &&
|
||||||
|
@ -135,7 +140,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
uint256 _type
|
uint256 _type
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
selfOnly
|
managementOnly
|
||||||
returns (bool success)
|
returns (bool success)
|
||||||
{
|
{
|
||||||
_addKey(_key, _purpose, _type);
|
_addKey(_key, _purpose, _type);
|
||||||
|
@ -148,7 +153,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
uint256 _newType
|
uint256 _newType
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
selfOnly
|
managementOnly
|
||||||
returns (bool success)
|
returns (bool success)
|
||||||
{
|
{
|
||||||
uint256 purpose = keys[_oldKey].purpose;
|
uint256 purpose = keys[_oldKey].purpose;
|
||||||
|
@ -162,7 +167,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
uint256 _purpose
|
uint256 _purpose
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
selfOnly
|
managementOnly
|
||||||
returns (bool success)
|
returns (bool success)
|
||||||
{
|
{
|
||||||
_removeKey(_key, _purpose);
|
_removeKey(_key, _purpose);
|
||||||
|
@ -175,11 +180,20 @@ contract Identity is ERC725, ERC735 {
|
||||||
bytes _data
|
bytes _data
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
managerOrActor(bytes32(msg.sender))
|
|
||||||
returns (uint256 executionId)
|
returns (uint256 executionId)
|
||||||
{
|
{
|
||||||
executionId = _execute(_to, _value, _data);
|
uint256 requiredKey = _to == address(this) ? MANAGEMENT_KEY : ACTION_KEY;
|
||||||
approve(executionId, true);
|
if (minimumApprovalsByKeyPurpose[requiredKey] == 1) {
|
||||||
|
executionId = nonce;
|
||||||
|
nonce++;
|
||||||
|
require(isKeyPurpose(bytes32(msg.sender), requiredKey));
|
||||||
|
_to.call.value(_value)(_data);
|
||||||
|
emit Executed(executionId, _to, _value, _data);
|
||||||
|
} else {
|
||||||
|
executionId = _execute(_to, _value, _data);
|
||||||
|
approve(executionId, true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function approve(uint256 _id, bool _approval)
|
function approve(uint256 _id, bool _approval)
|
||||||
|
@ -195,7 +209,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
uint256 _minimumApprovals
|
uint256 _minimumApprovals
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
selfOnly
|
managementOnly
|
||||||
{
|
{
|
||||||
require(_minimumApprovals > 0);
|
require(_minimumApprovals > 0);
|
||||||
require(_minimumApprovals <= keysByPurpose[_purpose].length);
|
require(_minimumApprovals <= keysByPurpose[_purpose].length);
|
||||||
|
@ -412,7 +426,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
|
|
||||||
function setupRecovery(address _recoveryContract)
|
function setupRecovery(address _recoveryContract)
|
||||||
public
|
public
|
||||||
selfOnly
|
managementOnly
|
||||||
{
|
{
|
||||||
require(recoveryContract == address(0));
|
require(recoveryContract == address(0));
|
||||||
recoveryContract = _recoveryContract;
|
recoveryContract = _recoveryContract;
|
||||||
|
@ -455,7 +469,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
bool _approval
|
bool _approval
|
||||||
)
|
)
|
||||||
private
|
private
|
||||||
returns(bool success)
|
returns(bool success) //(?) should return approved instead of success?
|
||||||
{
|
{
|
||||||
|
|
||||||
Transaction storage trx = txx[_id];
|
Transaction storage trx = txx[_id];
|
||||||
|
@ -476,10 +490,11 @@ contract Identity is ERC725, ERC735 {
|
||||||
requiredKeyPurpose = ACTION_KEY;
|
requiredKeyPurpose = ACTION_KEY;
|
||||||
approvalCount = _calculateApprovals(actorKeyHash, _approval, trx);
|
approvalCount = _calculateApprovals(actorKeyHash, _approval, trx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (approvalCount >= minimumApprovalsByKeyPurpose[requiredKeyPurpose]) {
|
if (approvalCount >= minimumApprovalsByKeyPurpose[requiredKeyPurpose]) {
|
||||||
emit Executed(_id, trx.to, trx.value, trx.data);
|
//(?) success should be included in event?
|
||||||
success = trx.to.call.value(trx.value)(trx.data);
|
success = trx.to.call.value(trx.value)(trx.data);
|
||||||
|
emit Executed(_id, trx.to, trx.value, trx.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue