-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update the license information
- Loading branch information
1 parent
8d38148
commit b8dedb8
Showing
50 changed files
with
1,181 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
Business Source License 1.1 | ||
|
||
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. | ||
"Business Source License" is a trademark of MariaDB Corporation Ab. | ||
|
||
----------------------------------------------------------------------------- | ||
|
||
Parameters | ||
|
||
Licensor: LayerZero Labs Ltd | ||
|
||
Licensed Work: LayerZero Protocol | ||
The Licensed Work is (c) 2022 LayerZero Labs Ltd | ||
|
||
Change Date: 2027-12-01 | ||
|
||
----------------------------------------------------------------------------- | ||
|
||
Terms | ||
|
||
The Licensor hereby grants you the right to copy, modify, create derivative | ||
works, redistribute, and make non-production use of the Licensed Work. The | ||
Licensor may make an Additional Use Grant, above, permitting limited | ||
production use. | ||
|
||
Effective on the Change Date, or the fourth anniversary of the first publicly | ||
available distribution of a specific version of the Licensed Work under this | ||
License, whichever comes first, the Licensor hereby grants you rights under | ||
the terms of the Change License, and the rights granted in the paragraph | ||
above terminate. | ||
|
||
If your use of the Licensed Work does not comply with the requirements | ||
currently in effect as described in this License, you must purchase a | ||
commercial license from the Licensor, its affiliated entities, or authorized | ||
resellers, or you must refrain from using the Licensed Work. | ||
|
||
All copies of the original and modified Licensed Work, and derivative works | ||
of the Licensed Work, are subject to this License. This License applies | ||
separately for each version of the Licensed Work and the Change Date may vary | ||
for each version of the Licensed Work released by Licensor. | ||
|
||
You must conspicuously display this License on each original or modified copy | ||
of the Licensed Work. If you receive the Licensed Work in original or | ||
modified form from a third party, the terms and conditions set forth in this | ||
License apply to your use of that work. | ||
|
||
Any use of the Licensed Work in violation of this License will automatically | ||
terminate your rights under this License for the current and all other | ||
versions of the Licensed Work. | ||
|
||
This License does not grant you any right in any trademark or logo of | ||
Licensor or its affiliates (provided that you may use a trademark or logo of | ||
Licensor as expressly required by this License). | ||
|
||
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON | ||
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, | ||
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND | ||
TITLE. | ||
|
||
MariaDB hereby grants you permission to use this License’s text to license | ||
your works, and to refer to it using the trademark "Business Source License", | ||
as long as you comply with the Covenants of Licensor below. | ||
|
||
----------------------------------------------------------------------------- | ||
|
||
Covenants of Licensor | ||
|
||
In consideration of the right to use this License’s text and the "Business | ||
Source License" name and trademark, Licensor covenants to MariaDB, and to all | ||
other recipients of the licensed work to be provided by Licensor: | ||
|
||
1. To specify as the Change License the GPL Version 2.0 or any later version, | ||
or a license that is compatible with GPL Version 2.0 or a later version, | ||
where "compatible" means that software provided under the Change License can | ||
be included in a program with software provided under GPL Version 2.0 or a | ||
later version. Licensor may specify additional Change Licenses without | ||
limitation. | ||
|
||
2. To either: (a) specify an additional grant of rights to use that does not | ||
impose any additional restriction on the right granted in this License, as | ||
the Additional Use Grant; or (b) insert the text "None". | ||
|
||
3. To specify a Change Date. | ||
|
||
4. Not to modify this License in any other way. | ||
|
||
----------------------------------------------------------------------------- | ||
|
||
Notice | ||
|
||
The Business Source License (this document, or the "License") is not an Open | ||
Source license. However, the Licensed Work will eventually be made available | ||
under an Open Source License, as stated in this License. |
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,25 @@ | ||
Copyright (c) 2018 | ||
|
||
Permission is hereby granted, free of charge, to any | ||
person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the | ||
Software without restriction, including without | ||
limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software | ||
is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice | ||
shall be included in all copies or substantial portions | ||
of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF | ||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | ||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
152 changes: 152 additions & 0 deletions
152
messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.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,152 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity 0.8.22; | ||
|
||
import { IRouterClient } from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol"; | ||
import { CCIPReceiver } from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol"; | ||
import { Client } from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol"; | ||
|
||
import { DVNAdapterBase } from "../DVNAdapterBase.sol"; | ||
|
||
contract CCIPDVNAdapter is CCIPReceiver, DVNAdapterBase { | ||
struct DstConfigParam { | ||
uint32 dstEid; | ||
// https://docs.chain.link/ccip/supported-networks/v1_2_0/testnet#ethereum-sepolia | ||
// https://docs.chain.link/ccip/supported-networks/v1_0_0/mainnet | ||
uint64 chainSelector; | ||
uint16 multiplierBps; | ||
uint256 gasLimit; | ||
bytes peer; | ||
} | ||
|
||
struct DstConfig { | ||
uint64 chainSelector; | ||
uint16 multiplierBps; | ||
uint256 gasLimit; | ||
bytes peer; | ||
} | ||
|
||
address private constant NATIVE_GAS_TOKEN_ADDRESS = address(0); | ||
|
||
event DstConfigSet(DstConfigParam[] params); | ||
|
||
mapping(uint32 dstEid => DstConfig config) public dstConfig; | ||
mapping(uint64 chainSelector => uint32 eid) public CCIPChainToEid; | ||
|
||
constructor( | ||
address _sendLib, | ||
address _receiveLib, | ||
address[] memory _admins, | ||
address router | ||
) CCIPReceiver(router) DVNAdapterBase(_sendLib, _receiveLib, _admins) {} | ||
|
||
/// @notice sets configuration (`chainSelector`, `multiplierBps`, `gasLimit` and `peer`) for destination chains | ||
/// @dev The `multiplierBps` can be updated separately using `setDstMultiplierBps` function | ||
/// @param _params array of chain configurations | ||
function setDstConfig(DstConfigParam[] calldata _params) external onlyAdmin { | ||
for (uint256 i = 0; i < _params.length; i++) { | ||
DstConfigParam calldata param = _params[i]; | ||
|
||
delete CCIPChainToEid[dstConfig[param.dstEid].chainSelector]; | ||
|
||
CCIPChainToEid[param.chainSelector] = param.dstEid; | ||
dstConfig[param.dstEid] = DstConfig({ | ||
chainSelector: param.chainSelector, | ||
multiplierBps: param.multiplierBps, | ||
gasLimit: param.gasLimit, | ||
peer: param.peer | ||
}); | ||
} | ||
|
||
emit DstConfigSet(_params); | ||
} | ||
|
||
/// @notice sets fee multiplier in basis points for destination chains | ||
/// @param _params array of multipliers for destination chains | ||
function setDstMultiplier(DstMultiplierParam[] calldata _params) external onlyAdmin { | ||
for (uint256 i = 0; i < _params.length; i++) { | ||
DstMultiplierParam calldata param = _params[i]; | ||
dstConfig[param.dstEid].multiplierBps = param.multiplierBps; | ||
} | ||
|
||
emit DstMultiplierSet(_params); | ||
} | ||
|
||
function getFee( | ||
uint32 _dstEid, | ||
uint64 /*_confirmations*/, | ||
address _sender, | ||
bytes calldata /*_options*/ | ||
) external view override returns (uint256 fee) { | ||
DstConfig storage config = dstConfig[_dstEid]; | ||
|
||
Client.EVM2AnyMessage memory message = _createCCIPMessage( | ||
new bytes(PACKET_HEADER_SIZE), | ||
bytes32(0), | ||
config.peer, | ||
config.gasLimit | ||
); | ||
|
||
fee = _getCCIPFee(config.chainSelector, message); | ||
if (address(feeLib) != address(0)) { | ||
fee = feeLib.getFee(_dstEid, _sender, defaultMultiplierBps, config.multiplierBps, fee); | ||
} | ||
} | ||
|
||
function assignJob( | ||
AssignJobParam calldata _param, | ||
bytes calldata /*_options*/ | ||
) external payable override onlySendLib returns (uint256 fee) { | ||
DstConfig memory config = dstConfig[_param.dstEid]; | ||
|
||
Client.EVM2AnyMessage memory message = _createCCIPMessage( | ||
_param.packetHeader, | ||
_param.payloadHash, | ||
config.peer, | ||
config.gasLimit | ||
); | ||
|
||
fee = _getCCIPFee(config.chainSelector, message); | ||
_assertBalanceAndWithdrawFee(fee); | ||
|
||
IRouterClient(getRouter()).ccipSend{ value: fee }(config.chainSelector, message); | ||
|
||
if (address(feeLib) != address(0)) { | ||
fee = feeLib.getFee(_param.dstEid, _param.sender, defaultMultiplierBps, config.multiplierBps, fee); | ||
} | ||
} | ||
|
||
function _createCCIPMessage( | ||
bytes memory _packetHeader, | ||
bytes32 _payloadHash, | ||
bytes memory _receiver, | ||
uint256 _gasLimit | ||
) private pure returns (Client.EVM2AnyMessage memory message) { | ||
message = Client.EVM2AnyMessage({ | ||
receiver: _receiver, | ||
data: _encodePayload(_packetHeader, _payloadHash), | ||
tokenAmounts: new Client.EVMTokenAmount[](0), // Empty array indicating no tokens are being sent | ||
extraArgs: Client._argsToBytes(Client.EVMExtraArgsV1({ gasLimit: _gasLimit, strict: false })), | ||
feeToken: NATIVE_GAS_TOKEN_ADDRESS | ||
}); | ||
} | ||
|
||
function _getCCIPFee( | ||
uint64 _dstChainSelector, | ||
Client.EVM2AnyMessage memory _message | ||
) private view returns (uint256 ccipFee) { | ||
ccipFee = IRouterClient(getRouter()).getFee(_dstChainSelector, _message); | ||
} | ||
|
||
function _ccipReceive(Client.Any2EVMMessage memory _message) internal override { | ||
_assertPeer(_message.sourceChainSelector, _message.sender); | ||
_verify(_message.data); | ||
} | ||
|
||
function _assertPeer(uint64 _sourceChainSelector, bytes memory _sourceAddress) private view { | ||
uint32 sourceEid = CCIPChainToEid[_sourceChainSelector]; | ||
bytes memory sourcePeer = dstConfig[sourceEid].peer; | ||
|
||
if (keccak256(_sourceAddress) != keccak256(sourcePeer)) revert Unauthorized(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.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,7 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity 0.8.22; | ||
|
||
import { DVNAdapterFeeLibBase } from "../DVNAdapterFeeLibBase.sol"; | ||
|
||
contract CCIPDVNAdapterFeeLib is DVNAdapterFeeLibBase {} |
Oops, something went wrong.