Skip to content

Instantly share code, notes, and snippets.

View brockelmore's full-sized avatar
🌱

brockelmore

🌱
View GitHub Profile
@brockelmore
brockelmore / bedrock_deploy.sol
Last active April 19, 2024 22:28
Optimism-Bedrock deployment with foundry
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.15;
import "forge-std/Script.sol";
// L1
import { L1CrossDomainMessenger } from "../L1/L1CrossDomainMessenger.sol";
import { L1ERC721Bridge } from "../L1/L1ERC721Bridge.sol";
import { L1StandardBridge } from "../L1/L1StandardBridge.sol";
import { L2OutputOracle } from "../L1/L2OutputOracle.sol";
name: Tests
on: [push, pull_request]
jobs:
check:
name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
library InsertionSort {
function sort(uint256[] memory list) internal pure {
// Algorithm:
//
// for i = 2 to n do
// for j = 1 to i − 1 do // NOTE: we init do an extra sub instead of <=
// if A[i] < A[j] then
@brockelmore
brockelmore / NotSoPrivateFn.sol
Created February 7, 2022 06:53
Accessing private function outside of the contract
// SPDX-License-Identifier: UNLICENSE
pragma solidity >=0.8.0 <0.9.0;
contract Private {
function t_() private returns (uint256) {
return 1;
}
function rt() public returns (bytes32 fp) {
@brockelmore
brockelmore / FullPushable.sol
Last active June 17, 2022 18:36
Dynamic list in solidity (no need to define length)
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.11;
type PushArrayPtr is bytes32;
library PushArray {
function newArray(uint8 len) internal pure returns (PushArrayPtr s) {
assembly {
// grab free mem ptr, accounting for annoying return adjustment
@brockelmore
brockelmore / pushable_array.sol
Created January 19, 2022 23:20
Pushable array datatype for solidity
// SPDX-License-Identifier: UNLICENSE
pragma solidity >=0.8.0 <0.9.0;
// NOT TESTED - USE AT YOUR OWN RISK
// Supports 32 byte word types. Could be easily extended to multiword types by
// passing in the size of the elements as well though
struct PushableArray {
@brockelmore
brockelmore / root.sol
Last active December 30, 2021 11:18
Root storage pattern
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.10;
import "solmate/tokens/ERC20.sol";
import "solmate/utils/SafeTransferLib.sol";
import "ds-test/test.sol";
contract MerkleTrust is DSTest {
using SafeTransferLib for ERC20;