code refactor

This commit is contained in:
Richa-iitr 2022-06-15 14:44:49 +05:30
parent f8e65363c9
commit f3aaea677b
6 changed files with 26 additions and 13 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;