Skip to content

Instantly share code, notes, and snippets.

@oneleo
oneleo / userOperation.tsx
Created May 20, 2024 07:30
estimateGasLimit
// ...
function UserOperationConfirmation(props: { userOpLog: UserOperationLog }) {
// ...
// TODO: Put it into a dedicated module
const estimateGasFee = async () => {
const fee = await provider.getFeeData()
const gasPriceWithBuffer = (fee.gasPrice * 120n) / 100n
@oneleo
oneleo / index.ts
Last active April 30, 2024 10:23
Background Main
const fetchData = async () => {
const fetchUserOpsSent = async () => {
const s = storage.get()
const nm = new NetworkStorageManager(storage)
const bundler = nm.getActive().bundler
const bundlerProvider = new JsonRpcProvider(bundler.url)
console.log(
`[ttt] storage userOp: ${json.stringify(s.userOpPool, null, 2)}`
)
const userOps = Object.values(s.userOpPool)
// ...
import { type State } from "~background/storage"
import {
AccountType,
getStorage,
setStorageTest,
type Account
@oneleo
oneleo / p256.ts
Last active December 26, 2023 10:07
Secp256r1
import { AbiCoder } from "ethers";
import { readFileSync } from "fs";
import { p1363ToDer } from "./ecdsa-utils";
const userOpHash = process.argv[2];
const ethersAbi = AbiCoder.defaultAbiCoder();
const fido2Credential = JSON.parse(
readFileSync("test/ffi/bitwarden_export_20231219124736.json", "utf-8"),
@oneleo
oneleo / Test.md
Created October 27, 2023 07:38
Test

Here is a simple flow chart:

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
@oneleo
oneleo / settings.json
Last active September 10, 2023 11:34
Visual Studio Code Settings
{
// 同步更新至:https://gist.github.com/oneleo/780d90384b6444e504b8a7b2fc49f9e5
// -----------------------------
// ----------- VSCode -----------
// -----------------------------
// 滑鼠點選其他分頁時,舊分頁自動存檔
"files.autoSave": "onFocusChange",
// 調整字體大小
"editor.fontSize": 15,
// 文字超過螢幕自動挪到下一行
@oneleo
oneleo / remapLRShift.json
Created August 5, 2023 01:26
karabiner-elements: perfect solution while changing language inputs between EN and ZH (Location: ${HOME}/.config/karabiner/assets/complex_modifications/)
{
"title": "LR_Shift to Ctrl+Space",
"rules": [
{
"description": "Change L_Shift to switch EN/ZH condition",
"manipulators": [
{
"type": "basic",
"conditions": [
{
@oneleo
oneleo / remapLRShift.json
Last active August 5, 2023 01:25
karabiner-elements: partial solution while changing language inputs between EN and ZH
{
"title": "LR_Shift to Ctrl+Space",
"rules": [
{
"description": "Change L_Shift to switch EN/ZH condition",
"manipulators": [
{
"type": "basic",
"conditions": [
{
@oneleo
oneleo / prev_randao.py
Created April 28, 2023 03:19 — forked from a2468834/prev_randao.py
Calculate next slot prev_randao
import hashlib
import string
##### Helper function #####
ssz_byteorder = "little" # https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md
# https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#aliases
def isBytesN(input_):
# BytesN := Vector[uint8, N]
assert isinstance(input_, list)
title tags
有關上海升級,你需要知道的事 (test gist)
imToken, Staking Withdraw, envTest

以太坊上海升級,和你有關嗎?

前言

以太坊上海升級即將來臨,對於生態系裡的不同角色,針對此升級要做的事也有所不同。此篇文章我們帶領大家導覽上海升級與你的關係,並且該做什麼事來應對。