Skip to content

Instantly share code, notes, and snippets.

@blmalone
blmalone / index.html
Created January 30, 2021 00:11
Sample Google Website Sign-In - Token retrieval
<html lang="en">
<head>
<meta name="google-signin-scope" content="email" />
<meta
name="google-signin-client_id"
content="enter_google_client_id_here"
/>
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
@blmalone
blmalone / curl-protected-resources.sh
Created February 1, 2021 17:40
Example Curl Command to Access protected AWS resources
curl -H "x-api-key: <api_gateway_api_key>" -H "Authorization: <google_jwt_token>" https://<api_gateway_uri>/prod/example/1
@blmalone
blmalone / google-authorizer.ts
Last active April 21, 2021 14:23
Google Token Authorizer
import { OAuth2Client } from "google-auth-library";
/**
* Unique client ID for application.
*/
const CLIENT_ID: string = process.env.GOOGLE_CLIENT_ID as string;
export const handler = async (event: any, _: any, callback: any) => {
const token = event.authorizationToken;
return verify(token, event);
@blmalone
blmalone / aws-cdk-secured-api.ts
Last active June 10, 2021 19:26
Secure AWS API Gateway with Google using Custom Authorizers
import * as lambda from "@aws-cdk/aws-lambda";
import * as cdk from "@aws-cdk/core";
import * as apigw from "@aws-cdk/aws-apigateway";
import { TokenAuthorizer } from "@aws-cdk/aws-apigateway";
export class CdkExampleStack extends cdk.Stack {
constructor(
scope: cdk.App,
id: string,
props?: cdk.StackProps
@blmalone
blmalone / ReceiveFallback.sol
Created November 8, 2022 13:35
Receive & Fallback
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract ReceiveFallback {
event Log(string func, uint value, address sender, bytes data);
fallback() external payable {
emit Log("fallback", msg.value, msg.sender, msg.data);
}
@blmalone
blmalone / extended_key.ts
Last active November 11, 2022 03:10
Creating an extended private key from bip32 test vector
import { algo, enc } from 'crypto-js';
import { ec as EC } from "elliptic";
import * as bs58check from "bs58check";
const ec = new EC("secp256k1");
const TEST_VECTOR_1_SEED = "000102030405060708090a0b0c0d0e0f";
const MASTER_KEY_DERIVATION_KEY = "Bitcoin seed";
const mainnetVersionBytesPriv = "0488ADE4";
const mainnetVersionBytesPub = "0488B21E";
Order of secp256k1 curve: fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
### MASTER KEY DERIVATION ###
Master Private Key: e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35 (Alice's parent private key)
Master Public Key: 0439a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c23cbe7ded0e7ce6a594896b8f62888fdbc5c8821305e2ea42bf01e37300116281
Master Compressed Public Key: 0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2
Master Chain Code: 873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d508 (Alice's parent chain code)
### HARDENED DERIVATION ###
@blmalone
blmalone / op-contracts-release-notes.md
Last active May 8, 2024 14:36
Op Contracts Release Notes Template

Overview

Give an overview of what's changed in this release.

Contracts Updated

Insert a list of L1 contracts that've changed an are being updated as part of this release.

Insert links to the contracts updated semantic version e.g. source code

@blmalone
blmalone / ExtractL2ProxyAdminOwners.sh
Created May 10, 2024 15:13
Finds proxy contracts on OP Mainnet that have active implementation contracts associated.
#!/bin/bash
# Finds proxy contracts on OP Mainnet that have active implementation contracts associated.
# Attempts to produce an exhaustive list of these contract addresses in 'active_proxies.txt'.
# This script checks the address range: 0x4200000000000000000000000000000000000000 -> 0x4200000000000000000000000000000000000800 as per genesis file.
output_file="active_proxies.txt"
rpc_url=$MAINNET_RPC_URL
no_implementation_contract="0x0000000000000000000000000000000000000000000000000000000000000000"
eip1967_proxy_impl_storage_slot=0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
@blmalone
blmalone / optimism-version-mappings.ts
Last active May 16, 2024 16:54
Define all L1 smart contracts version numbers for all optimism release tags (op-contracts/vX.Y.Z).
import * as https from "https";
/**
* A mapping of smart contract names to their corresponding paths in the Optimism repository.
*/
const CONTRACT_PATHS = {
AddressManager: "legacy/AddressManager",
AnchorStateRegistry: "dispute/AnchorStateRegistry",
DelayedWETH: "dispute/weth/DelayedWETH",
DisputeGameFactory: "dispute/DisputeGameFactory",