mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
code refactor
This commit is contained in:
parent
f8e65363c9
commit
f3aaea677b
|
@ -1,5 +1,6 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
pragma abicoder v2;
|
||||
|
||||
interface TokenInterface {
|
||||
function approve(address, uint256) external;
|
||||
|
@ -23,5 +24,5 @@ interface AccountInterface {
|
|||
}
|
||||
|
||||
interface InstaConnectors {
|
||||
function connectors(string memory) external returns (address);
|
||||
function isConnectors(string[] calldata) external returns (bool, address[] memory);
|
||||
}
|
||||
|
|
|
@ -28,10 +28,13 @@ contract SwapHelpers {
|
|||
require(_length > 0, "zero-length-not-allowed");
|
||||
require(_datas.length == _length, "calldata-length-invalid");
|
||||
|
||||
(bool isOk, address[] memory connectors) = instaConnectors.isConnectors(
|
||||
_connectors
|
||||
);
|
||||
require(isOk, "connector-names-invalid");
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
(success, returnData) = instaConnectors
|
||||
.connectors(_connectors[i])
|
||||
.delegatecall(_datas[i]);
|
||||
(success, returnData) = connectors[i].delegatecall(_datas[i]);
|
||||
if (success) {
|
||||
connector = _connectors[i];
|
||||
break;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
pragma abicoder v2;
|
||||
|
||||
interface TokenInterface {
|
||||
function approve(address, uint256) external;
|
||||
|
@ -29,5 +30,5 @@ interface AccountInterface {
|
|||
}
|
||||
|
||||
interface InstaConnectors {
|
||||
function connectors(string memory) external returns (address);
|
||||
}
|
||||
function isConnectors(string[] calldata) external returns (bool, address[] memory);
|
||||
}
|
||||
|
|
|
@ -28,10 +28,13 @@ contract SwapHelpers {
|
|||
require(_length > 0, "zero-length-not-allowed");
|
||||
require(_datas.length == _length, "calldata-length-invalid");
|
||||
|
||||
(bool isOk, address[] memory connectors) = instaConnectors.isConnectors(
|
||||
_connectors
|
||||
);
|
||||
require(isOk, "connector-names-invalid");
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
(success, returnData) = instaConnectors
|
||||
.connectors(_connectors[i])
|
||||
.delegatecall(_datas[i]);
|
||||
(success, returnData) = connectors[i].delegatecall(_datas[i]);
|
||||
if (success) {
|
||||
connector = _connectors[i];
|
||||
break;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
pragma abicoder v2;
|
||||
|
||||
interface TokenInterface {
|
||||
function approve(address, uint256) external;
|
||||
|
@ -28,5 +29,6 @@ interface AccountInterface {
|
|||
}
|
||||
|
||||
interface InstaConnectors {
|
||||
function connectors(string memory) external returns (address);
|
||||
function isConnectors(string[] calldata) external returns (bool, address[] memory);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,13 @@ contract SwapHelpers {
|
|||
require(_length > 0, "zero-length-not-allowed");
|
||||
require(_datas.length == _length, "calldata-length-invalid");
|
||||
|
||||
(bool isOk, address[] memory connectors) = instaConnectors.isConnectors(
|
||||
_connectors
|
||||
);
|
||||
require(isOk, "connector-names-invalid");
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
(success, returnData) = instaConnectors
|
||||
.connectors(_connectors[i])
|
||||
.delegatecall(_datas[i]);
|
||||
(success, returnData) = connectors[i].delegatecall(_datas[i]);
|
||||
if (success) {
|
||||
connector = _connectors[i];
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue
Block a user