Skip to content

Instantly share code, notes, and snippets.

pragma solidity >=0.5.0;
import './Proxy.sol';
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
// @title is where Proxy can lookup users version preference and update valid implementations
// @notice resolver is ownable
contract Resolver is Ownable{
@0xdewy
0xdewy / Example.js
Created June 17, 2019 08:00
Upgrading contracts
contract Example {
bytes32 public highestHash; // The current highest hash
// @notice if the sha3() hash of the string is higher than highest hash, replace highestHash with 'a'
function setHighestHash(string memory a)
public {
bytes32 newHash = keccak256(abi.encodePacked(a));
require(isHighest(a), "NOT HIGHEST HASH");
highestHash = newHash;
@0xdewy
0xdewy / Proxy.js
Last active June 17, 2019 07:51
Fallback function of Proxy contraact
function ()
payable
external {
address implementation = Resolver(resolver()).getUserVersion(msg.sender);
require(implementation != address(0), "INVALID IMPLEMENTATION");
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize) // Copy incoming calldata
let result := delegatecall(gas, implementation, ptr, calldatasize, 0, 0)
let size := returndatasize
function fib3(uint n) external pure returns(uint a) {
if (n == 0) {
return 0;
}
uint h = n / 2;
uint mask = 1;
// find highest set bit in n
while(mask <= h) {
mask <<= 1;
}
@0xdewy
0xdewy / keybase.md
Created November 20, 2017 15:13
Proving my keybase account

Keybase proof

I hereby claim:

  • I am kyledewy on github.
  • I am kyledewy (https://keybase.io/kyledewy) on keybase.
  • I have a public key ASDD2tZhpRmrXjo6uKB1OXXc_zhHZnkk3CctO2VsZ_Peswo

To claim this, I am signing this object: