Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,010 changes: 700 additions & 3,310 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@chainlink/local",
"description": "Chainlink Local Simulator",
"license": "MIT",
"version": "0.2.2-beta",
"version": "0.2.3-beta",
"files": [
"src/**/*.sol",
"!src/test/**/*",
Expand Down Expand Up @@ -42,7 +42,7 @@
"solidity-docgen": "^0.6.0-beta.36"
},
"dependencies": {
"@chainlink/contracts": "^1.1.1",
"@chainlink/contracts": "^1.2.0",
"@chainlink/contracts-ccip": "^1.5.0-beta.0"
}
}
Empty file.
416 changes: 416 additions & 0 deletions src/automation/AutomationLocalSimulator.sol

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions src/automation/MockAutomationForwarder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

uint256 constant PERFORM_GAS_CUSHION = 5_000;

/**
* @title MockAutomationForwarder is a relayer that sits between the simulator and the customer's target contract
* @dev The purpose of the forwarder is to give customers a consistent address to authorize against,
* which stays consistent between migrations.
*/
contract MockAutomationForwarder {
/**
* @notice forward is called by the registry and forwards the call to the target
* @param gasAmount is the amount of gas to use in the call
* @param data is the 4 bytes function selector + arbitrary function data
* @return success indicating whether the target call succeeded or failed
*/
function forward(address target, uint256 gasAmount, bytes memory data)
external
returns (bool success, uint256 gasUsed)
{
gasUsed = gasleft();
assembly {
let g := gas()
// Compute g -= PERFORM_GAS_CUSHION and check for underflow
if lt(g, PERFORM_GAS_CUSHION) { revert(0, 0) }
g := sub(g, PERFORM_GAS_CUSHION)
// if g - g//64 <= gasAmount, revert
// (we subtract g//64 because of EIP-150)
if iszero(gt(sub(g, div(g, 64)), gasAmount)) { revert(0, 0) }
// solidity calls check that a contract actually exists at the destination, so we do the same
if iszero(extcodesize(target)) { revert(0, 0) }
// call with exact gas
success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0)
}
gasUsed = gasUsed - gasleft();
return (success, gasUsed);
}
}
Loading