Skip to content

Instantly share code, notes, and snippets.

View KONFeature's full-sized avatar

Quentin Nivelais KONFeature

View GitHub Profile
@KONFeature
KONFeature / WebAuthNSmartWallet.ts
Created January 22, 2024 15:58
Simple permissionnless smart wallet using kernel account and the kernel webauthn validator
import { KernelExecuteAbi, KernelInitAbi } from "@/lib/abi/KernelAccountAbi";
import {
getAccountNonce,
getSenderAddress,
getUserOperationHash,
} from "permissionless";
import {
SignTransactionNotSupportedBySmartAccount,
SmartAccount,
} from "permissionless/accounts";
@KONFeature
KONFeature / typeboxEventBuilder.ts
Created December 23, 2023 20:56
Simple SST event builder using typebox instead of zod (missing a few stuff, like metadata)
import {
EventBridgeClient,
PutEventsCommand,
PutEventsCommandOutput,
PutEventsRequestEntry,
} from "@aws-sdk/client-eventbridge";
import { Static, TSchema } from "@sinclair/typebox";
import { TypeCompiler } from "@sinclair/typebox/compiler";
import { EventBus } from "sst/node/event-bus";
import { useLoader } from "./loaderReplica";
@KONFeature
KONFeature / jokerace-merkle-gen.ts
Last active December 14, 2023 12:34
Small gist used to reproduce voting MerkleTree generation & proof generation for a Jokerace contest. If you check out this gist, and find it useful, don't hesitate to vote for the Frak proposal aha
import {
encodePacked,
getAddress,
isAddress,
keccak256,
parseUnits,
} from "viem";
import { MerkleTree } from "merkletreejs";
import fs from "fs";
import csv from "csv-parser";
@KONFeature
KONFeature / EventGasUsageTest.sol
Created March 22, 2023 08:51
Test of different way to send event, and their impact on gas usage
// SPDX-License-Identifier: GNU GPLv3
pragma solidity 0.8.17;
import {PRBTest} from "@prb/test/PRBTest.sol";
contract SampleEvent {
event LogTransfer(address indexed from, address indexed to, uint256 value);
function transfer(address to, uint256 value) public {
emit LogTransfer(msg.sender, to, value);
@KONFeature
KONFeature / RevertGasUsageTest.sol
Created March 21, 2023 20:32
Sample revert gas usage test
// SPDX-License-Identifier: GNU GPLv3
pragma solidity 0.8.17;
import {PRBTest} from "@prb/test/PRBTest.sol";
contract RevertWithString {
function sampleRevert(uint256 amount) external pure {
require(amount > 10, "Not enough amount");
}
@KONFeature
KONFeature / run-all-nohup.sh
Created October 7, 2022 14:35
Run all the scripts with nohup
#!/bin/bash
# Assert we are on the root folder
if [ ! -d "contracts" ]; then
echo "error: script needs to be run from project root './tools/run-all-nohup.sh'"
exit 1
fi
# Exec the run all script with nohup
nohup sh tools/run-all.sh > tools/logs/security-analysis.log 2>&1 &
@KONFeature
KONFeature / run-all.sh
Created October 7, 2022 14:28
Run all the security script from the tools folder
#!/bin/bash
# Assert we are on the root folder
if [ ! -d "contracts" ]; then
echo "error: script needs to be run from project root './tools/run-all.sh'"
exit 1
fi
# Run slither analysis
./tools/slither/slither.sh > tools/logs/slither-output.log
@KONFeature
KONFeature / mythril.sh
Last active October 7, 2022 10:42
Script to run mythril inside a project to perform some security check
#!/bin/bash
# Assert we are in the right folder
if [ ! -d "contracts" ]; then
echo "error: script needs to be run from project root './tools/mythril/mythril.sh'"
exit 1
fi
# Run mythril analyse on the given contract
function analyse_contract {
@KONFeature
KONFeature / ComposeOverlayViewService.kt
Created June 28, 2022 21:34
Service ready to display complete view (with the right context to access the window manager and layout inflater if needed, but also access to a saved state registry and a view model store owner). Then a compose overlay service, that use the first one to push a compose view as system overlay, and also proposing a simple draggable box that can be …
import android.content.Intent
import android.graphics.PixelFormat
import android.os.IBinder
import android.view.Gravity
import android.view.WindowManager
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue