generated from evan-gray/multichain-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7544aab
commit 96005ed
Showing
11 changed files
with
491 additions
and
118 deletions.
There are no files selected for viewing
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
evm/script/DeployWormholeGuardiansAdapterWithExecutor.s.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,53 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.19; | ||
|
||
import { | ||
WormholeGuardiansAdapterWithExecutor, | ||
wormholeGuardiansAdapterWithExecutorVersionString | ||
} from "../src/WormholeGuardiansAdapterWithExecutor.sol"; | ||
import "forge-std/Script.sol"; | ||
|
||
// DeployWormholeGuardiansAdapterWithExecutor is a forge script to deploy the WormholeGuardiansAdapterWithExecutor contract. Use ./sh/deployWormholeGuardiansAdapterWithExecutor.sh to invoke this. | ||
contract DeployWormholeGuardiansAdapterWithExecutor is Script { | ||
function test() public {} // Exclude this from coverage report. | ||
|
||
function dryRun( | ||
uint16 ourChain, | ||
address admin, | ||
address endpoint, | ||
address executor, | ||
address wormhole, | ||
uint8 consistencyLevel | ||
) public { | ||
_deploy(ourChain, admin, endpoint, executor, wormhole, consistencyLevel); | ||
} | ||
|
||
function run( | ||
uint16 ourChain, | ||
address admin, | ||
address endpoint, | ||
address executor, | ||
address wormhole, | ||
uint8 consistencyLevel | ||
) public returns (address deployedAddress) { | ||
vm.startBroadcast(); | ||
(deployedAddress) = _deploy(ourChain, admin, endpoint, executor, wormhole, consistencyLevel); | ||
vm.stopBroadcast(); | ||
} | ||
|
||
function _deploy( | ||
uint16 ourChain, | ||
address admin, | ||
address endpoint, | ||
address executor, | ||
address wormhole, | ||
uint8 consistencyLevel | ||
) internal returns (address deployedAddress) { | ||
bytes32 salt = keccak256(abi.encodePacked(wormholeGuardiansAdapterWithExecutorVersionString)); | ||
WormholeGuardiansAdapterWithExecutor wormholeGuardiansAdapterWithExecutor = new WormholeGuardiansAdapterWithExecutor{ | ||
salt: salt | ||
}(ourChain, admin, endpoint, executor, wormhole, consistencyLevel); | ||
|
||
return (address(wormholeGuardiansAdapterWithExecutor)); | ||
} | ||
} |
File renamed without changes.
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,49 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# This script deploys the WormholeGuardiansAdapterWithExecutor contract. | ||
# Usage: RPC_URL= MNEMONIC= OUR_CHAIN_ID= EVM_CHAIN_ID= ADMIN= ENDPOINT= EXECUTOR= WORMHOLE= CONSISTENCY_LEVEL= ./sh/deployWormholeGuardiansAdapterWithExecutor.sh | ||
# tilt: ENDPOINT=0x1aBE68277AE236083947f2551FEe8b885efCA8f5 EXECUTOR= ./sh/deployWormholeGuardiansAdapterWithExecutor.sh | ||
# | ||
|
||
[[ -z $ENDPOINT ]] && { echo "Missing ENDPOINT"; exit 1; } | ||
[[ -z $EXECUTOR ]] && { echo "Missing EXECUTOR"; exit 1; } | ||
|
||
if [ "${RPC_URL}X" == "X" ]; then | ||
RPC_URL=http://localhost:8545 | ||
fi | ||
|
||
if [ "${MNEMONIC}X" == "X" ]; then | ||
MNEMONIC=0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d | ||
fi | ||
|
||
if [ "${OUR_CHAIN_ID}X" == "X" ]; then | ||
OUR_CHAIN_ID=2 | ||
fi | ||
|
||
if [ "${EVM_CHAIN_ID}X" == "X" ]; then | ||
EVM_CHAIN_ID=1337 | ||
fi | ||
|
||
if [ "${ADMIN}X" == "X" ]; then | ||
ADMIN=0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1 | ||
fi | ||
|
||
if [ "${WORMHOLE}X" == "X" ]; then | ||
WORMHOLE=0xC89Ce4735882C9F0f0FE26686c53074E09B0D550 | ||
fi | ||
|
||
if [ "${CONSISTENCY_LEVEL}X" == "X" ]; then | ||
CONSISTENCY_LEVEL=200 | ||
fi | ||
|
||
forge script ./script/DeployWormholeGuardiansAdapterWithExecutor.s.sol:DeployWormholeGuardiansAdapterWithExecutor \ | ||
--sig "run(uint16,address,address,address,address,uint8)" $OUR_CHAIN_ID $ADMIN $ENDPOINT $EXECUTOR $WORMHOLE $CONSISTENCY_LEVEL \ | ||
--rpc-url "$RPC_URL" \ | ||
--private-key "$MNEMONIC" \ | ||
--broadcast ${FORGE_ARGS} | ||
|
||
returnInfo=$(cat ./broadcast/DeployWormholeGuardiansAdapterWithExecutor.s.sol/$EVM_CHAIN_ID/run-latest.json) | ||
|
||
DEPLOYED_ADDRESS=$(jq -r '.returns.deployedAddress.value' <<< "$returnInfo") | ||
echo "Deployed adapter address: $DEPLOYED_ADDRESS" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: Apache 2 | ||
pragma solidity ^0.8.19; | ||
|
||
import "example-messaging-endpoint/evm/src/interfaces/IEndpointAdapter.sol"; | ||
import "example-messaging-executor/evm/src/interfaces/IExecutor.sol"; | ||
import "wormhole-solidity-sdk/interfaces/IWormhole.sol"; | ||
|
||
import "./WormholeGuardiansAdapter.sol"; | ||
|
||
string constant wormholeGuardiansAdapterWithExecutorVersionString = "WormholeGuardiansAdapterWithExecutor-0.0.1"; | ||
|
||
contract WormholeGuardiansAdapterWithExecutor is WormholeGuardiansAdapter { | ||
// ==================== Immutables =============================================== | ||
|
||
IExecutor public immutable executor; | ||
|
||
// ==================== Constructor ============================================== | ||
|
||
constructor( | ||
uint16 _ourChain, | ||
address _admin, | ||
address _endpoint, | ||
address _executor, | ||
address _wormhole, | ||
uint8 _consistencyLevel | ||
) WormholeGuardiansAdapter(_ourChain, _admin, _endpoint, _wormhole, _consistencyLevel) { | ||
assert(_executor != address(0)); | ||
executor = IExecutor(_executor); | ||
} | ||
|
||
/// @inheritdoc IAdapter | ||
function getAdapterType() external pure override returns (string memory) { | ||
return wormholeGuardiansAdapterWithExecutorVersionString; | ||
} | ||
|
||
/// @inheritdoc IAdapter | ||
/// @dev The caller should set the delivery price in msg.value. | ||
function sendMessage( | ||
UniversalAddress srcAddr, | ||
uint64 sequence, | ||
uint16 dstChain, | ||
UniversalAddress dstAddr, | ||
bytes32 payloadHash, | ||
address refundAddr | ||
) external payable override onlyEndpoint { | ||
bytes memory payload = _encodePayload(srcAddr, sequence, dstChain, dstAddr, payloadHash); | ||
wormhole.publishMessage{value: msg.value}(0, payload, consistencyLevel); | ||
emit MessageSent(srcAddr, dstChain, dstAddr, sequence, payloadHash); | ||
|
||
// TODO: These should be passed in. | ||
bytes memory signedQuote = new bytes(0); | ||
bytes memory relayInstructions = new bytes(0); | ||
|
||
executor.requestExecution(dstChain, dstAddr.toBytes32(), refundAddr, signedQuote, payload, relayInstructions); | ||
} | ||
} |
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.