updated dsa provider module (#5)

This commit is contained in:
Hilmar X 2020-09-05 14:58:18 +02:00 committed by GitHub
parent ec0ffb687b
commit bc88e48c6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 83 additions and 15 deletions

View File

@ -59,22 +59,24 @@ contract ProviderModuleDSA is GelatoProviderModuleStandard {
if (!AccountInterface(_userProxy).isAuth(gelatoCore)) if (!AccountInterface(_userProxy).isAuth(gelatoCore))
return "ProviderModuleDSA.isProvided:GelatoCoreNotAuth"; return "ProviderModuleDSA.isProvided:GelatoCoreNotAuth";
// Is connector valid // @dev commented out for gas savings
ConnectorsInterface connectors = ConnectorsInterface(index.connectors(
AccountInterface(_userProxy).version()
));
address[] memory targets = new address[](_task.actions.length); // // Is connector valid
for (uint i = 0; i < _task.actions.length; i++) // ConnectorsInterface connectors = ConnectorsInterface(index.connectors(
targets[i] = _task.actions[i].addr; // AccountInterface(_userProxy).version()
// ));
bool isShield = AccountInterface(_userProxy).shield(); // address[] memory targets = new address[](_task.actions.length);
if (isShield) // for (uint i = 0; i < _task.actions.length; i++)
if (!connectors.isStaticConnector(targets)) // targets[i] = _task.actions[i].addr;
return "ProviderModuleDSA.isProvided:not-static-connector";
else // bool isShield = AccountInterface(_userProxy).shield();
if (!connectors.isConnector(targets)) // if (isShield)
return "ProviderModuleDSA.isProvided:not-connector"; // if (!connectors.isStaticConnector(targets))
// return "ProviderModuleDSA.isProvided:not-static-connector";
// else
// if (!connectors.isConnector(targets))
// return "ProviderModuleDSA.isProvided:not-connector";
return OK; return OK;
} }
@ -98,7 +100,7 @@ contract ProviderModuleDSA is GelatoProviderModuleStandard {
AccountInterface.cast.selector, AccountInterface.cast.selector,
targets, targets,
datas, datas,
tx.origin gelatoCore
); );
} }
} }

View File

@ -0,0 +1,66 @@
// "SPDX-License-Identifier: MIT"
pragma solidity ^0.6.0;
interface MemoryInterface {
function getUint(uint id) external returns (uint num);
function setUint(uint id, uint val) external;
}
interface EventInterface {
function emitEvent(uint connectorType, uint connectorID, bytes32 eventCode, bytes calldata eventData) external;
}
contract Stores {
/**
* @dev Return ethereum address
*/
function getEthAddr() internal pure returns (address) {
return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // ETH Address
}
/**
* @dev Return memory variable address
*/
function getMemoryAddr() internal pure returns (address) {
return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address
}
/**
* @dev Return InstaEvent Address.
*/
function getEventAddr() internal pure returns (address) {
return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97; // InstaEvent Address
}
/**
* @dev Get Uint value from InstaMemory Contract.
*/
function getUint(uint getId, uint val) internal returns (uint returnVal) {
returnVal = getId == 0 ? val : MemoryInterface(getMemoryAddr()).getUint(getId);
}
/**
* @dev Set Uint value in InstaMemory Contract.
*/
function setUint(uint setId, uint val) virtual internal {
if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val);
}
/**
* @dev emit event on event contract
*/
function emitEvent(bytes32 eventCode, bytes memory eventData) virtual internal {
(uint model, uint id) = connectorID();
EventInterface(getEventAddr()).emitEvent(model, id, eventCode, eventData);
}
/**
* @dev Connector Details - needs to be changed before deployment
*/
function connectorID() public view virtual returns(uint model, uint id) {
(model, id) = (0, 0);
}
}