-
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.
Merge pull request #3 from skip-mev/revision_v1
Use proxy contract, enable ERC20 forwarding, fix unwrapping
- Loading branch information
Showing
8 changed files
with
216 additions
and
34 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
Submodule openzeppelin-contracts
updated
538 files
Submodule openzeppelin-contracts-upgradeable
added at
5bc599
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,98 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import {IAxelarGateway} from "lib/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol"; | ||
import {IAxelarExecutable} from "lib/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarExecutable.sol"; | ||
import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"; | ||
|
||
contract AxelarExecutableUpgradeable is IAxelarExecutable, Initializable { | ||
IAxelarGateway public gateway; | ||
uint256[5] __gap; | ||
|
||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function __AxelarExecutable_init( | ||
address axelarGateway | ||
) internal onlyInitializing { | ||
__AxelarExecutable_init_unchained(axelarGateway); | ||
} | ||
|
||
function __AxelarExecutable_init_unchained( | ||
address axelarGateway | ||
) internal onlyInitializing { | ||
gateway = IAxelarGateway(axelarGateway); | ||
} | ||
|
||
function initialize(address gateway_) external initializer { | ||
if (gateway_ == address(0)) revert InvalidAddress(); | ||
|
||
gateway = IAxelarGateway(gateway_); | ||
} | ||
|
||
function execute( | ||
bytes32 commandId, | ||
string calldata sourceChain, | ||
string calldata sourceAddress, | ||
bytes calldata payload | ||
) external { | ||
bytes32 payloadHash = keccak256(payload); | ||
|
||
if ( | ||
!gateway.validateContractCall( | ||
commandId, | ||
sourceChain, | ||
sourceAddress, | ||
payloadHash | ||
) | ||
) revert NotApprovedByGateway(); | ||
|
||
_execute(sourceChain, sourceAddress, payload); | ||
} | ||
|
||
function executeWithToken( | ||
bytes32 commandId, | ||
string calldata sourceChain, | ||
string calldata sourceAddress, | ||
bytes calldata payload, | ||
string calldata tokenSymbol, | ||
uint256 amount | ||
) external { | ||
bytes32 payloadHash = keccak256(payload); | ||
|
||
if ( | ||
!gateway.validateContractCallAndMint( | ||
commandId, | ||
sourceChain, | ||
sourceAddress, | ||
payloadHash, | ||
tokenSymbol, | ||
amount | ||
) | ||
) revert NotApprovedByGateway(); | ||
|
||
_executeWithToken( | ||
sourceChain, | ||
sourceAddress, | ||
payload, | ||
tokenSymbol, | ||
amount | ||
); | ||
} | ||
|
||
function _execute( | ||
string calldata sourceChain, | ||
string calldata sourceAddress, | ||
bytes calldata payload | ||
) internal virtual {} | ||
|
||
function _executeWithToken( | ||
string calldata sourceChain, | ||
string calldata sourceAddress, | ||
bytes calldata payload, | ||
string calldata tokenSymbol, | ||
uint256 amount | ||
) internal virtual {} | ||
} |
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.