diff --git a/contracts/arbitrum/common/interfaces.sol b/contracts/arbitrum/common/interfaces.sol index 5fbd1b6d..0a0c2c58 100644 --- a/contracts/arbitrum/common/interfaces.sol +++ b/contracts/arbitrum/common/interfaces.sol @@ -26,6 +26,15 @@ interface AccountInterface { function enable(address) external; function disable(address) external; function isAuth(address) external view returns (bool); + function cast( + string[] calldata _targetNames, + bytes[] calldata _datas, + address _origin + ) external payable returns (bytes32[] memory responses); +} + +interface ListInterface { + function accountID(address) external returns (uint64); } interface InstaConnectors { diff --git a/contracts/arbitrum/connectors/spell/events.sol b/contracts/arbitrum/connectors/spell/events.sol new file mode 100644 index 00000000..1fff84f3 --- /dev/null +++ b/contracts/arbitrum/connectors/spell/events.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma abicoder v2; + +contract Events { + event LogCastDSA( + address indexed targetDSA, + string[] connectors, + bytes[] datas + ); +} diff --git a/contracts/arbitrum/connectors/spell/helpers.sol b/contracts/arbitrum/connectors/spell/helpers.sol new file mode 100644 index 00000000..5f8d3d9a --- /dev/null +++ b/contracts/arbitrum/connectors/spell/helpers.sol @@ -0,0 +1,12 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; + +import { ListInterface } from "../../common/interfaces.sol"; + +contract SpellHelpers { + /** + * @dev InstaList + */ + ListInterface internal constant instaList = + ListInterface(0x3565F6057b7fFE36984779A507fC87b31EFb0f09); +} diff --git a/contracts/arbitrum/connectors/spell/main.sol b/contracts/arbitrum/connectors/spell/main.sol new file mode 100644 index 00000000..5e0356d4 --- /dev/null +++ b/contracts/arbitrum/connectors/spell/main.sol @@ -0,0 +1,42 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +/** + * @title Spell. + * @dev Cast on DSAs. + */ + +// import files +import { AccountInterface } from "../../common/interfaces.sol"; +import { SpellHelpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract Spell is SpellHelpers, Events { + /** + *@dev Cast spells on DSA. + *@param targetDSA target DSA to cast spells on. + *@param connectors connector names. + *@param datas datas for the cast. + */ + function castDSA( + address targetDSA, + string[] memory connectors, + bytes[] memory datas + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(instaList.accountID(targetDSA) != 0, "not-a-DSA"); + + AccountInterface(targetDSA).cast(connectors, datas, address(0)); + + _eventName = "LogCastDSA(address,string[],bytes[])"; + _eventParam = abi.encode(targetDSA, connectors, datas); + } +} + +contract ConnectV2SpellConnectorPolygon is Spell { + string public name = "Spell-Connector-v1.0"; +} diff --git a/contracts/avalanche/common/interfaces.sol b/contracts/avalanche/common/interfaces.sol index 912e57b1..11186b6b 100644 --- a/contracts/avalanche/common/interfaces.sol +++ b/contracts/avalanche/common/interfaces.sol @@ -21,6 +21,15 @@ interface AccountInterface { function enable(address) external; function disable(address) external; function isAuth(address) external view returns (bool); + function cast( + string[] calldata _targetNames, + bytes[] calldata _datas, + address _origin + ) external payable returns (bytes32[] memory responses); +} + +interface ListInterface { + function accountID(address) external returns (uint64); } interface InstaConnectors { diff --git a/contracts/avalanche/connectors/spell/events.sol b/contracts/avalanche/connectors/spell/events.sol new file mode 100644 index 00000000..1fff84f3 --- /dev/null +++ b/contracts/avalanche/connectors/spell/events.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma abicoder v2; + +contract Events { + event LogCastDSA( + address indexed targetDSA, + string[] connectors, + bytes[] datas + ); +} diff --git a/contracts/avalanche/connectors/spell/helpers.sol b/contracts/avalanche/connectors/spell/helpers.sol new file mode 100644 index 00000000..0576e10e --- /dev/null +++ b/contracts/avalanche/connectors/spell/helpers.sol @@ -0,0 +1,12 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; + +import { ListInterface } from "../../common/interfaces.sol"; + +contract SpellHelpers { + /** + * @dev InstaList + */ + ListInterface internal constant instaList = + ListInterface(0x9926955e0Dd681Dc303370C52f4Ad0a4dd061687); +} diff --git a/contracts/avalanche/connectors/spell/main.sol b/contracts/avalanche/connectors/spell/main.sol new file mode 100644 index 00000000..5e0356d4 --- /dev/null +++ b/contracts/avalanche/connectors/spell/main.sol @@ -0,0 +1,42 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +/** + * @title Spell. + * @dev Cast on DSAs. + */ + +// import files +import { AccountInterface } from "../../common/interfaces.sol"; +import { SpellHelpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract Spell is SpellHelpers, Events { + /** + *@dev Cast spells on DSA. + *@param targetDSA target DSA to cast spells on. + *@param connectors connector names. + *@param datas datas for the cast. + */ + function castDSA( + address targetDSA, + string[] memory connectors, + bytes[] memory datas + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(instaList.accountID(targetDSA) != 0, "not-a-DSA"); + + AccountInterface(targetDSA).cast(connectors, datas, address(0)); + + _eventName = "LogCastDSA(address,string[],bytes[])"; + _eventParam = abi.encode(targetDSA, connectors, datas); + } +} + +contract ConnectV2SpellConnectorPolygon is Spell { + string public name = "Spell-Connector-v1.0"; +} diff --git a/contracts/fantom/common/interfaces.sol b/contracts/fantom/common/interfaces.sol index cf1abfee..b228ebe8 100644 --- a/contracts/fantom/common/interfaces.sol +++ b/contracts/fantom/common/interfaces.sol @@ -34,6 +34,16 @@ interface AccountInterface { function disable(address) external; function isAuth(address) external view returns (bool); + + function cast( + string[] calldata _targetNames, + bytes[] calldata _datas, + address _origin + ) external payable returns (bytes32[] memory responses); +} + +interface ListInterface { + function accountID(address) external returns (uint64); } interface InstaConnectors { diff --git a/contracts/fantom/connectors/spell/events.sol b/contracts/fantom/connectors/spell/events.sol new file mode 100644 index 00000000..1fff84f3 --- /dev/null +++ b/contracts/fantom/connectors/spell/events.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma abicoder v2; + +contract Events { + event LogCastDSA( + address indexed targetDSA, + string[] connectors, + bytes[] datas + ); +} diff --git a/contracts/fantom/connectors/spell/helpers.sol b/contracts/fantom/connectors/spell/helpers.sol new file mode 100644 index 00000000..ae065b8b --- /dev/null +++ b/contracts/fantom/connectors/spell/helpers.sol @@ -0,0 +1,12 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; + +import { ListInterface } from "../../common/interfaces.sol"; + +contract SpellHelpers { + /** + * @dev InstaList + */ + ListInterface internal constant instaList = + ListInterface(0x10e166c3FAF887D8a61dE6c25039231eE694E926); +} diff --git a/contracts/fantom/connectors/spell/main.sol b/contracts/fantom/connectors/spell/main.sol new file mode 100644 index 00000000..5e0356d4 --- /dev/null +++ b/contracts/fantom/connectors/spell/main.sol @@ -0,0 +1,42 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +/** + * @title Spell. + * @dev Cast on DSAs. + */ + +// import files +import { AccountInterface } from "../../common/interfaces.sol"; +import { SpellHelpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract Spell is SpellHelpers, Events { + /** + *@dev Cast spells on DSA. + *@param targetDSA target DSA to cast spells on. + *@param connectors connector names. + *@param datas datas for the cast. + */ + function castDSA( + address targetDSA, + string[] memory connectors, + bytes[] memory datas + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(instaList.accountID(targetDSA) != 0, "not-a-DSA"); + + AccountInterface(targetDSA).cast(connectors, datas, address(0)); + + _eventName = "LogCastDSA(address,string[],bytes[])"; + _eventParam = abi.encode(targetDSA, connectors, datas); + } +} + +contract ConnectV2SpellConnectorPolygon is Spell { + string public name = "Spell-Connector-v1.0"; +} diff --git a/contracts/mainnet/common/interfaces.sol b/contracts/mainnet/common/interfaces.sol index 29f60e4b..9b872418 100644 --- a/contracts/mainnet/common/interfaces.sol +++ b/contracts/mainnet/common/interfaces.sol @@ -27,6 +27,15 @@ interface AccountInterface { function enable(address) external; function disable(address) external; function isAuth(address) external view returns (bool); + function cast( + string[] calldata _targetNames, + bytes[] calldata _datas, + address _origin + ) external payable returns (bytes32[] memory responses); +} + +interface ListInterface { + function accountID(address) external returns (uint64); } interface InstaConnectors { diff --git a/contracts/mainnet/connectors/spell/events.sol b/contracts/mainnet/connectors/spell/events.sol new file mode 100644 index 00000000..1fff84f3 --- /dev/null +++ b/contracts/mainnet/connectors/spell/events.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma abicoder v2; + +contract Events { + event LogCastDSA( + address indexed targetDSA, + string[] connectors, + bytes[] datas + ); +} diff --git a/contracts/mainnet/connectors/spell/helpers.sol b/contracts/mainnet/connectors/spell/helpers.sol new file mode 100644 index 00000000..a0a7582a --- /dev/null +++ b/contracts/mainnet/connectors/spell/helpers.sol @@ -0,0 +1,12 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; + +import { ListInterface } from "../../common/interfaces.sol"; + +contract SpellHelpers { + /** + * @dev InstaList + */ + ListInterface internal constant instaList = + ListInterface(0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb); +} diff --git a/contracts/mainnet/connectors/spell/main.sol b/contracts/mainnet/connectors/spell/main.sol new file mode 100644 index 00000000..5e0356d4 --- /dev/null +++ b/contracts/mainnet/connectors/spell/main.sol @@ -0,0 +1,42 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +/** + * @title Spell. + * @dev Cast on DSAs. + */ + +// import files +import { AccountInterface } from "../../common/interfaces.sol"; +import { SpellHelpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract Spell is SpellHelpers, Events { + /** + *@dev Cast spells on DSA. + *@param targetDSA target DSA to cast spells on. + *@param connectors connector names. + *@param datas datas for the cast. + */ + function castDSA( + address targetDSA, + string[] memory connectors, + bytes[] memory datas + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(instaList.accountID(targetDSA) != 0, "not-a-DSA"); + + AccountInterface(targetDSA).cast(connectors, datas, address(0)); + + _eventName = "LogCastDSA(address,string[],bytes[])"; + _eventParam = abi.encode(targetDSA, connectors, datas); + } +} + +contract ConnectV2SpellConnectorPolygon is Spell { + string public name = "Spell-Connector-v1.0"; +} diff --git a/contracts/optimism/common/interfaces.sol b/contracts/optimism/common/interfaces.sol index 797bce15..05fab373 100644 --- a/contracts/optimism/common/interfaces.sol +++ b/contracts/optimism/common/interfaces.sol @@ -23,6 +23,15 @@ interface AccountInterface { function enable(address) external; function disable(address) external; function isAuth(address) external view returns (bool); + function cast( + string[] calldata _targetNames, + bytes[] calldata _datas, + address _origin + ) external payable returns (bytes32[] memory responses); +} + +interface ListInterface { + function accountID(address) external returns (uint64); } interface InstaConnectors { diff --git a/contracts/optimism/connectors/spell/events.sol b/contracts/optimism/connectors/spell/events.sol new file mode 100644 index 00000000..1fff84f3 --- /dev/null +++ b/contracts/optimism/connectors/spell/events.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma abicoder v2; + +contract Events { + event LogCastDSA( + address indexed targetDSA, + string[] connectors, + bytes[] datas + ); +} diff --git a/contracts/optimism/connectors/spell/helpers.sol b/contracts/optimism/connectors/spell/helpers.sol new file mode 100644 index 00000000..0576e10e --- /dev/null +++ b/contracts/optimism/connectors/spell/helpers.sol @@ -0,0 +1,12 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; + +import { ListInterface } from "../../common/interfaces.sol"; + +contract SpellHelpers { + /** + * @dev InstaList + */ + ListInterface internal constant instaList = + ListInterface(0x9926955e0Dd681Dc303370C52f4Ad0a4dd061687); +} diff --git a/contracts/optimism/connectors/spell/main.sol b/contracts/optimism/connectors/spell/main.sol new file mode 100644 index 00000000..5e0356d4 --- /dev/null +++ b/contracts/optimism/connectors/spell/main.sol @@ -0,0 +1,42 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +/** + * @title Spell. + * @dev Cast on DSAs. + */ + +// import files +import { AccountInterface } from "../../common/interfaces.sol"; +import { SpellHelpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract Spell is SpellHelpers, Events { + /** + *@dev Cast spells on DSA. + *@param targetDSA target DSA to cast spells on. + *@param connectors connector names. + *@param datas datas for the cast. + */ + function castDSA( + address targetDSA, + string[] memory connectors, + bytes[] memory datas + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(instaList.accountID(targetDSA) != 0, "not-a-DSA"); + + AccountInterface(targetDSA).cast(connectors, datas, address(0)); + + _eventName = "LogCastDSA(address,string[],bytes[])"; + _eventParam = abi.encode(targetDSA, connectors, datas); + } +} + +contract ConnectV2SpellConnectorPolygon is Spell { + string public name = "Spell-Connector-v1.0"; +} diff --git a/contracts/polygon/common/interfaces.sol b/contracts/polygon/common/interfaces.sol index 94f054e1..5041400a 100644 --- a/contracts/polygon/common/interfaces.sol +++ b/contracts/polygon/common/interfaces.sol @@ -26,6 +26,15 @@ interface AccountInterface { function enable(address) external; function disable(address) external; function isAuth(address) external view returns (bool); + function cast( + string[] calldata _targetNames, + bytes[] calldata _datas, + address _origin + ) external payable returns (bytes32[] memory responses); +} + +interface ListInterface { + function accountID(address) external returns (uint64); } interface InstaConnectors { diff --git a/contracts/polygon/connectors/spell/events.sol b/contracts/polygon/connectors/spell/events.sol new file mode 100644 index 00000000..1fff84f3 --- /dev/null +++ b/contracts/polygon/connectors/spell/events.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma abicoder v2; + +contract Events { + event LogCastDSA( + address indexed targetDSA, + string[] connectors, + bytes[] datas + ); +} diff --git a/contracts/polygon/connectors/spell/helpers.sol b/contracts/polygon/connectors/spell/helpers.sol new file mode 100644 index 00000000..ae03c240 --- /dev/null +++ b/contracts/polygon/connectors/spell/helpers.sol @@ -0,0 +1,12 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; + +import { ListInterface } from "../../common/interfaces.sol"; + +contract SpellHelpers { + /** + * @dev InstaList + */ + ListInterface internal constant instaList = + ListInterface(0x839c2D3aDe63DF5b0b8F3E57D5e145057Ab41556); +} diff --git a/contracts/polygon/connectors/spell/main.sol b/contracts/polygon/connectors/spell/main.sol new file mode 100644 index 00000000..5e0356d4 --- /dev/null +++ b/contracts/polygon/connectors/spell/main.sol @@ -0,0 +1,42 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +/** + * @title Spell. + * @dev Cast on DSAs. + */ + +// import files +import { AccountInterface } from "../../common/interfaces.sol"; +import { SpellHelpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract Spell is SpellHelpers, Events { + /** + *@dev Cast spells on DSA. + *@param targetDSA target DSA to cast spells on. + *@param connectors connector names. + *@param datas datas for the cast. + */ + function castDSA( + address targetDSA, + string[] memory connectors, + bytes[] memory datas + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(instaList.accountID(targetDSA) != 0, "not-a-DSA"); + + AccountInterface(targetDSA).cast(connectors, datas, address(0)); + + _eventName = "LogCastDSA(address,string[],bytes[])"; + _eventParam = abi.encode(targetDSA, connectors, datas); + } +} + +contract ConnectV2SpellConnectorPolygon is Spell { + string public name = "Spell-Connector-v1.0"; +}