-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish wormhole, write in a bunch of the tests
probably still a lot of bugs but can probably push up a testnet deployment just to see if everything is gluing together ok
- Loading branch information
Showing
19 changed files
with
554 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
protocol/synthetix/contracts/interfaces/external/IERC7412.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
interface IERC7412 { | ||
error FeeRequired(uint amount); | ||
error OracleDataRequired(address oracleContract, bytes oracleQuery); | ||
|
||
function oracleId() external view returns (bytes32 oracleId); | ||
|
||
function fulfillOracleQuery(bytes calldata signedOffchainData) external payable; | ||
} |
19 changes: 19 additions & 0 deletions
19
protocol/synthetix/contracts/interfaces/external/IWormholeERC7412Receiver.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
import "@synthetixio/core-contracts/contracts/interfaces/IERC20.sol"; | ||
import "./IERC7412.sol"; | ||
|
||
interface IWormholeERC7412Receiver is IERC7412 { | ||
struct CrossChainRequest { | ||
uint64 chainSelector; | ||
uint256 timestamp; | ||
address target; | ||
bytes data; | ||
} | ||
|
||
function getCrossChainData( | ||
CrossChainRequest[] memory reqs, | ||
uint256 maxAge | ||
) external view returns (bytes[] memory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
import "@synthetixio/core-contracts/contracts/utils/CallUtil.sol"; | ||
|
||
/** | ||
* A module which can be added to the core system to allow it to call itself. Used for cross chain purposes, which rely on messages to self | ||
*/ | ||
contract CallSelfModule { | ||
using CallUtil for address; | ||
|
||
function callSelf(bytes memory selfCallData) external returns (bytes memory) { | ||
return address(this).tryCall(selfCallData); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
protocol/synthetix/contracts/mocks/FakeSendCrossChainModule.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
import "@synthetixio/core-contracts/contracts/utils/CallUtil.sol"; | ||
|
||
/** | ||
* A module which can be added to the core system to allow it to call itself. Used for cross chain purposes, which rely on messages to self | ||
*/ | ||
contract FakeSendCrossChainModule { | ||
function sendCrossChainFake( | ||
uint64[] memory targetChains, | ||
bytes memory data, | ||
uint256 gasLimit | ||
) external returns (bytes32[] memory) { | ||
return new bytes32[](targetChains.length); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
protocol/synthetix/contracts/mocks/FakeWormholeCrossChainRead.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
import "../interfaces/external/IWormholeERC7412Receiver.sol"; | ||
|
||
contract FakeWormholeCrossChainRead is IWormholeERC7412Receiver { | ||
mapping(bytes32 => bytes) public queryResponses; | ||
|
||
function getCrossChainData( | ||
IWormholeERC7412Receiver.CrossChainRequest[] memory reqs, | ||
uint256 maxAge | ||
) external view override returns (bytes[] memory responses) { | ||
responses = new bytes[](reqs.length); | ||
for (uint i = 0; i < reqs.length; i++) { | ||
CrossChainRequest memory req = reqs[i]; | ||
bytes32 reqHash = keccak256(abi.encodePacked(req.chainSelector, req.target, req.data)); | ||
|
||
responses[i] = queryResponses[reqHash]; | ||
} | ||
} | ||
|
||
function setCrossChainData( | ||
uint64 chainSelector, | ||
address target, | ||
bytes memory callData, | ||
bytes memory response | ||
) external { | ||
bytes32 reqHash = keccak256(abi.encodePacked(chainSelector, target, callData)); | ||
queryResponses[reqHash] = response; | ||
} | ||
|
||
function fulfillOracleQuery(bytes calldata signedOffchainData) external payable {} | ||
|
||
function oracleId() external view returns (bytes32) { | ||
return "DUMMY"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.