Skip to content

Commit

Permalink
Kernel: swap order of initializePayload and setDefault arguments in n…
Browse files Browse the repository at this point in the history
…ewAppInstance()
  • Loading branch information
sohkai committed Sep 3, 2018
1 parent fb06a15 commit f4bb44c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions contracts/factory/APMRegistryFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ contract APMRegistryFactory is APMRegistryConstants {
dao.newAppInstance(
keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(ENS_SUB_APP_NAME)))),
ensSubdomainRegistrarBase,
false,
noInit
noInit,
false
)
);
APMRegistry apm = APMRegistry(
dao.newAppInstance(
keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(APM_APP_NAME)))),
registryBase,
false,
noInit
noInit,
false
)
);

Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/EVMScriptRegistryFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract EVMScriptRegistryFactory is AppProxyFactory, EVMScriptRegistryConstants

function newEVMScriptRegistry(Kernel _dao) public returns (EVMScriptRegistry reg) {
bytes memory initPayload = abi.encodeWithSelector(reg.initialize.selector);
reg = EVMScriptRegistry(_dao.newPinnedAppInstance(EVMSCRIPT_REGISTRY_APP_ID, baseReg, true, initPayload));
reg = EVMScriptRegistry(_dao.newPinnedAppInstance(EVMSCRIPT_REGISTRY_APP_ID, baseReg, initPayload, true));

ACL acl = ACL(_dao.acl());

Expand Down
12 changes: 6 additions & 6 deletions contracts/kernel/Kernel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ contract Kernel is IKernel, KernelStorage, Petrifiable, IsContract, VaultRecover
auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _appId))
returns (ERCProxy appProxy)
{
return newAppInstance(_appId, _appBase, false, new bytes(0));
return newAppInstance(_appId, _appBase, new bytes(0), false);
}

/**
* @dev Create a new instance of an app linked to this kernel and set its base
* implementation if it was not already set
* @param _appId Identifier for app
* @param _appBase Address of the app's base implementation
* @param _initializePayload Payload for call made by the proxy during its construction to initialize
* @param _setDefault Whether the app proxy app is the default one.
* Useful when the Kernel needs to know of an instance of a particular app,
* like Vault for escape hatch mechanism.
* @param _initializePayload Payload for call made by the proxy on its constructor to initialize
* @return AppProxy instance
*/
function newAppInstance(bytes32 _appId, address _appBase, bool _setDefault, bytes _initializePayload)
function newAppInstance(bytes32 _appId, address _appBase, bytes _initializePayload, bool _setDefault)
public
auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _appId))
returns (ERCProxy appProxy)
Expand All @@ -98,21 +98,21 @@ contract Kernel is IKernel, KernelStorage, Petrifiable, IsContract, VaultRecover
auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _appId))
returns (ERCProxy appProxy)
{
return newPinnedAppInstance(_appId, _appBase, false, new bytes(0));
return newPinnedAppInstance(_appId, _appBase, new bytes(0), false);
}

/**
* @dev Create a new pinned instance of an app linked to this kernel and set
* its base implementation if it was not already set
* @param _appId Identifier for app
* @param _appBase Address of the app's base implementation
* @param _initializePayload Payload for call made by the proxy during its construction to initialize
* @param _setDefault Whether the app proxy app is the default one.
* Useful when the Kernel needs to know of an instance of a particular app,
* like Vault for escape hatch mechanism.
* @param _initializePayload Payload for call made by the proxy on its constructor to initialize
* @return AppProxy instance
*/
function newPinnedAppInstance(bytes32 _appId, address _appBase, bool _setDefault, bytes _initializePayload)
function newPinnedAppInstance(bytes32 _appId, address _appBase, bytes _initializePayload, bool _setDefault)
public
auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _appId))
returns (ERCProxy appProxy)
Expand Down
8 changes: 4 additions & 4 deletions contracts/test/mocks/APMRegistryFactoryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ contract APMRegistryFactoryMock is APMRegistryFactory {
dao.newAppInstance(
keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(ENS_SUB_APP_NAME)))),
ensSubdomainRegistrarBase,
false,
noInit
noInit,
false
)
);
APMRegistry apm = APMRegistry(
dao.newAppInstance(
keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(APM_APP_NAME)))),
registryBase,
false,
noInit
noInit,
false
)
);

Expand Down
12 changes: 6 additions & 6 deletions contracts/test/mocks/KernelOverloadMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ contract KernelOverloadMock {
kernel = Kernel(_kernel);
}

//function newAppInstance(bytes32 _name, address _appBase, bool _setDefault, bytes _initializePayload) auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _name)) public returns (ERCProxy appProxy) {
function newAppInstance(bytes32 _name, address _appBase, bool _setDefault, bytes _initializePayload) public returns (ERCProxy appProxy) {
appProxy = kernel.newAppInstance(_name, _appBase, _setDefault, _initializePayload);
//function newAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _name)) public returns (ERCProxy appProxy) {
function newAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) public returns (ERCProxy appProxy) {
appProxy = kernel.newAppInstance(_name, _appBase, _initializePayload, _setDefault);
emit NewAppProxy(appProxy);
}

// function newPinnedAppInstance(bytes32 _name, address _appBase, bool _setDefault, bytes _initializePayload) auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _name)) public returns (ERCProxy appProxy) {
function newPinnedAppInstance(bytes32 _name, address _appBase, bool _setDefault, bytes _initializePayload) public returns (ERCProxy appProxy) {
appProxy = kernel.newPinnedAppInstance(_name, _appBase, _setDefault, _initializePayload);
// function newPinnedAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _name)) public returns (ERCProxy appProxy) {
function newPinnedAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) public returns (ERCProxy appProxy) {
appProxy = kernel.newPinnedAppInstance(_name, _appBase, _initializePayload, _setDefault);
emit NewAppProxy(appProxy);
}
}
4 changes: 2 additions & 2 deletions test/kernel_apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ contract('Kernel apps', accounts => {
const kernelMock = await KernelOverloadMock.new(kernel.address)

await withAppManagerPermission(kernelMock.address, async () => {
const receipt = await kernelMock[newInstanceFn](APP_ID, appBase1.address, true, '0x')
const receipt = await kernelMock[newInstanceFn](APP_ID, appBase1.address, '0x', true)
appProxyAddr = receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
})

Expand All @@ -166,7 +166,7 @@ contract('Kernel apps', accounts => {
const initData = appBase1.initialize.request().params[0].data

await withAppManagerPermission(kernelMock.address, async () => {
const receipt = await kernelMock[newInstanceFn](APP_ID, appBase1.address, false, initData)
const receipt = await kernelMock[newInstanceFn](APP_ID, appBase1.address, initData, false)
appProxyAddr = receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
})

Expand Down

0 comments on commit f4bb44c

Please sign in to comment.