Skip to content

Instantly share code, notes, and snippets.

View hellwolf's full-sized avatar

Miao ZhiCheng hellwolf

View GitHub Profile
@hellwolf
hellwolf / abi-to-sol.js
Last active June 9, 2023 15:14
Convert ABI to solidity file
/**
* Convert ABI json file to solidity interface contract
*/
const fs = require('fs');
const args = process.argv.slice(2);
function convert(inputFilename) {
const abi = JSON.parse(fs.readFileSync(inputFilename, 'utf8'));
pragma solidity >=0.4.21 <0.6.0;
// converted from cDAI.json
contract cDAI {
function name() external returns (
string memory
);
function approve(
address spender,
@hellwolf
hellwolf / rtoken-snippet.sol
Created August 6, 2019 11:25
rtoken sinippet
/**
* @notice Sender supplies assets into the market and receives rTokens in exchange
* @param mintAmount The amount of the underlying asset to supply
* @return uint 0=success, otherwise a failure
*/
function mint(uint256 mintAmount) external returns (bool);
/**
* @notice Sender redeems rTokens in exchange for the underlying asset
* @param redeemTokens The number of rTokens to redeem into underlying
@hellwolf
hellwolf / IRToken.sol
Created October 18, 2019 12:34
IRToken.sol for remix editor
// File: contracts/RTokenStructs.sol
pragma solidity ^0.5.8;
contract RTokenStructs {
/**
* @notice Global stats
*/
struct GlobalStats {
### Keybase proof
I hereby claim:
* I am hellwolf on github.
* I am hellwolf (https://keybase.io/hellwolf) on keybase.
* I have a public key ASDp-pJdZFPC_pAoE-6UzzywqGo1frs3weSoDhzHVwEy0wo
To claim this, I am signing this object:
@hellwolf
hellwolf / App.js
Last active June 3, 2020 07:26
App.js with setWeb3 and setDrizzle react hooks
import Web3 from "web3";
import React, { useState, useEffect } from "react";
import { DrizzleContext } from "@drizzle/react-plugin";
import { Drizzle } from "@drizzle/store";
import drizzleOptionsFactory from "./drizzleOptionsFactory";
import MyComponent from "./MyComponent";
import "./App.css";
@hellwolf
hellwolf / gist:a617da357f8de9da42a9fdc5286fa74d
Created January 29, 2021 20:19
List github repositories
curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/orgs/superfluid-finance/repos | jq '.[].name' -r | while read r;do echo /github subscribe superfluid-finance/$r commits:all,comments,reviews;done
@hellwolf
hellwolf / gist:2bedb0188eda7a1f5c4d400d9e76b2b5
Created March 31, 2021 14:23
Github List Cards in a Project Column
for i in `curl -su :$GITHUB_TOKEN -H "Accept: application/vnd.github.inertia-preview+json" https://api.github.com/projects/columns/12000498/cards | jq '.[] | .content_url' -r`;do curl -su :$GITHUB_TOKEN -H "Accept: application/vnd.github.inertia-preview+json" $i | jq '"[" + (.number|tostring) + "] - " + .title';done
@hellwolf
hellwolf / findEvent.js
Created April 26, 2021 17:07
Truffle contract findEventTopic0
findEventTopic0 = (truffleContract, eventName) => Object.keys(truffleContract.events).filter(e => truffleContract.events[e].name === eventName)[0]
@hellwolf
hellwolf / testCors.sh
Created June 14, 2021 10:33
testCors shell script
#!/bin/sh
if [ -z "$1" ]; then echo "Error: No origin was provided"; exit 1; fi
if [ -z "$2" ]; then echo "Error: No URL to test was provided"; exit 1; fi
if [ "$3" ]; then METHOD="$3"; else METHOD=GET; fi
curl -I -X OPTIONS \
-s \
-H "Origin: $1" \
-H "Access-Control-Request-Method: $METHOD" \