Skip to content

Commit

Permalink
Merge branch 'hotfix/fix-container-factory-permissions'
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfraem committed Aug 29, 2019
2 parents c9ace5b + c3ba05c commit 5376600
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
5 changes: 5 additions & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
### Deprecations


## Version 2.6.1
### Fixes
- fix container factory permissions


## Version 2.6.0
### Features
- performance/cost optimizations for `ContainerDataContractFactory`
Expand Down
51 changes: 17 additions & 34 deletions contracts/ContainerDataContractFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,42 +70,25 @@ contract ContainerDataContractFactory is BaseContractFactory, EnsReader {

function createRoles(address owner, address newContract) public returns (DSRolesPerContract) {
DSRolesPerContract roles = super.createRoles(owner);

// roles
uint8 ownerRole = 0;
uint8 memberRole = 1;

// make contract root user of own roles config
roles.setRootUser(newContract, true);

uint8[] memory roles1;
assembly {
// Create an dynamic sized array manually.
// Don't need to define the data type here as the EVM will prefix it
roles1 := mload(0x40) // 0x40 is the address where next free memory slot is stored in Solidity.
mstore(add(roles1, 0x00), 9) // Set size to 14
// omit owner roles, as initial value for field is 0 and owner role id is 0
mstore(add(roles1, 0xc0), 1)
mstore(add(roles1, 0xe0), 1)
mstore(add(roles1, 0x0100), 1)
mstore(add(roles1, 0x0120), 1)
mstore(0x40, add(roles1, 0x0140)) // Update the msize offset to be our memory reference plus the amount of bytes we're using
}
bytes4[] memory sigs;
assembly {
// Create an dynamic sized array manually.
// Don't need to define the data type here as the EVM will prefix it
sigs := mload(0x40) // 0x40 is the address where next free memory slot is stored in Solidity.
mstore(add(sigs, 0x00), 9) // Set size to 14
mstore(add(sigs, 0x20), 0x9f99b6e7) // init(bytes32,bool)
mstore(add(sigs, 0x40), 0x13af4035) // setOwner(address)
mstore(add(sigs, 0x60), 0xb14f5d7e) // inviteConsumer(address,address)
mstore(add(sigs, 0x80), 0xa7b93d61) // removeConsumer(address,address)
mstore(add(sigs, 0xa0), 0xcf82c070) // moveListEntry(bytes32,uint256,bytes32[])
mstore(add(sigs, 0xc0), 0x6d948f50) // addListEntries(bytes32[],bytes32[])
mstore(add(sigs, 0xe0), 0xc0ff8ed5) // removeListEntry(bytes32,uint256)
mstore(add(sigs, 0x0100), 0x44dd44d6) // setEntry(bytes32,bytes32)
mstore(add(sigs, 0x0120), 0xb4f64c05) // setMappingValue(bytes32,bytes32,bytes32)
mstore(0x40, add(sigs, 0x0140)) // Update the msize offset to be our memory reference plus the amount of bytes we're using
}

roles.setRoleCapabilities(roles1, sigs, true);

// role 2 permission (contract owner)
roles.setRoleCapability(ownerRole, 0, 0x9f99b6e7, true); // init(bytes32,bool)
roles.setRoleCapability(ownerRole, 0, 0x13af4035, true); // setOwner(address)
roles.setRoleCapability(ownerRole, 0, 0xb14f5d7e, true); // inviteConsumer(address,address)
roles.setRoleCapability(ownerRole, 0, 0xa7b93d61, true); // removeConsumer(address,address)
roles.setRoleCapability(ownerRole, 0, 0xcf82c070, true); // moveListEntry(bytes32,uint256,bytes32[])

// role 2 permission (members)
roles.setRoleCapability(memberRole, 0, 0x6d948f50, true); // addListEntries(bytes32[],bytes32[])
roles.setRoleCapability(memberRole, 0, 0xc0ff8ed5, true); // removeListEntry(bytes32,uint256)
roles.setRoleCapability(memberRole, 0, 0x44dd44d6, true); // setEntry(bytes32,bytes32)
roles.setRoleCapability(memberRole, 0, 0xb4f64c05, true); // setMappingValue(bytes32,bytes32,bytes32)

return roles;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"scripts": {
"build-contracts": "node ./scripts/build-contracts.js"
},
"version": "2.6.0"
"version": "2.6.1"
}

0 comments on commit 5376600

Please sign in to comment.