Skip to content

Instantly share code, notes, and snippets.

View KONFeature's full-sized avatar

Quentin Nivelais KONFeature

View GitHub Profile
@KONFeature
KONFeature / mythril.sh
Last active October 7, 2022 10:42
Script to run mythril inside a project to perform some security check
View mythril.sh
#!/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 / run-all.sh
Created October 7, 2022 14:28
Run all the security script from the tools folder
View run-all.sh
#!/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 / run-all-nohup.sh
Created October 7, 2022 14:35
Run all the scripts with nohup
View run-all-nohup.sh
#!/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 / RevertGasUsageTest.sol
Created March 21, 2023 20:32
Sample revert gas usage test
View RevertGasUsageTest.sol
// 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 / EventGasUsageTest.sol
Created March 22, 2023 08:51
Test of different way to send event, and their impact on gas usage
View EventGasUsageTest.sol
// 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 / 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 …
View ComposeOverlayViewService.kt
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