This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract KeyValueStorage { | |
mapping(address => mapping(bytes32 => uint256)) _uintStorage; | |
mapping(address => mapping(bytes32 => address)) _addressStorage; | |
mapping(address => mapping(bytes32 => bool)) _boolStorage; | |
/**** Get Methods ***********/ | |
function getAddress(bytes32 key) public view returns (address) { | |
return _addressStorage[msg.sender][key]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
import "./KeyValueStorage.sol"; | |
import './StorageConsumer.sol'; | |
import './Proxy.sol'; | |
contract StoreNumber is StorageConsumer, Proxy { | |
function StoreNumber(KeyValueStorage storage_) | |
public | |
StorageConsumer(storage_) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
import "./Ownable.sol"; | |
contract Proxy is Ownable { | |
event Upgraded(address indexed implementation); | |
address internal _implementation; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
import "./KeyValueStorage.sol"; | |
import "./StorageStateful.sol"; | |
import "./KeyValueStorage.sol"; | |
contract StorageConsumer is StorageStateful { | |
function StorageConsumer(KeyValueStorage storage_) public { | |
_storage = storage_; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
import "./StorageStateful.sol"; | |
contract NumberLogicV1 is StorageStateful{ | |
function setNumber(uint _number) public { | |
_storage.setUint("MyNumber", 20*_number); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
import "./StorageStateful.sol"; | |
contract NumberLogicV2 is StorageStateful{ | |
function getNumber()public returns(uint){ | |
return _storage.getUint("MyNumber"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash' // importing extend library from javascript | |
import { expect } from 'chai' // importing mocha chai library for unit testing | |
import { web3 } from './helpers/w3' // importing w3 script from helpers to import w3 functions | |
import expectRevert from './helpers/expectRevert' | |
const accounts = web3.eth.accounts | |
const KeyValueStorage = artifacts.require("KeyValueStorage"); //eternal storage contract | |
const NumberLogicV1 = artifacts.require("NumberLogicV1"); //Implementation v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Parsing { | |
function callNumber(uint256 number) public view returns(bytes32){ | |
bytes32 hash = keccak256("callNumber(uint256)"); | |
return hash; | |
} | |
function callAddress(address _addr) public view returns(bytes32){ | |
bytes32 hash = keccak256("callAddress(address _addr)"); | |
return hash; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
contract Test { | |
bytes public result; | |
function saveArgs(uint arg1,bool arg2, string arg3, address arg4) public returns(bytes4){ | |
return this.saveArgs.selector; | |
} | |
function encodeMe(bytes4 selector, uint arg1,bool arg2, string arg3, address arg4) returns(bytes){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.19; | |
contract Interchain { | |
bytes public selector; | |
bytes public destHash; | |
function withdrawal(bytes32 destHash) returns(bytes4){ | |
return this.withdrawal.selector; |