Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
"""
Human quality transcripts from audio files using
AssemblyAI for transcription and Google's Gemini for enhancement.
Requirements:
- AssemblyAI API key (https://www.assemblyai.com/)
- Google API key (https://aistudio.google.com/)
- Python packages: assemblyai, google-generativeai, pydub
@tynes
tynes / 7702-interop.sol
Created November 17, 2024 15:52
example 7702 smart contract wallet with op stack interop support
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/// @title L2ToL2CrossDomainMessenger
/// @notice Gives replay protection and domain binding to cross chain calls.
interface L2ToL2CrossDomainMessenger {
function crossDomainMessageSender() external view returns (address sender_);
function sendMessage(uint256 _chainid, address _target, bytes memory _data) external;
}
@lucadonnoh
lucadonnoh / optimism.pl
Created September 6, 2024 09:42
OP Mainnet permissions modelling in Prolog.
:- discontiguous malicious/1.
:- discontiguous finalized_invalid_root/1.
:- discontiguous recovers/1.
:- discontiguous invalid_state/1.
% DEFINED IN PROXY
malicious_upgrade(proxy(_, Admin)) :- malicious(Admin).
% DEFINED IN MULTISIG (e.g. GNOSIS SAFE)
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* Workaround example on how to inject and execute arbitrary bytecode in solidity contract
* Currently only YUL supports verbatim: https://github.com/ethereum/solidity/issues/12067
* But you cannot import Solidity code in YUL, or YUL code in solidity, so this workaround is necessary.
* It works as long the byte sequence `0x7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F00` appear in the runtime code.
*
from slither import Slither
from slither.slithir.operations import InternalCall, SolidityCall
from slither.core.expressions.super_call_expression import SuperCallExpression
sl = Slither("MyContract.sol")
c = sl.get_contract_from_name("MyContract")[0]
def get_super_calls(x):
super_call_content = ""
@brockelmore
brockelmore / bedrock_deploy.sol
Last active December 22, 2024 02:10
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";
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
// Used in the `name()` function
// "Yul Token"
bytes32 constant nameLength = 0x0000000000000000000000000000000000000000000000000000000000000009;
bytes32 constant nameData = 0x59756c20546f6b656e0000000000000000000000000000000000000000000000;
// Used in the `symbol()` function
// "YUL"
coverage_report:
name: Generate coverage report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly
@emo-eth
emo-eth / chain_funcs.sh
Last active June 22, 2023 14:43
Helper functions for interacting with chains and Foundry tests. Source from .zshrc etc
###########
# Imports #
###########
# the RPCs file should include RPC URLs and Etherscan API Keys for relevant networks
# (in a separate file so they don't get committed)
source "$(dirname "$0")/rpcs.sh"
# any useful addresses for various networks for easy reference
source "$(dirname "$0")/addresses.sh"
# any useful functions and definitions for interacting with Seaport
// 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