Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Razvan Berg PaulRBerg

View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@PaulRBerg
PaulRBerg / CarefulMath.sol
Created Aug 14, 2020
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.10+commit.00c0fcaf.js&optimize=true&gist=
View CarefulMath.sol
/* SPDX-License-Identifier: LGPL-3.0-or-later */
pragma solidity ^0.6.10;
/**
* @title CarefulMath
* @author Compound
* @notice Exponential module for storing fixed-precision decimals.
* @dev Derived from OpenZeppelin's SafeMath library
*/
abstract contract CarefulMath {
@PaulRBerg
PaulRBerg / testotron.ts
Created Aug 13, 2020
Logging block timestamps
View testotron.ts
import { BigNumber } from "@ethersproject/bignumber";
import { Signer } from "@ethersproject/abstract-signer";
import { waffle } from "@nomiclabs/buidler";
import { expect } from "chai";
export function shouldBehaveLikeGreeter(_signers: Signer[]): void {
describe("1st Block", function () {
beforeEach(async function () {
await waffle.provider.send("evm_setNextBlockTimestamp", [1597348800]);
const blockTimestamp: BigNumber = await this.testotron.getBlockTimestamp();
@PaulRBerg
PaulRBerg / augmentations.d.ts
Created Jul 29, 2020
Augmenting the Context type used by Mocha in beforeEach, it, etc.
View augmentations.d.ts
import { Erc20 } from "../typechain/Erc20";
declare module "mocha" {
export interface Context {
token: Token;
}
}
View rebalancePseudocode.sol
function rebalance(address user) returns (bool) {
uint currentTimestamp = block.timestamp;
if (currentTimestamp == priorRebalanceTimestamp) {
return true;
}
uint incomingDelta = 0;
for (incomingStream in incomingStreamsOf(user)) {
rebalance(incomingStream.sender);
uint streamBalanceOfRecipient = streamBalanceOfRecipient(incomingStream.id);
View call-exception.log
Greeter
greet
Deploying a Greeter with greeting: Hello from greeter!
✓ should return the greeting (42ms)
getBlockNumber
Deploying a Greeter with greeting: Hello from greeter!
✓ should sum up the number
ChildGreeter
getBlockNumber
@PaulRBerg
PaulRBerg / SbErc20.sol
Created Jun 2, 2020
Makes the solidity vscode extension crash
View SbErc20.sol
/* SPDX-License-Identifier: LGPL-3.0-or-later */
pragma solidity ^0.6.8;
import "./ErrorReporter.sol";
import "./SbAdmin.sol";
import "./SbErc20Interface.sol";
import "./SbErc20Storage.sol";
import "./ReentrancyGuard.sol";
View yarnTscErrors.txt
src/dataDisplay/Text/index.tsx:16:12 - error TS2345: Argument of type '({ color, theme }: ThemedStyledProps<Pick<DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "slot" | ... 255 more ... | "valueLink"> & { ...; } & Props, DefaultTheme>) => string | Disabled' is not assignable to parameter of type 'Interpolation<ThemedStyledProps<Pick<DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "slot" | ... 255 more ... | "valueLink"> & { ...; } & Props, DefaultTheme>>'.
Type '({ color, theme }: ThemedStyledProps<Pick<DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "slot" | ... 255 more ... | "valueLink"> & { ...; } & Props, DefaultTheme>) => string | Disabled' is not assignable to type 'InterpolationFunction<ThemedStyledProps<Pick<DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "slot" | ... 255 more ... | "valueLink"> & { ...; } & Props, DefaultTheme>>'.
Type 'string | Disabled' is not assignab
@PaulRBerg
PaulRBerg / deploymentScript.ts
Created May 22, 2020
Basic deployment script used in a Buidler project
View deploymentScript.ts
// We require the Buidler Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
// When running the script with `buidler run <script>` you'll find the Buidler
// Runtime Environment's members available in the global scope.
import bre from "@nomiclabs/buidler";
import { Contract, ContractFactory } from "ethers";
async function main(): Promise<void> {
// Buidler always runs the compile task when running scripts through it.
// If this runs in a standalone fashion you may want to call compile manually
@PaulRBerg
PaulRBerg / counter.ts
Last active May 20, 2020
Dummy test file used for reproducing a Buidler bug
View counter.ts
import chai from "chai";
import { deployContract, solidity } from "ethereum-waffle";
import { waffle } from "@nomiclabs/buidler";
import CounterArtifact from "../artifacts/Counter.json";
import { Counter } from "../typechain/Counter";
chai.use(solidity);
const { expect } = chai;
You can’t perform that action at this time.