From 13258b70acaa1470ca6fb38a7d8535c1ac53b6b2 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 13 Jun 2018 13:07:17 -0400 Subject: [PATCH 1/3] unit testing place for review --- .gitignore | 2 + .travis.yml | 17 +- README.md | 14 +- blockExplorerApi/app.go | 4 +- cmd/geth/chaincmd.go | 10 +- cmd/utils/flags.go | 13 +- config.toml | 2 +- consensus/ethash/consensus.go | 2 - core/blockchain.go | 10 +- core/chain_makers.go | 11 +- core/genesis.go | 27 +- eth/api_tracer.go | 8 + eth/backend.go | 17 +- eth/tracers/tracer.go | 6 + les/backend.go | 2 +- .../initShyftGeth.sh | 0 .../postgres_setup/create_shyftdb.psql | 0 .../postgres_setup/create_tables.psql | 9 - .../postgres_setup/drop_tables.psql | 2 - .../postgres_setup/drop_tables.sh | 3 + .../postgres_setup/init_tables.sh | 3 + shyft-cli/postgres_setup/initdb.sh | 4 + .../resetShyftGeth.sh | 0 run_js_in_geth.sh => shyft-cli/runJs.sh | 2 +- shyft-cli/setup.sh | 17 + shyft-cli/shyftFullReset.sh | 12 + .../startShyftGeth.sh | 0 .../web3}/checkbalances.js | 0 shyft-cli/web3/deployContract.js | 31 + .../web3}/getGreeting.js | 0 .../web3}/sendTransactions.js | 0 shyft-cli/web3/testContract.js | 58 + .../.node-xmlhttprequest-sync-64192 | 0 shyft-cli/web3/token_test/README.md | 32 + .../web3/token_test/callGreeterFnsTest.js | 7 + shyft-cli/web3/token_test/call_greeter_fns.js | 83 + .../web3}/token_test/calltx.js | 0 .../web3}/token_test/deploy.js | 0 shyft-cli/web3/token_test/deployToken.js | 22 + .../token_test/deploy_greeter_contracts.js | 94 + shyft-cli/web3/token_test/multi.js | 22 + shyft-cli/web3/token_test/package-lock.json | 43 + .../web3}/token_test/package.json | 0 .../web3}/token_test/token.sol | 0 .../build/contracts/Migrations.json | 1393 +++++ .../build/contracts/Transfers.json | 4652 +++++++++++++++++ .../build/contracts/Transfers2.json | 423 ++ .../contracts/Migrations.sol | 23 + .../contracts/Transfers.sol | 44 + .../contracts/Transfers2.sol | 7 + .../migrations/1_initial_migration.js | 5 + .../migrations/2_migrate.js | 7 + .../transfer-through-master/package-lock.json | 5 + .../web3/transfer-through-master/package.json | 15 + .../web3/transfer-through-master/test/test.js | 41 + .../transfer-through-master/truffle-config.js | 12 + .../web3/transfer-through-master/truffle.js | 10 + shyft-geth.sh | 47 + shyftBlockExplorerApi/app.go | 18 + .../handler.go | 39 + .../logger.go | 0 .../router.go | 0 .../routes.go | 6 + shyftDb/db.go | 37 + shyftDb/postgres_setup/initdb.sh | 1 - .../create_shyftdb_test.psql | 1 + .../create_tables_test.psql | 40 + .../postgres_setup_test/drop_tables_test.psql | 3 + .../postgres_setup_test/drop_tables_test.sh | 1 + shyftDb/postgres_setup_test/initTestdb.sh | 1 + .../postgres_setup_test/init_tables_test.sh | 1 + shyftDb/postgres_test.go | 42 + shyftDb/shyft_database_util.go | 168 +- shyftDb/shyft_database_util_test.go | 451 ++ shyftFullReset.sh | 5 - simulations/deployContract.js | 27 - simulations/token_test/README.md | 9 - 77 files changed, 7893 insertions(+), 230 deletions(-) rename initShyftGeth.sh => shyft-cli/initShyftGeth.sh (100%) rename {shyftDb => shyft-cli}/postgres_setup/create_shyftdb.psql (100%) rename {shyftDb => shyft-cli}/postgres_setup/create_tables.psql (84%) rename {shyftDb => shyft-cli}/postgres_setup/drop_tables.psql (54%) rename {shyftDb => shyft-cli}/postgres_setup/drop_tables.sh (52%) rename {shyftDb => shyft-cli}/postgres_setup/init_tables.sh (53%) create mode 100644 shyft-cli/postgres_setup/initdb.sh rename resetShyftGeth.sh => shyft-cli/resetShyftGeth.sh (100%) rename run_js_in_geth.sh => shyft-cli/runJs.sh (80%) create mode 100644 shyft-cli/setup.sh create mode 100644 shyft-cli/shyftFullReset.sh rename startShyftGeth.sh => shyft-cli/startShyftGeth.sh (100%) rename {simulations => shyft-cli/web3}/checkbalances.js (100%) create mode 100644 shyft-cli/web3/deployContract.js rename {simulations => shyft-cli/web3}/getGreeting.js (100%) rename {simulations => shyft-cli/web3}/sendTransactions.js (100%) create mode 100644 shyft-cli/web3/testContract.js create mode 100644 shyft-cli/web3/token_test/.node-xmlhttprequest-sync-64192 create mode 100644 shyft-cli/web3/token_test/README.md create mode 100644 shyft-cli/web3/token_test/callGreeterFnsTest.js create mode 100644 shyft-cli/web3/token_test/call_greeter_fns.js rename {simulations => shyft-cli/web3}/token_test/calltx.js (100%) rename {simulations => shyft-cli/web3}/token_test/deploy.js (100%) create mode 100644 shyft-cli/web3/token_test/deployToken.js create mode 100644 shyft-cli/web3/token_test/deploy_greeter_contracts.js create mode 100644 shyft-cli/web3/token_test/multi.js create mode 100644 shyft-cli/web3/token_test/package-lock.json rename {simulations => shyft-cli/web3}/token_test/package.json (100%) rename {simulations => shyft-cli/web3}/token_test/token.sol (100%) create mode 100755 shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json create mode 100755 shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json create mode 100755 shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json create mode 100755 shyft-cli/web3/transfer-through-master/contracts/Migrations.sol create mode 100755 shyft-cli/web3/transfer-through-master/contracts/Transfers.sol create mode 100755 shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol create mode 100755 shyft-cli/web3/transfer-through-master/migrations/1_initial_migration.js create mode 100755 shyft-cli/web3/transfer-through-master/migrations/2_migrate.js create mode 100755 shyft-cli/web3/transfer-through-master/package-lock.json create mode 100755 shyft-cli/web3/transfer-through-master/package.json create mode 100755 shyft-cli/web3/transfer-through-master/test/test.js create mode 100755 shyft-cli/web3/transfer-through-master/truffle-config.js create mode 100755 shyft-cli/web3/transfer-through-master/truffle.js create mode 100755 shyft-geth.sh create mode 100644 shyftBlockExplorerApi/app.go rename {blockExplorerApi => shyftBlockExplorerApi}/handler.go (80%) rename {blockExplorerApi => shyftBlockExplorerApi}/logger.go (100%) rename {blockExplorerApi => shyftBlockExplorerApi}/router.go (100%) rename {blockExplorerApi => shyftBlockExplorerApi}/routes.go (94%) create mode 100644 shyftDb/db.go delete mode 100644 shyftDb/postgres_setup/initdb.sh create mode 100644 shyftDb/postgres_setup_test/create_shyftdb_test.psql create mode 100644 shyftDb/postgres_setup_test/create_tables_test.psql create mode 100644 shyftDb/postgres_setup_test/drop_tables_test.psql create mode 100644 shyftDb/postgres_setup_test/drop_tables_test.sh create mode 100644 shyftDb/postgres_setup_test/initTestdb.sh create mode 100644 shyftDb/postgres_setup_test/init_tables_test.sh create mode 100644 shyftDb/postgres_test.go create mode 100644 shyftDb/shyft_database_util_test.go delete mode 100644 shyftFullReset.sh delete mode 100644 simulations/deployContract.js delete mode 100644 simulations/token_test/README.md diff --git a/.gitignore b/.gitignore index a2326e3cfa..3561546ca9 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ $HOME # Remove Shyft Data shyftData/* +shyft-cli/web3/token_test/node_modules +shyft-cli/web3/transfer-through-master/node_modules diff --git a/.travis.yml b/.travis.yml index b3757ff7d9..c4753fa9d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: go -go_import_path: github.com/ethereum/go-ethereum +go_import_path: github.com/ShyftNetwork/shyft_go-ethereum sudo: false matrix: include: @@ -151,7 +151,7 @@ matrix: - export GOROOT=`pwd`/go - export GOPATH=$HOME/go script: - # Build the Android archive and upload it to Maven Central and Azure + # Build the Android archive and upload it gto Maven Central and Azure - curl https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip -o android-ndk-r15c.zip - unzip -q android-ndk-r15c.zip && rm android-ndk-r15c.zip - mv android-ndk-r15c $HOME @@ -178,6 +178,7 @@ matrix: - gem uninstall cocoapods -a -x - gem install cocoapods + - mv ~/.cocoapods/repos/master ~/.cocoapods/repos/master.bak - sed -i '.bak' 's/repo.join/!repo.join/g' $(dirname `gem which cocoapods`)/cocoapods/sources_manager.rb - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git clone --depth=1 https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master && pod setup --verbose; fi @@ -201,9 +202,9 @@ matrix: script: - go run build/ci.go purge -store gethstore/builds -days 14 -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/e09ccdce1048c5e03445 - on_success: change - on_failure: always +# notifications: +# webhooks: +# urls: +# - https://webhooks.gitter.im/e/e09ccdce1048c5e03445 +# on_success: change +# on_failure: always diff --git a/README.md b/README.md index 3d0d4d35d4..f7d50d21a6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Official golang implementation of the Ethereum protocol. https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667 )](https://godoc.org/github.com/ethereum/go-ethereum) [![Go Report Card](https://goreportcard.com/badge/github.com/ethereum/go-ethereum)](https://goreportcard.com/report/github.com/ethereum/go-ethereum) -[![Travis](https://travis-ci.org/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.org/ethereum/go-ethereum) +[![Build Status](https://travis-ci.org/ShyftNetwork/shyft_go-ethereum.svg?branch=master)](https://travis-ci.org/ShyftNetwork/shyft_go-ethereum) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Automated builds are available for stable releases and the unstable master branch. @@ -95,7 +95,7 @@ Specifying the `--testnet` flag however will reconfigure your Geth instance a bi `geth attach /testnet/geth.ipc`. Windows users are not affected by this. * Instead of connecting the main Ethereum network, the client will connect to the test network, which uses different P2P bootnodes, different network IDs and genesis states. - + *Note: Although there are some internal protective measures to prevent transactions from crossing over between the main network and test network, you should make sure to always use separate accounts for play-money and real-money. Unless you manually move accounts, Geth will by default correctly @@ -277,6 +277,16 @@ Which will start mining blocks and transactions on a single CPU thread, creditin the account specified by `--etherbase`. You can further tune the mining by changing the default gas limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`). +## SHYFT NOTES + +#### CLI +Run `./shyft-geth.sh` with one of the following flags: + +- `--setup` - Setups postgres and the shyft chain db. +- `--start` - Starts geth. +- `--reset` - Drops postgress and chain db, and reinstantiates both. +- `--js [web3 filename]` - Executes web3 calls with a passed file name. If the file name is `sendTransactions.js`, `./shyft-geth.sh --js sendTransactions`. + ## Contribution Thank you for considering to help out with the source code! We welcome contributions from diff --git a/blockExplorerApi/app.go b/blockExplorerApi/app.go index c1334fe903..9047b1d3aa 100644 --- a/blockExplorerApi/app.go +++ b/blockExplorerApi/app.go @@ -12,5 +12,7 @@ import ( func main() { router := NewRouter() - log.Fatal(http.ListenAndServe(":8080", handlers.CORS(handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS"}), handlers.AllowedOrigins([]string{"*"}))(router))) + port := "8080" + log.Printf("Listening on port " + " " + port) + log.Fatal(http.ListenAndServe(":"+port, handlers.CORS(handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS"}), handlers.AllowedOrigins([]string{"*"}))(router))) } diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 3f517a7bf0..c9ab72b6df 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -38,7 +38,6 @@ import ( "github.com/ethereum/go-ethereum/trie" "github.com/syndtr/goleveldb/leveldb/util" "gopkg.in/urfave/cli.v1" - "database/sql" ) var ( @@ -169,13 +168,7 @@ func initGenesis(ctx *cli.Context) error { if err != nil { utils.Fatalf("Failed to open database: %v", err) } - // @NOTE:shyft instantiate BlockExplorerDB here - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return nil - } - _, hash, err := core.SetupGenesisBlock(chaindb, genesis, blockExplorerDb) + _, hash, err := core.SetupGenesisBlock(chaindb, genesis) if err != nil { utils.Fatalf("Failed to write genesis block: %v", err) } @@ -321,6 +314,7 @@ func copyDb(ctx *cli.Context) error { syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode) dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil) + // Create a source peer to satisfy downloader requests from db, err := ethdb.NewLDBDatabase(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name), 256) if err != nil { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 3dbdeaaa9d..fa481522d4 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -57,9 +57,6 @@ import ( "github.com/ethereum/go-ethereum/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" "gopkg.in/urfave/cli.v1" - - // @shyft - "database/sql" ) var ( @@ -1219,7 +1216,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai var err error chainDb = MakeChainDatabase(ctx, stack) - config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx), nil) + config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx)) if err != nil { Fatalf("%v", err) } @@ -1252,14 +1249,8 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai } vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)} - // @NOTE:shyft instantiate BlockExplorerDB here? - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return nil, nil - } fmt.Println("Calling NewBlock CHAIN in flags.go ******************************") - chain, err = core.NewBlockChain(chainDb, blockExplorerDb,cache, config, engine, vmcfg) + chain, err = core.NewBlockChain(chainDb,cache, config, engine, vmcfg) if err != nil { Fatalf("Can't create BlockChain: %v", err) } diff --git a/config.toml b/config.toml index 23515e0b2f..e48def5a74 100644 --- a/config.toml +++ b/config.toml @@ -45,7 +45,7 @@ HTTPHost = "127.0.0.1" HTTPPort = 8545 HTTPCors = ["*"] HTTPVirtualHosts = ["localhost"] -HTTPModules = ["net", "web3", "eth", "shh"] +HTTPModules = ["net", "web3", "eth", "shh", "admin", "debug"] WSPort = 8546 WSModules = ["net", "web3", "eth", "shh"] diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 24c15c4f83..4a71ac26b1 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/log" set "gopkg.in/fatih/set.v0" ) @@ -565,6 +564,5 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header if (config.IsShyftNetwork(header.Number)) { state.AddBalance(ShyftNetworkConduitAddress, ShyftNetworkBlockReward) - log.Info("ShyftNetwork") } } diff --git a/core/blockchain.go b/core/blockchain.go index 2e231d8ee1..cb72402654 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -46,9 +46,6 @@ import ( "github.com/ethereum/go-ethereum/trie" "github.com/hashicorp/golang-lru" "gopkg.in/karalabe/cookiejar.v2/collections/prque" - - // @shyft - "database/sql" ) var ( @@ -96,7 +93,6 @@ type BlockChain struct { cacheConfig *CacheConfig // Cache configuration for pruning db ethdb.Database // Low level persistent database to store final content in - blockExplorerDb *sql.DB triegc *prque.Prque // Priority queue mapping block numbers to tries to gc gcproc time.Duration // Accumulates canonical block processing for trie dumping @@ -141,8 +137,7 @@ type BlockChain struct { // NewBlockChain returns a fully initialised block chain using information // available in the database. It initialises the default Ethereum Validator and // Processor. -func NewBlockChain(db ethdb.Database, blockExplorerDb *sql.DB, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) { - fmt.Printf("+++++++++++++++++core/blockchain.GO+++++++++++++++++++++++++NewBlockChain()") +func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) { if cacheConfig == nil { cacheConfig = &CacheConfig{ TrieNodeLimit: 256 * 1024 * 1024, @@ -159,7 +154,6 @@ func NewBlockChain(db ethdb.Database, blockExplorerDb *sql.DB, cacheConfig *Cach chainConfig: chainConfig, cacheConfig: cacheConfig, db: db, - blockExplorerDb: blockExplorerDb, triegc: prque.New(), stateCache: state.NewDatabase(db), quit: make(chan struct{}), @@ -908,7 +902,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. return NonStatTy, err } // @NOTE:SHYFT - Write block data for block explorer - if err := shyftdb.WriteBlock(bc.blockExplorerDb, block, receipts); err != nil { + if err := shyftdb.WriteBlock(block, receipts); err != nil { return NonStatTy, err } diff --git a/core/chain_makers.go b/core/chain_makers.go index 7e05bdbe4e..a785633f0b 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -28,9 +28,6 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/params" - - // @shyft - "database/sql" ) // So we can deterministically seed different blockchains @@ -169,9 +166,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse genblock := func(i int, parent *types.Block, statedb *state.StateDB) (*types.Block, types.Receipts) { // TODO(karalabe): This is needed for clique, which depends on multiple blocks. // It's nonetheless ugly to spin up a blockchain here. Get rid of this somehow. - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, _ := sql.Open("postgres", connStr) - blockchain, _ := NewBlockChain(db, blockExplorerDb,nil, config, engine, vm.Config{}) + blockchain, _ := NewBlockChain(db, nil, config, engine, vm.Config{}) defer blockchain.Stop() b := &BlockGen{i: i, parent: parent, chain: blocks, chainReader: blockchain, statedb: statedb, config: config, engine: engine} @@ -253,9 +248,7 @@ func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *B gspec := new(Genesis) db, _ := ethdb.NewMemDatabase() genesis := gspec.MustCommit(db) - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, _ := sql.Open("postgres", connStr) - blockchain, _ := NewBlockChain(db, blockExplorerDb, nil, params.AllEthashProtocolChanges, engine, vm.Config{}) + blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}) // Create and inject the requested chain if n == 0 { return db, blockchain, nil diff --git a/core/genesis.go b/core/genesis.go index b81b6f5d3f..26f7a771f1 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -35,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/shyftdb" "database/sql" "strconv" "time" @@ -142,13 +143,9 @@ func (e *GenesisMismatchError) Error() string { //WriteShyftGen writes the genesis block to Shyft db //@NOTE:SHYFT -func WriteShyftGen(sqldb *sql.DB, gen *Genesis, block *types.Block) { - if sqldb == nil { - log.Info("Initializing Shyft Postgres DB") - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, _ := sql.Open("postgres", connStr) - sqldb = blockExplorerDb - } +func WriteShyftGen(gen *Genesis, block *types.Block) { + + sqldb, _ := shyftdb.DBConnection() for k := range gen.Alloc { addr := k.String() @@ -196,13 +193,9 @@ func WriteShyftGen(sqldb *sql.DB, gen *Genesis, block *types.Block) { log.Info("Found Genesis Block") }}} -func WriteShyftBlockZero(sqldb *sql.DB, block *types.Block, gen *Genesis) error { - if sqldb == nil { - log.Info("Initializing Shyft Postgres DB") - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, _ := sql.Open("postgres", connStr) - sqldb = blockExplorerDb - } +func WriteShyftBlockZero(block *types.Block, gen *Genesis) error { + + sqldb, _ := shyftdb.DBConnection() coinbase := block.Header().Coinbase.String() number := block.Header().Number.String() @@ -252,7 +245,7 @@ func WriteShyftBlockZero(sqldb *sql.DB, block *types.Block, gen *Genesis) error // error is a *params.ConfigCompatError and the new, unwritten config is returned. // // The returned chain configuration is never nil. -func SetupGenesisBlock(db ethdb.Database, genesis *Genesis, sqldb *sql.DB) (*params.ChainConfig, common.Hash, error) { +func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error) { if genesis != nil && genesis.Config == nil { return params.AllEthashProtocolChanges, common.Hash{}, errGenesisNoConfig } @@ -267,9 +260,9 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis, sqldb *sql.DB) (*par } block, err := genesis.Commit(db) //@NOTE:SHYFT WRITE TO BLOCK ZERO DB - WriteShyftBlockZero(sqldb, block, genesis) + WriteShyftBlockZero(block, genesis) //@NOTE:SHYFT WRITE TO DB - WriteShyftGen(sqldb, genesis, block) + WriteShyftGen(genesis, block) return genesis.Config, block.Hash(), err } diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 07c4457bc3..e639bba33a 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -532,6 +532,11 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* // TraceTransaction returns the structured logs created during the execution of EVM // and returns them as a JSON object. func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { + fmt.Println("\n\n\t[API LOG]", api, "\n") + fmt.Printf("%+v\n", api.config) + fmt.Println("\n") + fmt.Printf("%+v\n", api.eth) + fmt.Println("\n") // Retrieve the transaction and assemble its EVM context tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) if tx == nil { @@ -546,6 +551,9 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha return nil, err } // Trace the transaction and return + //fmt.Println("\n\n\t\tRETURN") + //fmt.Println(api.traceTx(ctx, msg, vmctx, statedb, config)) + //fmt.Println("RETURN FINISHED") return api.traceTx(ctx, msg, vmctx, statedb, config) } diff --git a/eth/backend.go b/eth/backend.go index e4a34c46b0..44425ece9a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -47,9 +47,6 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" - - // @shyft - "database/sql" ) type LesServer interface { @@ -76,7 +73,6 @@ type Ethereum struct { // DB interfaces chainDb ethdb.Database // Block chain database - blockExplorerDb *sql.DB eventMux *event.TypeMux engine consensus.Engine @@ -116,16 +112,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { return nil, err } - // @NOTE:shyft instantiate BlockExplorerDB here // @TODO: Create Genesis Block - // @NOTE:shyft instantiate BlockExplorerDB here? - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return nil, err - } + stopDbUpgrade := upgradeDeduplicateData(chainDb) - chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis, blockExplorerDb) + chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis) if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { return nil, genesisErr } @@ -134,7 +124,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth := &Ethereum{ config: config, chainDb: chainDb, - blockExplorerDb: blockExplorerDb, chainConfig: chainConfig, eventMux: ctx.EventMux, accountManager: ctx.AccountManager, @@ -161,7 +150,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording} cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout} ) - eth.blockchain, err = core.NewBlockChain(chainDb, blockExplorerDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) + eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) if err != nil { return nil, err } diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 4cec9e633c..f0afeab6cb 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -496,6 +496,9 @@ func wrapError(context string, err error) error { // CaptureStart implements the Tracer interface to initialize the tracing operation. func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error { + //fmt.Println("\n\n\t\t type: ", reflect.TypeOf(input)) + fmt.Println("\t\t [TRACER INPUT]:", input) + fmt.Println("\t\t [TRACER INPUT STRING]:", string(input[:len(input)]), "\n\n") jst.ctx["type"] = "CALL" if create { jst.ctx["type"] = "CREATE" @@ -564,6 +567,9 @@ func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost // CaptureEnd is called after the call finishes to finalize the tracing. func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { + //fmt.Println("\n\n\t\t", reflect.TypeOf(output)) + fmt.Println("\t\t [TRACER OUTPUT]:", output[:len(output)]) + fmt.Println("\t\t [TRACER OUTPUT STRING]:", string(output[:len(output)]), "\n\n") jst.ctx["output"] = output jst.ctx["gasUsed"] = gasUsed jst.ctx["time"] = t.String() diff --git a/les/backend.go b/les/backend.go index e63751e353..6a324cb04b 100644 --- a/les/backend.go +++ b/les/backend.go @@ -84,7 +84,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) { if err != nil { return nil, err } - chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis, nil) + chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis) if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat { return nil, genesisErr } diff --git a/initShyftGeth.sh b/shyft-cli/initShyftGeth.sh similarity index 100% rename from initShyftGeth.sh rename to shyft-cli/initShyftGeth.sh diff --git a/shyftDb/postgres_setup/create_shyftdb.psql b/shyft-cli/postgres_setup/create_shyftdb.psql similarity index 100% rename from shyftDb/postgres_setup/create_shyftdb.psql rename to shyft-cli/postgres_setup/create_shyftdb.psql diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyft-cli/postgres_setup/create_tables.psql similarity index 84% rename from shyftDb/postgres_setup/create_tables.psql rename to shyft-cli/postgres_setup/create_tables.psql index e1fa00141a..f3f9adc976 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyft-cli/postgres_setup/create_tables.psql @@ -38,12 +38,3 @@ CREATE TABLE IF NOT EXISTS accounts ( balance numeric, txCountAccount numeric ); - -CREATE TABLE IF NOT EXISTS contracts ( - txHash text -); - -CREATE TABLE IF NOT EXISTS mined_blocks ( - blockNumber bigint, - addr text -); \ No newline at end of file diff --git a/shyftDb/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql similarity index 54% rename from shyftDb/postgres_setup/drop_tables.psql rename to shyft-cli/postgres_setup/drop_tables.psql index 2921358098..41563522dd 100644 --- a/shyftDb/postgres_setup/drop_tables.psql +++ b/shyft-cli/postgres_setup/drop_tables.psql @@ -1,5 +1,3 @@ DROP TABLE txs; DROP TABLE blocks; DROP TABLE accounts; -DROP TABLE contracts; -DROP TABLE mined_blocks; \ No newline at end of file diff --git a/shyftDb/postgres_setup/drop_tables.sh b/shyft-cli/postgres_setup/drop_tables.sh similarity index 52% rename from shyftDb/postgres_setup/drop_tables.sh rename to shyft-cli/postgres_setup/drop_tables.sh index 576637538a..b0d91aa52e 100644 --- a/shyftDb/postgres_setup/drop_tables.sh +++ b/shyft-cli/postgres_setup/drop_tables.sh @@ -1 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup psql -U postgres -d shyftdb -f drop_tables.psql \ No newline at end of file diff --git a/shyftDb/postgres_setup/init_tables.sh b/shyft-cli/postgres_setup/init_tables.sh similarity index 53% rename from shyftDb/postgres_setup/init_tables.sh rename to shyft-cli/postgres_setup/init_tables.sh index 988ad56700..50dfb4e695 100644 --- a/shyftDb/postgres_setup/init_tables.sh +++ b/shyft-cli/postgres_setup/init_tables.sh @@ -1 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup psql -U postgres -d shyftdb -f create_tables.psql diff --git a/shyft-cli/postgres_setup/initdb.sh b/shyft-cli/postgres_setup/initdb.sh new file mode 100644 index 0000000000..de2cf1c295 --- /dev/null +++ b/shyft-cli/postgres_setup/initdb.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup +psql -U postgres -f create_shyftdb.psql diff --git a/resetShyftGeth.sh b/shyft-cli/resetShyftGeth.sh similarity index 100% rename from resetShyftGeth.sh rename to shyft-cli/resetShyftGeth.sh diff --git a/run_js_in_geth.sh b/shyft-cli/runJs.sh similarity index 80% rename from run_js_in_geth.sh rename to shyft-cli/runJs.sh index b4a6649154..5c7f3e4fbd 100644 --- a/run_js_in_geth.sh +++ b/shyft-cli/runJs.sh @@ -1,4 +1,4 @@ file=$1 -echo $file +echo Executing "${file}"... runthing="./build/bin/geth --exec 'loadScript(\""$file"\")' attach http://127.0.0.1:8545" eval $runthing diff --git a/shyft-cli/setup.sh b/shyft-cli/setup.sh new file mode 100644 index 0000000000..dfb23704ee --- /dev/null +++ b/shyft-cli/setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then # Check if db is instantiated + echo Creating postgres db... + sh ./shyft-cli/postgres_setup/initdb.sh && # Init DB + echo Successfully created postgres db! && + sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables + sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data + sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth +else + echo Postgres DB found! + sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables + sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables + sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data + sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth +fi + diff --git a/shyft-cli/shyftFullReset.sh b/shyft-cli/shyftFullReset.sh new file mode 100644 index 0000000000..5dc4563468 --- /dev/null +++ b/shyft-cli/shyftFullReset.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then + echo Creating postgres db... + sh ./shyft-cli/postgres_setup/initdb.sh && + echo Successfully created postgres db! +fi + +sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables +sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables +sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data +sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth \ No newline at end of file diff --git a/startShyftGeth.sh b/shyft-cli/startShyftGeth.sh similarity index 100% rename from startShyftGeth.sh rename to shyft-cli/startShyftGeth.sh diff --git a/simulations/checkbalances.js b/shyft-cli/web3/checkbalances.js similarity index 100% rename from simulations/checkbalances.js rename to shyft-cli/web3/checkbalances.js diff --git a/shyft-cli/web3/deployContract.js b/shyft-cli/web3/deployContract.js new file mode 100644 index 0000000000..e4f35923c8 --- /dev/null +++ b/shyft-cli/web3/deployContract.js @@ -0,0 +1,31 @@ +var _message = "Hello" ; +var inboxContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"_newMessage","type":"string"}],"name":"setMessage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"message","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_message","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_newMessage","type":"string"}],"name":"EventMessage","type":"event"}]); +var inbox = inboxContract.new( + _message, + { + from: web3.eth.accounts[0], + data: '0x6060604052341561000f57600080fd5b604051610454380380610454833981016040528080518201919050508060009080519060200190610041929190610048565b50506100ed565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008957805160ff19168380011785556100b7565b828001600101855582156100b7579182015b828111156100b657825182559160200191906001019061009b565b5b5090506100c491906100c8565b5090565b6100ea91905b808211156100e65760008160009055506001016100ce565b5090565b90565b610358806100fc6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063368b877214610048578063e21f37ce146100a557600080fd5b341561005357600080fd5b6100a3600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610133565b005b34156100b057600080fd5b6100b86101e9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f85780820151818401526020810190506100dd565b50505050905090810190601f1680156101255780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8060009080519060200190610149929190610287565b507f2ec385c52f10e65de137fbbeb2582bb0f4a8460a2163012971e923d179d73ea7816040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ac578082015181840152602081019050610191565b50505050905090810190601f1680156101d95780820380516001836020036101000a031916815260200191505b509250505060405180910390a150565b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561027f5780601f106102545761010080835404028352916020019161027f565b820191906000526020600020905b81548152906001019060200180831161026257829003601f168201915b505050505081565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102c857805160ff19168380011785556102f6565b828001600101855582156102f6579182015b828111156102f55782518255916020019190600101906102da565b5b5090506103039190610307565b5090565b61032991905b8082111561032557600081600090555060010161030d565b5090565b905600a165627a7a72305820c83fcf90975f9c6996cf8dde1a2a1f4fab1f408588a2f8587487833ac98665630029', + gas: '4700000' + }, function (e, contract){ + if(!e) { + // NOTE: The callback will fire twice! + // Once the contract has the transactionHash property set and once its deployed on an address. + // e.g. check tx hash on the first call (transaction send) + if(!contract.address) { + console.log("TX hash:") + console.log(contract.transactionHash) // The hash of the transaction, which deploys the contract + + } else { + console.log("Contract address:") + console.log(contract.address) // the contract address + contract.methods.setMessage('New').call({from: web3.eth.accounts[0]}, function(error, result){ + if (error) { + console.log(error) + } else { + console.log('[METHOD RESULT]: ', result) + } + }); + } + + } + }); diff --git a/simulations/getGreeting.js b/shyft-cli/web3/getGreeting.js similarity index 100% rename from simulations/getGreeting.js rename to shyft-cli/web3/getGreeting.js diff --git a/simulations/sendTransactions.js b/shyft-cli/web3/sendTransactions.js similarity index 100% rename from simulations/sendTransactions.js rename to shyft-cli/web3/sendTransactions.js diff --git a/shyft-cli/web3/testContract.js b/shyft-cli/web3/testContract.js new file mode 100644 index 0000000000..78813c2f7c --- /dev/null +++ b/shyft-cli/web3/testContract.js @@ -0,0 +1,58 @@ +var testContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"live","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_bool","type":"bool"}],"name":"Live","type":"event"}]); +var test = testContract.new( + { + from: web3.eth.accounts[0], + data: '0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101698061005e6000396000f30060606040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638da5cb5b14610051578063957aa58c146100a6575b600080fd5b341561005c57600080fd5b6100646100d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100b157600080fd5b6100b96100f8565b604051808215151515815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60007f63f89985c88a92552c6e2ce4d4e46e9fbb7a06168c4536e662261decae02f9e76001604051808215151515815260200191505060405180910390a160019050905600a165627a7a7230582091089d445770c1c9bb2f0f86f6c0b8552ef59af41930e1f7ecfac34326b20e590029', + gas: '4700000' + }, function (e, contract){ + if (e) { + console.log("Error: ", e) + } + console.log("TX Hash:", contract.transactionHash) + if (typeof contract.address !== 'undefined') { + console.log('Contract address: ' + contract.address) + console.log('TransactionHash: ' + contract.transactionHash); + interact(contract.address); + } + }); + +function waitBlock(callback) { + function innerWaitBlock() { + + var receipt = web3.eth.getTransactionReceipt(test.transactionHash); + if (receipt && receipt.contractAddress) { + callback(receipt); + } else { + // console.log("Waiting a mined block to include your contract... currently in block " + web3.eth.blockNumber); + setTimeout(innerWaitBlock(), 4000); + } + } + innerWaitBlock(); +} + +waitBlock(function (receipt) { + // do stuff here now that the contract has been deployed + console.log("[Receipt] Contract Address: ", receipt.contract.address) +}); + +function interact(addr) { + var contract = testContract.at(addr); + contract.live({ + from: web3.eth.accounts[0], + gas: '4700000' + }, function (e, res) { + if (e) { + console.log(e) + } + console.log('Live TxHash: ', res) + }); + contract.live.call({ + from: web3.eth.accounts[0], + gas: '4700000' + }, function (e, res) { + if (e) { + console.log(e) + } + console.log('Live Response: ', res) + }) +} \ No newline at end of file diff --git a/shyft-cli/web3/token_test/.node-xmlhttprequest-sync-64192 b/shyft-cli/web3/token_test/.node-xmlhttprequest-sync-64192 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shyft-cli/web3/token_test/README.md b/shyft-cli/web3/token_test/README.md new file mode 100644 index 0000000000..c29332d16a --- /dev/null +++ b/shyft-cli/web3/token_test/README.md @@ -0,0 +1,32 @@ +`npm install` +run `node deploy.js` to deploy the contract. + +this will log out a contract in the geth logs. + +set the ADDR environment variable to this contract address. +ie `export ADDR=` + +then run `node calltx.js` + +(TODO: trigger the `calltx.js` function in the `deploy.js` file immediately) + +## TEST GREETERS / contract to contract txes + +First run `node deploy_greeter_contracts.js` + +this will log the address of the greeter and proxygreeter contracts and run various transactions on the contracts. + +To re-run transactions on these contracts you'll need to set the env variables, using the addresses logged during the `node deploy_greeter_contracts.js` process: + +``` +export GREETER= +export PROXYGREETER= +``` + +Then we can run: + +`node call_greeter_fns.js` + +This will run several write transactions, the hash will be logged to the geth logs. + +To run trace transaction on these txes, run `./build/bin/geth attach http://127.0.0.1:8545`, which will open an admin console (similar to a node console). Then run `debug.traceTransaction("", {tracer: "callTracer"})`, or `debug.traceTransaction("")` diff --git a/shyft-cli/web3/token_test/callGreeterFnsTest.js b/shyft-cli/web3/token_test/callGreeterFnsTest.js new file mode 100644 index 0000000000..a3bd4c0e03 --- /dev/null +++ b/shyft-cli/web3/token_test/callGreeterFnsTest.js @@ -0,0 +1,7 @@ +var Web3 = require('web3') +var web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545')) +var sendTxes = require('./call_greeter_fns').sendTxes +var greeter_addr = process.env.GREETER +var proxy_greeter_addr = process.env.PROXYGREETER + +sendTxes(web3, greeter_addr, proxy_greeter_addr) diff --git a/shyft-cli/web3/token_test/call_greeter_fns.js b/shyft-cli/web3/token_test/call_greeter_fns.js new file mode 100644 index 0000000000..cff2a98522 --- /dev/null +++ b/shyft-cli/web3/token_test/call_greeter_fns.js @@ -0,0 +1,83 @@ +var greetings = [ + 'My new greeting', + 'greeting 3', + 'greeting four', + 'greeting five' +] + +sendTxes = async (web3, greeter, proxyGreeter) => { + var greeterContractAddr = greeter + var proxyGreeterAddr = proxyGreeter + var greeterContract = web3.eth + .contract([ + { + constant: false, + inputs: [{ name: '_greeting', type: 'string' }], + name: 'setGreeting', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'greet', + outputs: [{ name: '', type: 'string' }], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'greeting', + outputs: [{ name: '', type: 'string' }], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + inputs: [{ name: '_greeting', type: 'string' }], + payable: false, + stateMutability: 'nonpayable', + type: 'constructor' + } + ]) + .at(greeterContractAddr) + var proxygreeterContract = web3.eth + .contract([ + { + constant: false, + inputs: [{ name: '_greeting', type: 'string' }], + name: 'proxySetGreeting', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [{ name: '_address', type: 'address' }], + payable: false, + stateMutability: 'nonpayable', + type: 'constructor' + } + ]) + .at(proxyGreeterAddr) + for (i = 0; i < greetings.length; i++) { + console.log(greetings[i]) + var res = await proxygreeterContract.proxySetGreeting.sendTransaction( + greetings[i], + { from: '0x43EC6d0942f7fAeF069F7F63D0384a27f529B062', gas: 3000000 } + ) + console.log(res) + await sleep(10000) + console.log(greeterContract.greet()) + } +} + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) +} + +module.exports = { sendTxes: sendTxes } diff --git a/simulations/token_test/calltx.js b/shyft-cli/web3/token_test/calltx.js similarity index 100% rename from simulations/token_test/calltx.js rename to shyft-cli/web3/token_test/calltx.js diff --git a/simulations/token_test/deploy.js b/shyft-cli/web3/token_test/deploy.js similarity index 100% rename from simulations/token_test/deploy.js rename to shyft-cli/web3/token_test/deploy.js diff --git a/shyft-cli/web3/token_test/deployToken.js b/shyft-cli/web3/token_test/deployToken.js new file mode 100644 index 0000000000..6173cca77b --- /dev/null +++ b/shyft-cli/web3/token_test/deployToken.js @@ -0,0 +1,22 @@ +var Web3 = require('web3') +var web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545")); + +var initialSupply = 1000000000000000 +var mytokenContract = web3.eth.contract([{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"_bool","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]); +var mytoken = mytokenContract.new( + initialSupply, + { + from: web3.eth.accounts[0], + data: '0x6060604052341561000f57600080fd5b60405160208061032f83398101604052808051906020019091905050806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550506102b18061007e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806370a0823114610048578063a9059cbb1461009557600080fd5b341561005357600080fd5b61007f600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506100ef565b6040518082815260200191505060405180910390f35b34156100a057600080fd5b6100d5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610107565b604051808215151515815260200191505060405180910390f35b60006020528060005260406000206000915090505481565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561015657600080fd5b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401101515156101e357600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060019050929150505600a165627a7a723058207dba9cbbfe34ea34b40caa5e6d2b53f9194dafa2420207342bebe3a5c949840c0029', + gas: '4700000' + }, function (e, contract) { + if (e) console.log("err1", e); + if (typeof contract.address !== 'undefined') { + console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); + var a = mytokenContract.at(contract.address); + a.transfer.sendTransaction(web3.eth.accounts[0], 5000000, {from: web3.eth.accounts[0]}, function (err, res) { + if (err) console.log("err", err); + console.log(res) + }) + } + }); \ No newline at end of file diff --git a/shyft-cli/web3/token_test/deploy_greeter_contracts.js b/shyft-cli/web3/token_test/deploy_greeter_contracts.js new file mode 100644 index 0000000000..3c15aa581d --- /dev/null +++ b/shyft-cli/web3/token_test/deploy_greeter_contracts.js @@ -0,0 +1,94 @@ +var Web3 = require('web3') +var web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545')) +var sendTxes = require('./call_greeter_fns').sendTxes + +// deploy javascript adapted from the remix templates +var _greeting = 'Greeting one' +var greeterAddress +var greeterContract = web3.eth.contract([ + { + constant: false, + inputs: [{ name: '_greeting', type: 'string' }], + name: 'setGreeting', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'greet', + outputs: [{ name: '', type: 'string' }], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + inputs: [{ name: '_greeting', type: 'string' }], + payable: false, + stateMutability: 'nonpayable', + type: 'constructor' + } +]) +var greeterAddr +var proxyGreeterAddr +var greeter = greeterContract.new( + _greeting, + { + from: web3.eth.accounts[0], + data: + '0x608060405234801561001057600080fd5b5060405161041c38038061041c833981018060405281019080805182019291905050508060009080519060200190610049929190610050565b50506100f5565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061009157805160ff19168380011785556100bf565b828001600101855582156100bf579182015b828111156100be5782518255916020019190600101906100a3565b5b5090506100cc91906100d0565b5090565b6100f291905b808211156100ee5760008160009055506001016100d6565b5090565b90565b610318806101046000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a413686214610051578063cfae3217146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061014a565b005b3480156100c657600080fd5b506100cf6101a5565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561010f5780820151818401526020810190506100f4565b50505050905090810190601f16801561013c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b33600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600090805190602001906101a1929190610247565b5050565b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561023d5780601f106102125761010080835404028352916020019161023d565b820191906000526020600020905b81548152906001019060200180831161022057829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028857805160ff19168380011785556102b6565b828001600101855582156102b6579182015b828111156102b557825182559160200191906001019061029a565b5b5090506102c391906102c7565b5090565b6102e991905b808211156102e55760008160009055506001016102cd565b5090565b905600a165627a7a7230582006a0234c8e31f8b96b20b9fb2f0ddddde4463524c8091978b490c87277170b620029', + gas: '4700000' + }, + function(e, contract) { + if (typeof contract.address !== 'undefined') { + var _address = contract.address + console.log( + 'Greeter Contract mined! address: ' + + _address + + ' transactionHash: ' + + contract.transactionHash + ) + greeterAddr = _address + var proxygreeterContract = web3.eth.contract([ + { + constant: false, + inputs: [{ name: '_greeting', type: 'string' }], + name: 'proxySetGreeting', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [{ name: '_address', type: 'address' }], + payable: false, + stateMutability: 'nonpayable', + type: 'constructor' + } + ]) + var proxygreeter = proxygreeterContract.new( + _address, + { + from: web3.eth.accounts[0], + data: + '0x608060405234801561001057600080fd5b5060405160208061026e83398101806040528101908080519060200190929190505050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506101eb806100836000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806369c92f6a14610046575b600080fd5b34801561005257600080fd5b506100ad600480360381019080803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506100af565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a4136862826040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561015857808201518184015260208101905061013d565b50505050905090810190601f1680156101855780820380516001836020036101000a031916815260200191505b5092505050600060405180830381600087803b1580156101a457600080fd5b505af11580156101b8573d6000803e3d6000fd5b50505050505600a165627a7a72305820946d166088750797f5bc3f5953806fd10118c88c95eac53d7aa7628997b69a310029', + gas: '4700000' + }, + function(e, contract) { + if (typeof contract.address !== 'undefined') { + proxyGreeterAddr = contract.address + console.log( + 'Proxy Greeter Contract mined! address: ' + + contract.address + + ' transactionHash: ' + + contract.transactionHash + ) + sendTxes(web3, greeterAddr, proxyGreeterAddr) + } + } + ) + } + } +) diff --git a/shyft-cli/web3/token_test/multi.js b/shyft-cli/web3/token_test/multi.js new file mode 100644 index 0000000000..9344c0e61a --- /dev/null +++ b/shyft-cli/web3/token_test/multi.js @@ -0,0 +1,22 @@ +var Web3 = require('web3') +var web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545")); + +var _message = "Hello"; +var multi = web3.eth.contract([{"constant":false,"inputs":[{"name":"_newMessage","type":"string"}],"name":"setMessage","outputs":[{"name":"_str","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"message","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_message","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_newMessage","type":"string"}],"name":"EventMessage","type":"event"}]); +var inbox = multi.new( + _message, + { + from: web3.eth.accounts[0], + data: '0x6060604052341561000f57600080fd5b6040516109cd3803806109cd833981016040528080518201919050508060009080519060200190610041929190610048565b50506100ed565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008957805160ff19168380011785556100b7565b828001600101855582156100b7579182015b828111156100b657825182559160200191906001019061009b565b5b5090506100c491906100c8565b5090565b6100ea91905b808211156100e65760008160009055506001016100ce565b5090565b90565b6108d1806100fc6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063368b877214610048578063e21f37ce1461011e57600080fd5b341561005357600080fd5b6100a3600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506101ac565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100e35780820151818401526020810190506100c8565b50505050905090810190601f1680156101105780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561012957600080fd5b6101316102b9565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610171578082015181840152602081019050610156565b50505050905090810190601f16801561019e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101b46107d8565b6101bc6107d8565b82600090805190602001906101d29291906107ec565b507f2ec385c52f10e65de137fbbeb2582bb0f4a8460a2163012971e923d179d73ea7836040518080602001828103825283818151815260200191508051906020019080838360005b8381101561023557808201518184015260208101905061021a565b50505050905090810190601f1680156102625780820380516001836020036101000a031916815260200191505b509250505060405180910390a16102ae836040805190810160405280600181526020017f6400000000000000000000000000000000000000000000000000000000000000815250610357565b905080915050919050565b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561034f5780601f106103245761010080835404028352916020019161034f565b820191906000526020600020905b81548152906001019060200180831161033257829003601f168201915b505050505081565b61035f6107d8565b61039c83836020604051908101604052806000815250602060405190810160405280600081525060206040519081016040528060008152506103a4565b905092915050565b6103ac6107d8565b6103b461086c565b6103bc61086c565b6103c461086c565b6103cc61086c565b6103d461086c565b6103dc6107d8565b6103e461086c565b6000808e98508d97508c96508b95508a94508451865188518a518c51010101016040518059106104115750595b9080825280602002602001820160405250935083925060009150600090505b88518110156104e357888181518110151561044757fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283838060010194508151811015156104a657fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050610430565b600090505b875181101561059b5787818151811015156104ff57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838380600101945081518110151561055e57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806001019150506104e8565b600090505b86518110156106535786818151811015156105b757fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838380600101945081518110151561061657fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806001019150506105a0565b600090505b855181101561070b57858181518110151561066f57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283838060010194508151811015156106ce57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050610658565b600090505b84518110156107c357848181518110151561072757fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838380600101945081518110151561078657fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050610710565b82995050505050505050505095945050505050565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061082d57805160ff191683800117855561085b565b8280016001018555821561085b579182015b8281111561085a57825182559160200191906001019061083f565b5b5090506108689190610880565b5090565b602060405190810160405280600081525090565b6108a291905b8082111561089e576000816000905550600101610886565b5090565b905600a165627a7a7230582020b529379f871d55b9275f90248d26586073f215f39c72d4f954eae2c85256170029', + gas: '4700000' + }, function (e, contract) { + if (e) console.log("err1", e); + if (typeof contract.address !== 'undefined') { + console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); + var a = multi.at(contract.address); + a.setMessage.sendTransaction("Hi dustin this is what i am", {from: web3.eth.accounts[0]}, function (err, res) { + if (err) console.log("err", err); + console.log(res) + }) + } + }); \ No newline at end of file diff --git a/shyft-cli/web3/token_test/package-lock.json b/shyft-cli/web3/token_test/package-lock.json new file mode 100644 index 0000000000..74e85e8570 --- /dev/null +++ b/shyft-cli/web3/token_test/package-lock.json @@ -0,0 +1,43 @@ +{ + "name": "token_contract", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "bignumber.js": { + "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934" + }, + "crypto-js": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.8.tgz", + "integrity": "sha1-cV8HC/YBTyrpkqmLOSkli3E/CNU=" + }, + "utf8": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.2.tgz", + "integrity": "sha1-H6DZJw6b6FDZsFAn9jUZv0ZFfZY=" + }, + "web3": { + "version": "0.20.6", + "resolved": "https://registry.npmjs.org/web3/-/web3-0.20.6.tgz", + "integrity": "sha1-PpcwauAk+yThCj11yIQwJWIhUSA=", + "requires": { + "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", + "crypto-js": "3.1.8", + "utf8": "2.1.2", + "xhr2": "0.1.4", + "xmlhttprequest": "1.8.0" + } + }, + "xhr2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.1.4.tgz", + "integrity": "sha1-f4dliEdxbbUCYyOBL4GMras4el8=" + }, + "xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" + } + } +} diff --git a/simulations/token_test/package.json b/shyft-cli/web3/token_test/package.json similarity index 100% rename from simulations/token_test/package.json rename to shyft-cli/web3/token_test/package.json diff --git a/simulations/token_test/token.sol b/shyft-cli/web3/token_test/token.sol similarity index 100% rename from simulations/token_test/token.sol rename to shyft-cli/web3/token_test/token.sol diff --git a/shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json b/shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json new file mode 100755 index 0000000000..fae58950b1 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json @@ -0,0 +1,1393 @@ +{ + "contractName": "Migrations", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "last_completed_migration", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": false, + "inputs": [ + { + "name": "completed", + "type": "uint256" + } + ], + "name": "setCompleted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "new_address", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a7230582081dfbd8174037e45d69fcbe70d6680c7a2138f79ab9ba39bdffaa14fb7854aa50029", + "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a7230582081dfbd8174037e45d69fcbe70d6680c7a2138f79ab9ba39bdffaa14fb7854aa50029", + "sourceMap": "26:480:0:-;;;115:50;8:9:-1;5:2;;;30:1;27;20:12;5:2;115:50:0;150:10;142:5;;:18;;;;;;;;;;;;;;;;;;26:480;;;;;;", + "deployedSourceMap": "26:480:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;339:165;;8:9:-1;5:2;;;30:1;27;20:12;5:2;339:165:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:36;;8:9:-1;5:2;;;30:1;27;20:12;5:2;74:36:0;;;;;;;;;;;;;;;;;;;;;;;50:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;50:20:0;;;;;;;;;;;;;;;;;;;;;;;;;;;232:103;;8:9:-1;5:2;;;30:1;27;20:12;5:2;232:103:0;;;;;;;;;;;;;;;;;;;;;;;;;;339:165;401:19;215:5;;;;;;;;;;;201:19;;:10;:19;;;197:26;;;434:11;401:45;;452:8;:21;;;474:24;;452:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;452:47:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;452:47:0;;;;197:26;339:165;;:::o;74:36::-;;;;:::o;50:20::-;;;;;;;;;;;;;:::o;232:103::-;215:5;;;;;;;;;;;201:19;;:10;:19;;;197:26;;;321:9;294:24;:36;;;;197:26;232:103;:::o", + "source": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", + "sourcePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", + "ast": { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 56 + ] + }, + "id": 57, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + "^", + "0.4", + ".23" + ], + "nodeType": "PragmaDirective", + "src": "0:24:0" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 56, + "linearizedBaseContracts": [ + 56 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 3, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 56, + "src": "50:20:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 2, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "50:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 5, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 56, + "src": "74:36:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 4, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "74:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 13, + "nodeType": "Block", + "src": "136:29:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 11, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 8, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "142:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 9, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "150:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 10, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "150:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "142:18:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 12, + "nodeType": "ExpressionStatement", + "src": "142:18:0" + } + ] + }, + "documentation": null, + "id": 14, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 6, + "nodeType": "ParameterList", + "parameters": [], + "src": "126:2:0" + }, + "payable": false, + "returnParameters": { + "id": 7, + "nodeType": "ParameterList", + "parameters": [], + "src": "136:0:0" + }, + "scope": 56, + "src": "115:50:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 22, + "nodeType": "Block", + "src": "191:37:0", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 19, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 16, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "201:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 17, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "201:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 18, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "215:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "201:19:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 21, + "nodeType": "IfStatement", + "src": "197:26:0", + "trueBody": { + "id": 20, + "nodeType": "PlaceholderStatement", + "src": "222:1:0" + } + } + ] + }, + "documentation": null, + "id": 23, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 15, + "nodeType": "ParameterList", + "parameters": [], + "src": "188:2:0" + }, + "src": "169:59:0", + "visibility": "internal" + }, + { + "body": { + "id": 34, + "nodeType": "Block", + "src": "288:47:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 32, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 30, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "294:24:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 31, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "321:9:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "294:36:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 33, + "nodeType": "ExpressionStatement", + "src": "294:36:0" + } + ] + }, + "documentation": null, + "id": 35, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 28, + "modifierName": { + "argumentTypes": null, + "id": 27, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "277:10:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "277:10:0" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 26, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 25, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 35, + "src": "254:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 24, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "254:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "253:16:0" + }, + "payable": false, + "returnParameters": { + "id": 29, + "nodeType": "ParameterList", + "parameters": [], + "src": "288:0:0" + }, + "scope": 56, + "src": "232:103:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 54, + "nodeType": "Block", + "src": "395:109:0", + "statements": [ + { + "assignments": [ + 43 + ], + "declarations": [ + { + "constant": false, + "id": 43, + "name": "upgraded", + "nodeType": "VariableDeclaration", + "scope": 55, + "src": "401:19:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + }, + "typeName": { + "contractScope": null, + "id": 42, + "name": "Migrations", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 56, + "src": "401:10:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 47, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 45, + "name": "new_address", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 37, + "src": "434:11:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 44, + "name": "Migrations", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 56, + "src": "423:10:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Migrations_$56_$", + "typeString": "type(contract Migrations)" + } + }, + "id": 46, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "423:23:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "401:45:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 51, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "474:24:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 48, + "name": "upgraded", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 43, + "src": "452:8:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + } + }, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "setCompleted", + "nodeType": "MemberAccess", + "referencedDeclaration": 35, + "src": "452:21:0", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256) external" + } + }, + "id": 52, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "452:47:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 53, + "nodeType": "ExpressionStatement", + "src": "452:47:0" + } + ] + }, + "documentation": null, + "id": 55, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 40, + "modifierName": { + "argumentTypes": null, + "id": 39, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "384:10:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "384:10:0" + } + ], + "name": "upgrade", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 38, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 37, + "name": "new_address", + "nodeType": "VariableDeclaration", + "scope": 55, + "src": "356:19:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 36, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "356:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "355:21:0" + }, + "payable": false, + "returnParameters": { + "id": 41, + "nodeType": "ParameterList", + "parameters": [], + "src": "395:0:0" + }, + "scope": 56, + "src": "339:165:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 57, + "src": "26:480:0" + } + ], + "src": "0:507:0" + }, + "legacyAST": { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 56 + ] + }, + "id": 57, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + "^", + "0.4", + ".23" + ], + "nodeType": "PragmaDirective", + "src": "0:24:0" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 56, + "linearizedBaseContracts": [ + 56 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 3, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 56, + "src": "50:20:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 2, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "50:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 5, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 56, + "src": "74:36:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 4, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "74:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 13, + "nodeType": "Block", + "src": "136:29:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 11, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 8, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "142:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 9, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "150:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 10, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "150:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "142:18:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 12, + "nodeType": "ExpressionStatement", + "src": "142:18:0" + } + ] + }, + "documentation": null, + "id": 14, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 6, + "nodeType": "ParameterList", + "parameters": [], + "src": "126:2:0" + }, + "payable": false, + "returnParameters": { + "id": 7, + "nodeType": "ParameterList", + "parameters": [], + "src": "136:0:0" + }, + "scope": 56, + "src": "115:50:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 22, + "nodeType": "Block", + "src": "191:37:0", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 19, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 16, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "201:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 17, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "201:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 18, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "215:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "201:19:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 21, + "nodeType": "IfStatement", + "src": "197:26:0", + "trueBody": { + "id": 20, + "nodeType": "PlaceholderStatement", + "src": "222:1:0" + } + } + ] + }, + "documentation": null, + "id": 23, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 15, + "nodeType": "ParameterList", + "parameters": [], + "src": "188:2:0" + }, + "src": "169:59:0", + "visibility": "internal" + }, + { + "body": { + "id": 34, + "nodeType": "Block", + "src": "288:47:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 32, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 30, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "294:24:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 31, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "321:9:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "294:36:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 33, + "nodeType": "ExpressionStatement", + "src": "294:36:0" + } + ] + }, + "documentation": null, + "id": 35, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 28, + "modifierName": { + "argumentTypes": null, + "id": 27, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "277:10:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "277:10:0" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 26, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 25, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 35, + "src": "254:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 24, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "254:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "253:16:0" + }, + "payable": false, + "returnParameters": { + "id": 29, + "nodeType": "ParameterList", + "parameters": [], + "src": "288:0:0" + }, + "scope": 56, + "src": "232:103:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 54, + "nodeType": "Block", + "src": "395:109:0", + "statements": [ + { + "assignments": [ + 43 + ], + "declarations": [ + { + "constant": false, + "id": 43, + "name": "upgraded", + "nodeType": "VariableDeclaration", + "scope": 55, + "src": "401:19:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + }, + "typeName": { + "contractScope": null, + "id": 42, + "name": "Migrations", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 56, + "src": "401:10:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 47, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 45, + "name": "new_address", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 37, + "src": "434:11:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 44, + "name": "Migrations", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 56, + "src": "423:10:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Migrations_$56_$", + "typeString": "type(contract Migrations)" + } + }, + "id": 46, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "423:23:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "401:45:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 51, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "474:24:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 48, + "name": "upgraded", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 43, + "src": "452:8:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$56", + "typeString": "contract Migrations" + } + }, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "setCompleted", + "nodeType": "MemberAccess", + "referencedDeclaration": 35, + "src": "452:21:0", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256) external" + } + }, + "id": 52, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "452:47:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 53, + "nodeType": "ExpressionStatement", + "src": "452:47:0" + } + ] + }, + "documentation": null, + "id": 55, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 40, + "modifierName": { + "argumentTypes": null, + "id": 39, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "384:10:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "384:10:0" + } + ], + "name": "upgrade", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 38, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 37, + "name": "new_address", + "nodeType": "VariableDeclaration", + "scope": 55, + "src": "356:19:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 36, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "356:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "355:21:0" + }, + "payable": false, + "returnParameters": { + "id": 41, + "nodeType": "ParameterList", + "parameters": [], + "src": "395:0:0" + }, + "scope": 56, + "src": "339:165:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 57, + "src": "26:480:0" + } + ], + "src": "0:507:0" + }, + "compiler": { + "name": "solc", + "version": "0.4.24+commit.e67f0147.Emscripten.clang" + }, + "networks": { + "1": { + "events": {}, + "links": {}, + "address": "0xfaeccae8c1af6bdfd71095e1b6a2f61c61c8a7e7", + "transactionHash": "0xeee5c7819e1a662e45a8244d02305b531d2c4e11e67383dace9b458dc76f22dc" + }, + "1528420224459": { + "events": {}, + "links": {}, + "address": "0x8887d2e7638bec1c9badc47beaeddc6dd261a095", + "transactionHash": "0x1d1b9f147f05f37206bbfa1143bb5ec43c8a1e193d17513471b6d6f58911779c" + } + }, + "schemaVersion": "2.0.0", + "updatedAt": "2018-06-08T15:58:27.900Z" +} \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json new file mode 100755 index 0000000000..cd9330c614 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json @@ -0,0 +1,4652 @@ +{ + "contractName": "Transfers", + "abi": [ + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "balance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": false, + "inputs": [ + { + "name": "_addr", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "myBalance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "deposit", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_addr", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_addrs", + "type": "address[]" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "withdrawMulti", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b506100196100de565b604051809103906000f080158015610035573d6000803e3d6000fd5b50600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506100ee565b60405161010c806107a683390190565b6106a9806100fd6000396000f300608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636b557a221461007d578063a9059cbb146100ed578063c9116b691461013a578063d0e30db014610165578063e3d670d714610183578063f3fef3a3146101da575b600080fd5b34801561008957600080fd5b506100eb6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050610227565b005b3480156100f957600080fd5b50610138600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610349565b005b34801561014657600080fd5b5061014f6104a9565b6040518082815260200191505060405180910390f35b61016d6104ef565b6040518082815260200191505060405180910390f35b34801561018f57600080fd5b506101c4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610581565b6040518082815260200191505060405180910390f35b3480156101e657600080fd5b50610225600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610599565b005b600080835191508183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561027d57600080fd5b8183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600090505b818110156103435783818151811015156102e657fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610335573d6000803e3d6000fd5b5080806001019150506102d0565b50505050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561039857600080fd5b60405180807f7472616e73666572286164647265737329000000000000000000000000000000815250601101905060405180910390209050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682827c0100000000000000000000000000000000000000000000000000000000900490856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060006040518083038185885af1935050505050505050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b6000346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156105e657600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610678573d6000803e3d6000fd5b5050505600a165627a7a7230582073b86b0504a0668c11a4b9525431c2c1eb1f06ba1b37ab7b422840967732027c0029608060405234801561001057600080fd5b5060ed8061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a72305820e95f74106a3328ffadd8b0adb916d92497daab65998ee73cf40afff57dc4b29b0029", + "deployedBytecode": "0x608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636b557a221461007d578063a9059cbb146100ed578063c9116b691461013a578063d0e30db014610165578063e3d670d714610183578063f3fef3a3146101da575b600080fd5b34801561008957600080fd5b506100eb6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050610227565b005b3480156100f957600080fd5b50610138600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610349565b005b34801561014657600080fd5b5061014f6104a9565b6040518082815260200191505060405180910390f35b61016d6104ef565b6040518082815260200191505060405180910390f35b34801561018f57600080fd5b506101c4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610581565b6040518082815260200191505060405180910390f35b3480156101e657600080fd5b50610225600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610599565b005b600080835191508183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561027d57600080fd5b8183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600090505b818110156103435783818151811015156102e657fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610335573d6000803e3d6000fd5b5080806001019150506102d0565b50505050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561039857600080fd5b60405180807f7472616e73666572286164647265737329000000000000000000000000000000815250601101905060405180910390209050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682827c0100000000000000000000000000000000000000000000000000000000900490856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060006040518083038185885af1935050505050505050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b6000346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156105e657600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610678573d6000803e3d6000fd5b5050505600a165627a7a7230582073b86b0504a0668c11a4b9525431c2c1eb1f06ba1b37ab7b422840967732027c0029", + "sourceMap": "54:979:1:-;;;152:72;8:9:-1;5:2;;;30:1;27;20:12;5:2;152:72:1;181:16;;:::i;:::-;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;181:16:1;177:1;;:20;;;;;;;;;;;;;;;;;;218:1;;;;;;;;;;;201:6;;:19;;;;;;;;;;;;;;;;;;54:979;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "54:979:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;790:241;;8:9:-1;5:2;;;30:1;27;20:12;5:2;790:241:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;227:197;;8:9:-1;5:2;;;30:1;27;20:12;5:2;227:197:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;427:77;;8:9:-1;5:2;;;30:1;27;20:12;5:2;427:77:1;;;;;;;;;;;;;;;;;;;;;;;507:119;;;;;;;;;;;;;;;;;;;;;;;76:40;;8:9:-1;5:2;;;30:1;27;20:12;5:2;76:40:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;629:158;;8:9:-1;5:2;;;30:1;27;20:12;5:2;629:158:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;790:241;855:6;969;864;:13;855:22;;921:1;912:6;:10;889:7;:19;897:10;889:19;;;;;;;;;;;;;;;;:33;;881:42;;;;;;;;959:1;950:6;:10;927:7;:19;935:10;927:19;;;;;;;;;;;;;;;;:33;;;;;;;;;;;978:1;969:10;;964:64;985:1;981;:5;964:64;;;997:6;1004:1;997:9;;;;;;;;;;;;;;;;;;:18;;:26;1016:6;997:26;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;997:26:1;988:3;;;;;;;964:64;;;790:241;;;;:::o;227:197::-;326:10;315:6;292:7;:19;300:10;292:19;;;;;;;;;;;;;;;;:29;;284:38;;;;;;;;346:30;;;;;;;;;;;;;;;;;;;326:51;;381:6;;;;;;;;;;;:11;;399:6;407:3;381:37;;;;412:5;381:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;227:197;;;:::o;427:77::-;464:4;481:7;:19;489:10;481:19;;;;;;;;;;;;;;;;474:26;;427:77;:::o;507:119::-;550:4;583:9;560:7;:19;568:10;560:19;;;;;;;;;;;;;;;;:32;;;;;;;;;;;603:7;:19;611:10;603:19;;;;;;;;;;;;;;;;596:26;;507:119;:::o;76:40::-;;;;;;;;;;;;;;;;;:::o;629:158::-;717:6;694:7;:19;702:10;694:19;;;;;;;;;;;;;;;;:29;;686:38;;;;;;;;751:6;728:7;:19;736:10;728:19;;;;;;;;;;;;;;;;:29;;;;;;;;;;;761:5;:14;;:22;776:6;761:22;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;761:22:1;629:158;;:::o", + "source": "pragma solidity ^0.4.19;\n\nimport \"./Transfers2.sol\";\n\ncontract Transfers {\n\tmapping (address => uint) public balance;\n\tTransfers2 t;\n\taddress t_addr;\n\n\tconstructor() public {\n\t\tt = new Transfers2();\n\t\tt_addr = address(t);\n\t}\n\n\tfunction transfer(address _addr, uint _value) public {\n\t\trequire(balance[msg.sender] >= _value);\n\t\tbytes4 sig = bytes4(keccak256(\"transfer(address)\"));\n\t\tt_addr.call.value(_value)(sig, _addr);\t\t\n\t}\n\n\tfunction myBalance() public returns (uint) {\n\t\treturn balance[msg.sender];\n\t}\n\n\tfunction deposit() public payable returns (uint) {\n\t\tbalance[msg.sender] += msg.value;\n\t\treturn balance[msg.sender];\n\t}\n\n\tfunction withdraw(address _addr, uint _value) public {\n\t\trequire(balance[msg.sender] >= _value);\n\t\tbalance[msg.sender] -= _value;\n\t\t_addr.transfer(_value);\n\t}\n\n\tfunction withdrawMulti(address[] _addrs, uint _value) public {\n\t\tuint l = _addrs.length;\n\t\trequire(balance[msg.sender] >= _value * l);\n\t\tbalance[msg.sender] -= _value * l;\n\t\tfor (uint i = 0; i < l; i++){\n\t\t\t_addrs[i].transfer(_value);\n\t\t}\n\t}\n}", + "sourcePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", + "ast": { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", + "exportedSymbols": { + "Transfers": [ + 233 + ] + }, + "id": 234, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 58, + "literals": [ + "solidity", + "^", + "0.4", + ".19" + ], + "nodeType": "PragmaDirective", + "src": "0:24:1" + }, + { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "file": "./Transfers2.sol", + "id": 59, + "nodeType": "ImportDirective", + "scope": 234, + "sourceUnit": 250, + "src": "26:26:1", + "symbolAliases": [], + "unitAlias": "" + }, + { + "baseContracts": [], + "contractDependencies": [ + 249 + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 233, + "linearizedBaseContracts": [ + 233 + ], + "name": "Transfers", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 63, + "name": "balance", + "nodeType": "VariableDeclaration", + "scope": 233, + "src": "76:40:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + }, + "typeName": { + "id": 62, + "keyType": { + "id": 60, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "85:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Mapping", + "src": "76:25:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + }, + "valueType": { + "id": 61, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "96:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 65, + "name": "t", + "nodeType": "VariableDeclaration", + "scope": 233, + "src": "119:12:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + }, + "typeName": { + "contractScope": null, + "id": 64, + "name": "Transfers2", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 249, + "src": "119:10:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 67, + "name": "t_addr", + "nodeType": "VariableDeclaration", + "scope": 233, + "src": "134:14:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 66, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "134:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 82, + "nodeType": "Block", + "src": "173:51:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 74, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 70, + "name": "t", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 65, + "src": "177:1:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "id": 72, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "NewExpression", + "src": "181:14:1", + "typeDescriptions": { + "typeIdentifier": "t_function_creation_nonpayable$__$returns$_t_contract$_Transfers2_$249_$", + "typeString": "function () returns (contract Transfers2)" + }, + "typeName": { + "contractScope": null, + "id": 71, + "name": "Transfers2", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 249, + "src": "185:10:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + } + }, + "id": 73, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "181:16:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "src": "177:20:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "id": 75, + "nodeType": "ExpressionStatement", + "src": "177:20:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 80, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 76, + "name": "t_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 67, + "src": "201:6:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 78, + "name": "t", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 65, + "src": "218:1:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + ], + "id": 77, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "210:7:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": "address" + }, + "id": 79, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "210:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "201:19:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 81, + "nodeType": "ExpressionStatement", + "src": "201:19:1" + } + ] + }, + "documentation": null, + "id": 83, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 68, + "nodeType": "ParameterList", + "parameters": [], + "src": "163:2:1" + }, + "payable": false, + "returnParameters": { + "id": 69, + "nodeType": "ParameterList", + "parameters": [], + "src": "173:0:1" + }, + "scope": 233, + "src": "152:72:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 118, + "nodeType": "Block", + "src": "280:144:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 96, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 91, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "292:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 94, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 92, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "300:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 93, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "300:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "292:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 95, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 87, + "src": "315:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "292:29:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 90, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 267, + 268 + ], + "referencedDeclaration": 267, + "src": "284:7:1", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 97, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "284:38:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 98, + "nodeType": "ExpressionStatement", + "src": "284:38:1" + }, + { + "assignments": [ + 100 + ], + "declarations": [ + { + "constant": false, + "id": 100, + "name": "sig", + "nodeType": "VariableDeclaration", + "scope": 119, + "src": "326:10:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + }, + "typeName": { + "id": 99, + "name": "bytes4", + "nodeType": "ElementaryTypeName", + "src": "326:6:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 106, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "7472616e73666572286164647265737329", + "id": 103, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "356:19:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_1a695230cbbb2b7dfd76397005587fe7ab9ee5f528dbc5a16361e8100dc2c499", + "typeString": "literal_string \"transfer(address)\"" + }, + "value": "transfer(address)" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_1a695230cbbb2b7dfd76397005587fe7ab9ee5f528dbc5a16361e8100dc2c499", + "typeString": "literal_string \"transfer(address)\"" + } + ], + "id": 102, + "name": "keccak256", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 258, + "src": "346:9:1", + "typeDescriptions": { + "typeIdentifier": "t_function_sha3_pure$__$returns$_t_bytes32_$", + "typeString": "function () pure returns (bytes32)" + } + }, + "id": 104, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "346:30:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes32", + "typeString": "bytes32" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bytes32", + "typeString": "bytes32" + } + ], + "id": 101, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "339:6:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_bytes4_$", + "typeString": "type(bytes4)" + }, + "typeName": "bytes4" + }, + "id": 105, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "339:38:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "326:51:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 114, + "name": "sig", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 100, + "src": "407:3:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + } + }, + { + "argumentTypes": null, + "id": 115, + "name": "_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 85, + "src": "412:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "arguments": [ + { + "argumentTypes": null, + "id": 112, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 87, + "src": "399:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 107, + "name": "t_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 67, + "src": "381:6:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 110, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "381:11:1", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$", + "typeString": "function () payable returns (bool)" + } + }, + "id": 111, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "381:17:1", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_nonpayable$_t_uint256_$returns$_t_function_barecall_payable$__$returns$_t_bool_$value_$", + "typeString": "function (uint256) returns (function () payable returns (bool))" + } + }, + "id": 113, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "381:25:1", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$value", + "typeString": "function () payable returns (bool)" + } + }, + "id": 116, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "381:37:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 117, + "nodeType": "ExpressionStatement", + "src": "381:37:1" + } + ] + }, + "documentation": null, + "id": 119, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "transfer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 88, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 85, + "name": "_addr", + "nodeType": "VariableDeclaration", + "scope": 119, + "src": "245:13:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 84, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "245:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 87, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 119, + "src": "260:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 86, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "260:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "244:28:1" + }, + "payable": false, + "returnParameters": { + "id": 89, + "nodeType": "ParameterList", + "parameters": [], + "src": "280:0:1" + }, + "scope": 233, + "src": "227:197:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 129, + "nodeType": "Block", + "src": "470:34:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 124, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "481:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 127, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 125, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "489:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 126, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "489:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "481:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 123, + "id": 128, + "nodeType": "Return", + "src": "474:26:1" + } + ] + }, + "documentation": null, + "id": 130, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "myBalance", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 120, + "nodeType": "ParameterList", + "parameters": [], + "src": "445:2:1" + }, + "payable": false, + "returnParameters": { + "id": 123, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 122, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 130, + "src": "464:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 121, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "464:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "463:6:1" + }, + "scope": 233, + "src": "427:77:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 148, + "nodeType": "Block", + "src": "556:70:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 141, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 135, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "560:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 138, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 136, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "568:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 137, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "568:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "560:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "+=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 139, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "583:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 140, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "583:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "560:32:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 142, + "nodeType": "ExpressionStatement", + "src": "560:32:1" + }, + { + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 143, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "603:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 146, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 144, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "611:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 145, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "611:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "603:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 134, + "id": 147, + "nodeType": "Return", + "src": "596:26:1" + } + ] + }, + "documentation": null, + "id": 149, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "deposit", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 131, + "nodeType": "ParameterList", + "parameters": [], + "src": "523:2:1" + }, + "payable": true, + "returnParameters": { + "id": 134, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 133, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 149, + "src": "550:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 132, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "550:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "549:6:1" + }, + "scope": 233, + "src": "507:119:1", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 178, + "nodeType": "Block", + "src": "682:105:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 162, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 157, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "694:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 160, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 158, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "702:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 159, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "702:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "694:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 161, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 153, + "src": "717:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "694:29:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 156, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 267, + 268 + ], + "referencedDeclaration": 267, + "src": "686:7:1", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 163, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "686:38:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 164, + "nodeType": "ExpressionStatement", + "src": "686:38:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 170, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 165, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "728:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 168, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 166, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "736:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 167, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "736:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "728:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "-=", + "rightHandSide": { + "argumentTypes": null, + "id": 169, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 153, + "src": "751:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "728:29:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 171, + "nodeType": "ExpressionStatement", + "src": "728:29:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 175, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 153, + "src": "776:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 172, + "name": "_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 151, + "src": "761:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 174, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "761:14:1", + "typeDescriptions": { + "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 176, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "761:22:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 177, + "nodeType": "ExpressionStatement", + "src": "761:22:1" + } + ] + }, + "documentation": null, + "id": 179, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 154, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 151, + "name": "_addr", + "nodeType": "VariableDeclaration", + "scope": 179, + "src": "647:13:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 150, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "647:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 153, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 179, + "src": "662:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 152, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "662:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "646:28:1" + }, + "payable": false, + "returnParameters": { + "id": 155, + "nodeType": "ParameterList", + "parameters": [], + "src": "682:0:1" + }, + "scope": 233, + "src": "629:158:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 231, + "nodeType": "Block", + "src": "851:180:1", + "statements": [ + { + "assignments": [ + 188 + ], + "declarations": [ + { + "constant": false, + "id": 188, + "name": "l", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "855:6:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 187, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "855:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 191, + "initialValue": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 189, + "name": "_addrs", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 182, + "src": "864:6:1", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", + "typeString": "address[] memory" + } + }, + "id": 190, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "length", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "864:13:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "855:22:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 200, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 193, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "889:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 196, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 194, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "897:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 195, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "897:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "889:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 199, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 197, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 184, + "src": "912:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 198, + "name": "l", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 188, + "src": "921:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "912:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "889:33:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 192, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 267, + 268 + ], + "referencedDeclaration": 267, + "src": "881:7:1", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 201, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "881:42:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 202, + "nodeType": "ExpressionStatement", + "src": "881:42:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 210, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 203, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "927:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 206, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 204, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "935:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 205, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "935:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "927:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "-=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 209, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 207, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 184, + "src": "950:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 208, + "name": "l", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 188, + "src": "959:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "950:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "927:33:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 211, + "nodeType": "ExpressionStatement", + "src": "927:33:1" + }, + { + "body": { + "id": 229, + "nodeType": "Block", + "src": "992:36:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 226, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 184, + "src": "1016:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 222, + "name": "_addrs", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 182, + "src": "997:6:1", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", + "typeString": "address[] memory" + } + }, + "id": 224, + "indexExpression": { + "argumentTypes": null, + "id": 223, + "name": "i", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 213, + "src": "1004:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "997:9:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 225, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "997:18:1", + "typeDescriptions": { + "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 227, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "997:26:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 228, + "nodeType": "ExpressionStatement", + "src": "997:26:1" + } + ] + }, + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 218, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 216, + "name": "i", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 213, + "src": "981:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<", + "rightExpression": { + "argumentTypes": null, + "id": 217, + "name": "l", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 188, + "src": "985:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "981:5:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 230, + "initializationExpression": { + "assignments": [ + 213 + ], + "declarations": [ + { + "constant": false, + "id": 213, + "name": "i", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "969:6:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 212, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "969:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 215, + "initialValue": { + "argumentTypes": null, + "hexValue": "30", + "id": 214, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "978:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "nodeType": "VariableDeclarationStatement", + "src": "969:10:1" + }, + "loopExpression": { + "expression": { + "argumentTypes": null, + "id": 220, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "++", + "prefix": false, + "src": "988:3:1", + "subExpression": { + "argumentTypes": null, + "id": 219, + "name": "i", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 213, + "src": "988:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 221, + "nodeType": "ExpressionStatement", + "src": "988:3:1" + }, + "nodeType": "ForStatement", + "src": "964:64:1" + } + ] + }, + "documentation": null, + "id": 232, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "withdrawMulti", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 185, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 182, + "name": "_addrs", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "813:16:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", + "typeString": "address[]" + }, + "typeName": { + "baseType": { + "id": 180, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "813:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 181, + "length": null, + "nodeType": "ArrayTypeName", + "src": "813:9:1", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", + "typeString": "address[]" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 184, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "831:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 183, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "831:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "812:31:1" + }, + "payable": false, + "returnParameters": { + "id": 186, + "nodeType": "ParameterList", + "parameters": [], + "src": "851:0:1" + }, + "scope": 233, + "src": "790:241:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 234, + "src": "54:979:1" + } + ], + "src": "0:1033:1" + }, + "legacyAST": { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", + "exportedSymbols": { + "Transfers": [ + 233 + ] + }, + "id": 234, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 58, + "literals": [ + "solidity", + "^", + "0.4", + ".19" + ], + "nodeType": "PragmaDirective", + "src": "0:24:1" + }, + { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "file": "./Transfers2.sol", + "id": 59, + "nodeType": "ImportDirective", + "scope": 234, + "sourceUnit": 250, + "src": "26:26:1", + "symbolAliases": [], + "unitAlias": "" + }, + { + "baseContracts": [], + "contractDependencies": [ + 249 + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 233, + "linearizedBaseContracts": [ + 233 + ], + "name": "Transfers", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 63, + "name": "balance", + "nodeType": "VariableDeclaration", + "scope": 233, + "src": "76:40:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + }, + "typeName": { + "id": 62, + "keyType": { + "id": 60, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "85:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Mapping", + "src": "76:25:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + }, + "valueType": { + "id": 61, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "96:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 65, + "name": "t", + "nodeType": "VariableDeclaration", + "scope": 233, + "src": "119:12:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + }, + "typeName": { + "contractScope": null, + "id": 64, + "name": "Transfers2", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 249, + "src": "119:10:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 67, + "name": "t_addr", + "nodeType": "VariableDeclaration", + "scope": 233, + "src": "134:14:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 66, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "134:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 82, + "nodeType": "Block", + "src": "173:51:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 74, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 70, + "name": "t", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 65, + "src": "177:1:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "id": 72, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "NewExpression", + "src": "181:14:1", + "typeDescriptions": { + "typeIdentifier": "t_function_creation_nonpayable$__$returns$_t_contract$_Transfers2_$249_$", + "typeString": "function () returns (contract Transfers2)" + }, + "typeName": { + "contractScope": null, + "id": 71, + "name": "Transfers2", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 249, + "src": "185:10:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + } + }, + "id": 73, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "181:16:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "src": "177:20:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + }, + "id": 75, + "nodeType": "ExpressionStatement", + "src": "177:20:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 80, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 76, + "name": "t_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 67, + "src": "201:6:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 78, + "name": "t", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 65, + "src": "218:1:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_Transfers2_$249", + "typeString": "contract Transfers2" + } + ], + "id": 77, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "210:7:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": "address" + }, + "id": 79, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "210:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "201:19:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 81, + "nodeType": "ExpressionStatement", + "src": "201:19:1" + } + ] + }, + "documentation": null, + "id": 83, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 68, + "nodeType": "ParameterList", + "parameters": [], + "src": "163:2:1" + }, + "payable": false, + "returnParameters": { + "id": 69, + "nodeType": "ParameterList", + "parameters": [], + "src": "173:0:1" + }, + "scope": 233, + "src": "152:72:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 118, + "nodeType": "Block", + "src": "280:144:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 96, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 91, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "292:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 94, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 92, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "300:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 93, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "300:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "292:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 95, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 87, + "src": "315:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "292:29:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 90, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 267, + 268 + ], + "referencedDeclaration": 267, + "src": "284:7:1", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 97, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "284:38:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 98, + "nodeType": "ExpressionStatement", + "src": "284:38:1" + }, + { + "assignments": [ + 100 + ], + "declarations": [ + { + "constant": false, + "id": 100, + "name": "sig", + "nodeType": "VariableDeclaration", + "scope": 119, + "src": "326:10:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + }, + "typeName": { + "id": 99, + "name": "bytes4", + "nodeType": "ElementaryTypeName", + "src": "326:6:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 106, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "7472616e73666572286164647265737329", + "id": 103, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "356:19:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_1a695230cbbb2b7dfd76397005587fe7ab9ee5f528dbc5a16361e8100dc2c499", + "typeString": "literal_string \"transfer(address)\"" + }, + "value": "transfer(address)" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_1a695230cbbb2b7dfd76397005587fe7ab9ee5f528dbc5a16361e8100dc2c499", + "typeString": "literal_string \"transfer(address)\"" + } + ], + "id": 102, + "name": "keccak256", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 258, + "src": "346:9:1", + "typeDescriptions": { + "typeIdentifier": "t_function_sha3_pure$__$returns$_t_bytes32_$", + "typeString": "function () pure returns (bytes32)" + } + }, + "id": 104, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "346:30:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes32", + "typeString": "bytes32" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bytes32", + "typeString": "bytes32" + } + ], + "id": 101, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "339:6:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_bytes4_$", + "typeString": "type(bytes4)" + }, + "typeName": "bytes4" + }, + "id": 105, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "339:38:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "326:51:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 114, + "name": "sig", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 100, + "src": "407:3:1", + "typeDescriptions": { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + } + }, + { + "argumentTypes": null, + "id": 115, + "name": "_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 85, + "src": "412:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bytes4", + "typeString": "bytes4" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "arguments": [ + { + "argumentTypes": null, + "id": 112, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 87, + "src": "399:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 107, + "name": "t_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 67, + "src": "381:6:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 110, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "381:11:1", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$", + "typeString": "function () payable returns (bool)" + } + }, + "id": 111, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "381:17:1", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_nonpayable$_t_uint256_$returns$_t_function_barecall_payable$__$returns$_t_bool_$value_$", + "typeString": "function (uint256) returns (function () payable returns (bool))" + } + }, + "id": 113, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "381:25:1", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$value", + "typeString": "function () payable returns (bool)" + } + }, + "id": 116, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "381:37:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 117, + "nodeType": "ExpressionStatement", + "src": "381:37:1" + } + ] + }, + "documentation": null, + "id": 119, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "transfer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 88, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 85, + "name": "_addr", + "nodeType": "VariableDeclaration", + "scope": 119, + "src": "245:13:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 84, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "245:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 87, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 119, + "src": "260:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 86, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "260:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "244:28:1" + }, + "payable": false, + "returnParameters": { + "id": 89, + "nodeType": "ParameterList", + "parameters": [], + "src": "280:0:1" + }, + "scope": 233, + "src": "227:197:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 129, + "nodeType": "Block", + "src": "470:34:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 124, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "481:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 127, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 125, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "489:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 126, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "489:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "481:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 123, + "id": 128, + "nodeType": "Return", + "src": "474:26:1" + } + ] + }, + "documentation": null, + "id": 130, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "myBalance", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 120, + "nodeType": "ParameterList", + "parameters": [], + "src": "445:2:1" + }, + "payable": false, + "returnParameters": { + "id": 123, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 122, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 130, + "src": "464:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 121, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "464:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "463:6:1" + }, + "scope": 233, + "src": "427:77:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 148, + "nodeType": "Block", + "src": "556:70:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 141, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 135, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "560:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 138, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 136, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "568:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 137, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "568:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "560:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "+=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 139, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "583:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 140, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "583:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "560:32:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 142, + "nodeType": "ExpressionStatement", + "src": "560:32:1" + }, + { + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 143, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "603:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 146, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 144, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "611:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 145, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "611:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "603:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 134, + "id": 147, + "nodeType": "Return", + "src": "596:26:1" + } + ] + }, + "documentation": null, + "id": 149, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "deposit", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 131, + "nodeType": "ParameterList", + "parameters": [], + "src": "523:2:1" + }, + "payable": true, + "returnParameters": { + "id": 134, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 133, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 149, + "src": "550:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 132, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "550:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "549:6:1" + }, + "scope": 233, + "src": "507:119:1", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 178, + "nodeType": "Block", + "src": "682:105:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 162, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 157, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "694:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 160, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 158, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "702:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 159, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "702:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "694:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 161, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 153, + "src": "717:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "694:29:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 156, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 267, + 268 + ], + "referencedDeclaration": 267, + "src": "686:7:1", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 163, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "686:38:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 164, + "nodeType": "ExpressionStatement", + "src": "686:38:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 170, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 165, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "728:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 168, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 166, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "736:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 167, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "736:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "728:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "-=", + "rightHandSide": { + "argumentTypes": null, + "id": 169, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 153, + "src": "751:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "728:29:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 171, + "nodeType": "ExpressionStatement", + "src": "728:29:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 175, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 153, + "src": "776:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 172, + "name": "_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 151, + "src": "761:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 174, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "761:14:1", + "typeDescriptions": { + "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 176, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "761:22:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 177, + "nodeType": "ExpressionStatement", + "src": "761:22:1" + } + ] + }, + "documentation": null, + "id": 179, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 154, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 151, + "name": "_addr", + "nodeType": "VariableDeclaration", + "scope": 179, + "src": "647:13:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 150, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "647:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 153, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 179, + "src": "662:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 152, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "662:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "646:28:1" + }, + "payable": false, + "returnParameters": { + "id": 155, + "nodeType": "ParameterList", + "parameters": [], + "src": "682:0:1" + }, + "scope": 233, + "src": "629:158:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 231, + "nodeType": "Block", + "src": "851:180:1", + "statements": [ + { + "assignments": [ + 188 + ], + "declarations": [ + { + "constant": false, + "id": 188, + "name": "l", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "855:6:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 187, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "855:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 191, + "initialValue": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 189, + "name": "_addrs", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 182, + "src": "864:6:1", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", + "typeString": "address[] memory" + } + }, + "id": 190, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "length", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "864:13:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "855:22:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 200, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 193, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "889:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 196, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 194, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "897:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 195, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "897:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "889:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 199, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 197, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 184, + "src": "912:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 198, + "name": "l", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 188, + "src": "921:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "912:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "889:33:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 192, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 267, + 268 + ], + "referencedDeclaration": 267, + "src": "881:7:1", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 201, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "881:42:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 202, + "nodeType": "ExpressionStatement", + "src": "881:42:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 210, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 203, + "name": "balance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 63, + "src": "927:7:1", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 206, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 204, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "935:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 205, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "935:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "927:19:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "-=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 209, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 207, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 184, + "src": "950:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 208, + "name": "l", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 188, + "src": "959:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "950:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "927:33:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 211, + "nodeType": "ExpressionStatement", + "src": "927:33:1" + }, + { + "body": { + "id": 229, + "nodeType": "Block", + "src": "992:36:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 226, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 184, + "src": "1016:6:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 222, + "name": "_addrs", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 182, + "src": "997:6:1", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", + "typeString": "address[] memory" + } + }, + "id": 224, + "indexExpression": { + "argumentTypes": null, + "id": 223, + "name": "i", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 213, + "src": "1004:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "997:9:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 225, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "997:18:1", + "typeDescriptions": { + "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 227, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "997:26:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 228, + "nodeType": "ExpressionStatement", + "src": "997:26:1" + } + ] + }, + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 218, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 216, + "name": "i", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 213, + "src": "981:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<", + "rightExpression": { + "argumentTypes": null, + "id": 217, + "name": "l", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 188, + "src": "985:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "981:5:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 230, + "initializationExpression": { + "assignments": [ + 213 + ], + "declarations": [ + { + "constant": false, + "id": 213, + "name": "i", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "969:6:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 212, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "969:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 215, + "initialValue": { + "argumentTypes": null, + "hexValue": "30", + "id": 214, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "978:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "nodeType": "VariableDeclarationStatement", + "src": "969:10:1" + }, + "loopExpression": { + "expression": { + "argumentTypes": null, + "id": 220, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "++", + "prefix": false, + "src": "988:3:1", + "subExpression": { + "argumentTypes": null, + "id": 219, + "name": "i", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 213, + "src": "988:1:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 221, + "nodeType": "ExpressionStatement", + "src": "988:3:1" + }, + "nodeType": "ForStatement", + "src": "964:64:1" + } + ] + }, + "documentation": null, + "id": 232, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "withdrawMulti", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 185, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 182, + "name": "_addrs", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "813:16:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", + "typeString": "address[]" + }, + "typeName": { + "baseType": { + "id": 180, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "813:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 181, + "length": null, + "nodeType": "ArrayTypeName", + "src": "813:9:1", + "typeDescriptions": { + "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", + "typeString": "address[]" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 184, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 232, + "src": "831:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 183, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "831:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "812:31:1" + }, + "payable": false, + "returnParameters": { + "id": 186, + "nodeType": "ParameterList", + "parameters": [], + "src": "851:0:1" + }, + "scope": 233, + "src": "790:241:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 234, + "src": "54:979:1" + } + ], + "src": "0:1033:1" + }, + "compiler": { + "name": "solc", + "version": "0.4.24+commit.e67f0147.Emscripten.clang" + }, + "networks": { + "1": { + "events": {}, + "links": {}, + "address": "0x9c2b479e15bbd956237c7ef33d31bfa2a576f007", + "transactionHash": "0x3213d366cc00423edfdf5683a4d26b3e93467c88cbd5f953864ec46edb7673d9" + }, + "1528420224459": { + "events": {}, + "links": {}, + "address": "0xebfa192f69d390707f8908e10ed274d6e38dc04f", + "transactionHash": "0x86a60b4cd8a9abab600debe01793dd76d05b65e4aa37c144e51c7f42a9d4d93b" + } + }, + "schemaVersion": "2.0.0", + "updatedAt": "2018-06-08T15:58:27.902Z" +} \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json new file mode 100755 index 0000000000..765962721b --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json @@ -0,0 +1,423 @@ +{ + "contractName": "Transfers2", + "abi": [ + { + "constant": false, + "inputs": [ + { + "name": "_addr", + "type": "address" + } + ], + "name": "transfer", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5060ed8061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a72305820e95f74106a3328ffadd8b0adb916d92497daab65998ee73cf40afff57dc4b29b0029", + "deployedBytecode": "0x608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a72305820e95f74106a3328ffadd8b0adb916d92497daab65998ee73cf40afff57dc4b29b0029", + "sourceMap": "26:106:2:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;26:106:2;;;;;;;", + "deployedSourceMap": "26:106:2:-;;;;;;;;;;;;;;;;;;;;;;;;49:81;;;;;;;;;;;;;;;;;;;;;;;;;;;;;101:5;:14;;:25;116:9;101:25;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;101:25:2;49:81;:::o", + "source": "pragma solidity ^0.4.19;\n\ncontract Transfers2 {\n\tfunction transfer(address _addr) public payable {\n\t\t_addr.transfer(msg.value);\n\t}\n}", + "sourcePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "ast": { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "exportedSymbols": { + "Transfers2": [ + 249 + ] + }, + "id": 250, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 235, + "literals": [ + "solidity", + "^", + "0.4", + ".19" + ], + "nodeType": "PragmaDirective", + "src": "0:24:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 249, + "linearizedBaseContracts": [ + 249 + ], + "name": "Transfers2", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 247, + "nodeType": "Block", + "src": "97:33:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 243, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "116:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 244, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "116:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 240, + "name": "_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 237, + "src": "101:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 242, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "101:14:2", + "typeDescriptions": { + "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 245, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "101:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 246, + "nodeType": "ExpressionStatement", + "src": "101:25:2" + } + ] + }, + "documentation": null, + "id": 248, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "transfer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 238, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 237, + "name": "_addr", + "nodeType": "VariableDeclaration", + "scope": 248, + "src": "67:13:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 236, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "67:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "66:15:2" + }, + "payable": true, + "returnParameters": { + "id": 239, + "nodeType": "ParameterList", + "parameters": [], + "src": "97:0:2" + }, + "scope": 249, + "src": "49:81:2", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 250, + "src": "26:106:2" + } + ], + "src": "0:132:2" + }, + "legacyAST": { + "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "exportedSymbols": { + "Transfers2": [ + 249 + ] + }, + "id": 250, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 235, + "literals": [ + "solidity", + "^", + "0.4", + ".19" + ], + "nodeType": "PragmaDirective", + "src": "0:24:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 249, + "linearizedBaseContracts": [ + 249 + ], + "name": "Transfers2", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 247, + "nodeType": "Block", + "src": "97:33:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 243, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 264, + "src": "116:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 244, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "116:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 240, + "name": "_addr", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 237, + "src": "101:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 242, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "101:14:2", + "typeDescriptions": { + "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 245, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "101:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 246, + "nodeType": "ExpressionStatement", + "src": "101:25:2" + } + ] + }, + "documentation": null, + "id": 248, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "transfer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 238, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 237, + "name": "_addr", + "nodeType": "VariableDeclaration", + "scope": 248, + "src": "67:13:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 236, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "67:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "66:15:2" + }, + "payable": true, + "returnParameters": { + "id": 239, + "nodeType": "ParameterList", + "parameters": [], + "src": "97:0:2" + }, + "scope": 249, + "src": "49:81:2", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 250, + "src": "26:106:2" + } + ], + "src": "0:132:2" + }, + "compiler": { + "name": "solc", + "version": "0.4.24+commit.e67f0147.Emscripten.clang" + }, + "networks": { + "1": { + "events": {}, + "links": {}, + "address": "0xa863f8203ad95e9078f6300e7857a4cca4fb4c60", + "transactionHash": "0xb836110657221cb8ac728c0345ae03da1cb4313cfa0bb61285f31b780907af50" + }, + "1528420224459": { + "events": {}, + "links": {}, + "address": "0x411410538c50b116663acd654e34dc6bed601cf0", + "transactionHash": "0x43f3fed1df72adfe12dd0c2432f0625b4b50b0c151f9583a166722ed74786ce3" + } + }, + "schemaVersion": "2.0.0", + "updatedAt": "2018-06-08T15:58:27.899Z" +} \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol b/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol new file mode 100755 index 0000000000..c4efb65e21 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol @@ -0,0 +1,23 @@ +pragma solidity ^0.4.23; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } + + function upgrade(address new_address) public restricted { + Migrations upgraded = Migrations(new_address); + upgraded.setCompleted(last_completed_migration); + } +} diff --git a/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol b/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol new file mode 100755 index 0000000000..9e7fbeef05 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol @@ -0,0 +1,44 @@ +pragma solidity ^0.4.19; + +import "./Transfers2.sol"; + +contract Transfers { + mapping (address => uint) public balance; + Transfers2 t; + address t_addr; + + constructor() public { + t = new Transfers2(); + t_addr = address(t); + } + + function transfer(address _addr, uint _value) public { + require(balance[msg.sender] >= _value); + bytes4 sig = bytes4(keccak256("transfer(address)")); + t_addr.call.value(_value)(sig, _addr); + } + + function myBalance() public returns (uint) { + return balance[msg.sender]; + } + + function deposit() public payable returns (uint) { + balance[msg.sender] += msg.value; + return balance[msg.sender]; + } + + function withdraw(address _addr, uint _value) public { + require(balance[msg.sender] >= _value); + balance[msg.sender] -= _value; + _addr.transfer(_value); + } + + function withdrawMulti(address[] _addrs, uint _value) public { + uint l = _addrs.length; + require(balance[msg.sender] >= _value * l); + balance[msg.sender] -= _value * l; + for (uint i = 0; i < l; i++){ + _addrs[i].transfer(_value); + } + } +} \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol b/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol new file mode 100755 index 0000000000..2e6c7c2e75 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol @@ -0,0 +1,7 @@ +pragma solidity ^0.4.19; + +contract Transfers2 { + function transfer(address _addr) public payable { + _addr.transfer(msg.value); + } +} \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/migrations/1_initial_migration.js b/shyft-cli/web3/transfer-through-master/migrations/1_initial_migration.js new file mode 100755 index 0000000000..4d5f3f9b02 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +var Migrations = artifacts.require("./Migrations.sol"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/shyft-cli/web3/transfer-through-master/migrations/2_migrate.js b/shyft-cli/web3/transfer-through-master/migrations/2_migrate.js new file mode 100755 index 0000000000..b1067351fd --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/migrations/2_migrate.js @@ -0,0 +1,7 @@ +var Transfers = artifacts.require('./Transfers.sol') +var Transfers2 = artifacts.require('./Transfers2.sol') + +module.exports = function (deployer) { + deployer.deploy(Transfers) + deployer.deploy(Transfers2) +} diff --git a/shyft-cli/web3/transfer-through-master/package-lock.json b/shyft-cli/web3/transfer-through-master/package-lock.json new file mode 100755 index 0000000000..326563a8c6 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "transfers", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/shyft-cli/web3/transfer-through-master/package.json b/shyft-cli/web3/transfer-through-master/package.json new file mode 100755 index 0000000000..df745f4570 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/package.json @@ -0,0 +1,15 @@ +{ + "name": "transfers", + "version": "1.0.0", + "description": "", + "main": "truffle-config.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/shyft-cli/web3/transfer-through-master/test/test.js b/shyft-cli/web3/transfer-through-master/test/test.js new file mode 100755 index 0000000000..6153da25c4 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/test/test.js @@ -0,0 +1,41 @@ +var Transfers = artifacts.require("Transfers"); +var Transfers2 = artifacts.require("Transfers2"); + +contract('Transfers', function(accounts) { + var addressA = web3.eth.accounts[0]; + var addressB = web3.eth.accounts[1]; + var transfers; + web3.eth.defaultAccount = web3.eth.accounts[0]; + + it("should initialize", async() => { + transfers = await Transfers.new(); + transfers2 = await Transfers2.new(); + assert(transfers !== undefined, ""); + assert(transfers2 !== undefined, ""); + }) + + it("should deposit", async() => { + let hash = await transfers.deposit({from: addressA, value: web3.toWei(4, "ether")}); + let bal = await transfers.deposit.call({from: addressA}); + console.log("\t\t[DEPOSIT TX]", hash.tx) + //console.log(bal); + }) + + it("should withdraw", async() => { + let prevB = await web3.eth.getBalance(addressB); + let hash = await transfers.withdraw(addressB, web3.toWei(1, "ether"), {from: addressA}); + let postB = await web3.eth.getBalance(addressB); + console.log("\t\t[WITHDRAW TX]", hash.tx) + //assert(postB - prevB == val, ""); + }) + + it("should transfer through other contract", async() => { + let val = 10; + let prevB = await web3.eth.getBalance(addressB); + + let hash = await transfers.transfer(addressB, web3.toWei(1, "ether"), {from: addressA}); + let postB = await web3.eth.getBalance(addressB); + console.log("\t\t[TRANSFER THROUGH TX]", hash.tx) + // assert(web3.fromWei(prevB,'wei') - web3.fromWei(postB,'wei') == val, ""); + }) +}) \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/truffle-config.js b/shyft-cli/web3/transfer-through-master/truffle-config.js new file mode 100755 index 0000000000..99b7dcd694 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/truffle-config.js @@ -0,0 +1,12 @@ +module.exports = { + // See + // to customize your Truffle configuration! + + networks: { + geth_testnet: { + host: "127.0.0.1", + port: 8545, + netword_id: "*" + } + } +}; diff --git a/shyft-cli/web3/transfer-through-master/truffle.js b/shyft-cli/web3/transfer-through-master/truffle.js new file mode 100755 index 0000000000..5b5f1104f8 --- /dev/null +++ b/shyft-cli/web3/transfer-through-master/truffle.js @@ -0,0 +1,10 @@ +module.exports = { + networks: { + development: { + host: 'localhost', + port: 8545, + network_id: '*', + //gasLimit: 6.7e6 + } + } +}; diff --git a/shyft-geth.sh b/shyft-geth.sh new file mode 100755 index 0000000000..b64fb5ec98 --- /dev/null +++ b/shyft-geth.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +if [[ $# -lt 1 ]]; then + echo + echo Shyft-Geth: No flags detected, see help: + echo + echo " --setup: Setups postgres and the shyft chain db." + echo " --start: Starts geth." + echo " --reset: Drops postgress and chain db, and reinstantiates both." + echo " --js [filename]: Executes web3 calls with a passed file name. If the file name is sendTransactions.js, $ ./shyft-geth.sh --js sendTransactions" + echo + exit 1 +fi + +illegalCommands=() +while [[ $# -gt 0 ]] +do +key="$1" +case $key in + --setup) + sh ./shyft-cli/setup.sh + shift # past argument + ;; + --start) + sh ./shyft-cli/startShyftGeth.sh + shift # past argument + ;; + --js) + sh ./shyft-cli/runJs.sh ./shyft-cli/web3/$2.js + shift # past argument + shift # past argument + ;; + --reset) + sh ./shyft-cli/shyftFullReset.sh + shift # past argument + ;; + *) # unknown option + illegalCommands+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done + +if [[ "${#illegalCommands[@]}" -gt "0" ]]; then + echo Shyft-Geth: The following commands are not supported: "${illegalCommands[*]}" +fi + diff --git a/shyftBlockExplorerApi/app.go b/shyftBlockExplorerApi/app.go new file mode 100644 index 0000000000..56f8b027d2 --- /dev/null +++ b/shyftBlockExplorerApi/app.go @@ -0,0 +1,18 @@ +package main + +//@NOTE SHYFT main func for api, sets up router and spins up a server +//to run server 'go run shyftBlockExplorerApi/*.go' +import ( + "log" + "net/http" + + "github.com/gorilla/handlers" +) + +func main() { + + router := NewRouter() + port := "8080" + log.Printf("Listening on port " + " " + port) + log.Fatal(http.ListenAndServe(":"+port, handlers.CORS(handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS"}), handlers.AllowedOrigins([]string{"*"}))(router))) +} diff --git a/blockExplorerApi/handler.go b/shyftBlockExplorerApi/handler.go similarity index 80% rename from blockExplorerApi/handler.go rename to shyftBlockExplorerApi/handler.go index b84d5d3537..496941db7b 100644 --- a/blockExplorerApi/handler.go +++ b/shyftBlockExplorerApi/handler.go @@ -10,6 +10,9 @@ import ( "github.com/ethereum/go-ethereum/shyftdb" "github.com/gorilla/mux" + "bytes" + "io/ioutil" + "encoding/json" ) // GetTransaction gets txs @@ -244,3 +247,39 @@ func GetInternalTransactionsHash(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Get Internal Transaction Hash", transactionHash) } + +func BroadcastTx(w http.ResponseWriter, r *http.Request) { + // Example return result (returns tx hash): + // {"jsonrpc":"2.0","id":1,"result":"0xafa4c62f29dbf16bbfac4eea7cbd001a9aa95c59974043a17f863172f8208029"} + + // http params + vars := mux.Vars(r) + transactionHash := vars["transaction_hash"] + + // format the transactionHash into a proper sendRawTransaction jsonrpc request + formatted_json := []byte(fmt.Sprintf(`{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["%s"],"id":0}`, transactionHash)) + + // send json rpc request + resp, _ := http.Post("http://localhost:8545", "application/json", bytes.NewBuffer(formatted_json)) + body, _ := ioutil.ReadAll(resp.Body) + byt := []byte(string(body)) + + // read json and return result as http response, be it an error or tx hash + var dat map[string]interface{} + if err := json.Unmarshal(byt, &dat); err != nil { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, "ERROR parsing json") + } + tx_hash := dat["result"] + if(tx_hash == nil) { + errMap := dat["error"].(map[string]interface{}) + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, "ERROR:", errMap["message"]) + } else { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, "Transaction Hash:", tx_hash) + } +} \ No newline at end of file diff --git a/blockExplorerApi/logger.go b/shyftBlockExplorerApi/logger.go similarity index 100% rename from blockExplorerApi/logger.go rename to shyftBlockExplorerApi/logger.go diff --git a/blockExplorerApi/router.go b/shyftBlockExplorerApi/router.go similarity index 100% rename from blockExplorerApi/router.go rename to shyftBlockExplorerApi/router.go diff --git a/blockExplorerApi/routes.go b/shyftBlockExplorerApi/routes.go similarity index 94% rename from blockExplorerApi/routes.go rename to shyftBlockExplorerApi/routes.go index 4ce0dc80c8..fd6517eb5e 100644 --- a/blockExplorerApi/routes.go +++ b/shyftBlockExplorerApi/routes.go @@ -87,4 +87,10 @@ var routes = Routes{ "/api/get_internal_transactions_hash/{transactions_hash}", GetInternalTransactionsHash, }, + Route{ + "BroadcastTx", + "GET", + "/api/broadcast_tx/{transaction_hash}", + BroadcastTx, + }, } diff --git a/shyftDb/db.go b/shyftDb/db.go new file mode 100644 index 0000000000..f95871fd28 --- /dev/null +++ b/shyftDb/db.go @@ -0,0 +1,37 @@ +package shyftdb + +import ( + "fmt" + "database/sql" + "os" +) + +var blockExplorerDb *sql.DB + +func InitDB() (*sql.DB, error){ + var connStr string + if "test" == os.Getenv("SHYFT_ENV") { + connStr = "user=postgres dbname=shyftdbtest sslmode=disable" + } else { + connStr = "user=postgres dbname=shyftdb sslmode=disable" + } + db, err := sql.Open("postgres", connStr) + if err != nil { + fmt.Println("ERROR OPENING DB, NOT INITIALIZING") + fmt.Println(err) + return nil, err + } else { + blockExplorerDb = db + return blockExplorerDb, nil + } +} + +func DBConnection() (*sql.DB, error) { + if (blockExplorerDb == nil) { + _, err := InitDB() + if(err != nil) { + return nil, err + } + } + return blockExplorerDb, nil +} \ No newline at end of file diff --git a/shyftDb/postgres_setup/initdb.sh b/shyftDb/postgres_setup/initdb.sh deleted file mode 100644 index 1fb7d829c5..0000000000 --- a/shyftDb/postgres_setup/initdb.sh +++ /dev/null @@ -1 +0,0 @@ -psql -U postgres -f create_shyftdb.psql diff --git a/shyftDb/postgres_setup_test/create_shyftdb_test.psql b/shyftDb/postgres_setup_test/create_shyftdb_test.psql new file mode 100644 index 0000000000..96a3d28af5 --- /dev/null +++ b/shyftDb/postgres_setup_test/create_shyftdb_test.psql @@ -0,0 +1 @@ +CREATE DATABASE shyftdbTest diff --git a/shyftDb/postgres_setup_test/create_tables_test.psql b/shyftDb/postgres_setup_test/create_tables_test.psql new file mode 100644 index 0000000000..2cd9bc5176 --- /dev/null +++ b/shyftDb/postgres_setup_test/create_tables_test.psql @@ -0,0 +1,40 @@ +CREATE TABLE IF NOT EXISTS blocks ( + hash text primary key, + coinbase text, + gasUsed numeric, + gasLimit numeric, + txCount numeric, + uncleCount numeric, + age timestamp, + parentHash text, + uncleHash text, + difficulty bigint, + size text, + nonce numeric, + rewards numeric, + number bigint +); + +CREATE TABLE IF NOT EXISTS txs ( + txHash text, + to_addr text, + from_addr text, + blockhash text references blocks(hash), + blocknumber text, + amount numeric, + gasprice numeric, + gas numeric, + gasLimit numeric, + txFee numeric, + nonce numeric, + txStatus text, + isContract bool, + age timestamp, + data bytea +); + +CREATE TABLE IF NOT EXISTS accounts ( + addr text primary key unique, + balance numeric, + txCountAccount numeric +); \ No newline at end of file diff --git a/shyftDb/postgres_setup_test/drop_tables_test.psql b/shyftDb/postgres_setup_test/drop_tables_test.psql new file mode 100644 index 0000000000..80625a022b --- /dev/null +++ b/shyftDb/postgres_setup_test/drop_tables_test.psql @@ -0,0 +1,3 @@ +DROP TABLE txs; +DROP TABLE blocks; +DROP TABLE accounts; \ No newline at end of file diff --git a/shyftDb/postgres_setup_test/drop_tables_test.sh b/shyftDb/postgres_setup_test/drop_tables_test.sh new file mode 100644 index 0000000000..c46031aee9 --- /dev/null +++ b/shyftDb/postgres_setup_test/drop_tables_test.sh @@ -0,0 +1 @@ +psql -U postgres -d shyftdbtest -f drop_tables_test.psql \ No newline at end of file diff --git a/shyftDb/postgres_setup_test/initTestdb.sh b/shyftDb/postgres_setup_test/initTestdb.sh new file mode 100644 index 0000000000..f41fc809c6 --- /dev/null +++ b/shyftDb/postgres_setup_test/initTestdb.sh @@ -0,0 +1 @@ +psql -U postgres -f create_shyftdb_test.psql \ No newline at end of file diff --git a/shyftDb/postgres_setup_test/init_tables_test.sh b/shyftDb/postgres_setup_test/init_tables_test.sh new file mode 100644 index 0000000000..aad56f6307 --- /dev/null +++ b/shyftDb/postgres_setup_test/init_tables_test.sh @@ -0,0 +1 @@ +psql -U postgres -d shyftdbtest -f create_tables_test.psql \ No newline at end of file diff --git a/shyftDb/postgres_test.go b/shyftDb/postgres_test.go new file mode 100644 index 0000000000..7a652301a5 --- /dev/null +++ b/shyftDb/postgres_test.go @@ -0,0 +1,42 @@ +package shyftdb + +import ( + "database/sql" + "fmt" +) + +func InitTestDB() *sql.DB { + connStr := "user=postgres dbname=shyftdbtest sslmode=disable" + blockExplorerDbTest, err := sql.Open("postgres", connStr) + if err != nil { + fmt.Println(err) + } + + return blockExplorerDbTest +} + +func ClearTables() { + connStr := "user=postgres dbname=shyftdbtest sslmode=disable" + blockExplorerDbTest, err := sql.Open("postgres", connStr) + if err != nil { + fmt.Println(err) + } + + sqlStatementTx:= `DELETE FROM txs` + _, err = blockExplorerDbTest.Exec(sqlStatementTx) + if err != nil { + panic(err) + } + + sqlStatementAcc:= `DELETE FROM accounts` + _, err = blockExplorerDbTest.Exec(sqlStatementAcc) + if err != nil { + panic(err) + } + + sqlStatement := `DELETE FROM blocks` + _, err = blockExplorerDbTest.Exec(sqlStatement) + if err != nil { + panic(err) + } +} \ No newline at end of file diff --git a/shyftDb/shyft_database_util.go b/shyftDb/shyft_database_util.go index ad37752fc2..658abe6e07 100644 --- a/shyftDb/shyft_database_util.go +++ b/shyftDb/shyft_database_util.go @@ -20,16 +20,16 @@ type SBlock struct { Hash string Coinbase string Number string - GasUsed string - GasLimit string - TxCount string - UncleCount string + GasUsed uint64 + GasLimit uint64 + TxCount int + UncleCount int Age string ParentHash string UncleHash string Difficulty string Size string - Nonce string + Nonce uint64 Rewards string } @@ -80,7 +80,7 @@ type ShyftTxEntryPretty struct { Amount string GasPrice uint64 Gas uint64 - GasLimit string + GasLimit uint64 Cost uint64 Nonce uint64 Status string @@ -104,8 +104,14 @@ type SendAndReceive struct { } //WriteBlock writes to block info to sql db -func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error { - rewards := WriteMinerRewards(sqldb,block) +func WriteBlock(block *types.Block, receipts []*types.Receipt) error { + + sqldb, err := DBConnection() + if (err != nil) { + panic(err) + } + + rewards := writeMinerRewards(sqldb,block) coinbase := block.Header().Coinbase.String() number := block.Header().Number.String() gasUsed := block.Header().GasUsed @@ -132,21 +138,20 @@ func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) er if block.Transactions().Len() > 0 { for _, tx := range block.Transactions() { - WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) + writeTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) if block.Transactions()[0].To() != nil { - WriteFromBalance(sqldb, tx) + writeFromBalance(sqldb, tx) } if block.Transactions()[0].To() == nil { - WriteContractBalance(sqldb, tx) - WriteContractsTxHashReferences(sqldb, tx) + writeContractBalance(sqldb, tx) } } } return nil } -//WriteTransactions writes to sqldb -func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error { +//writeTransactions writes to sqldb +func writeTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error { txData := ShyftTxEntry{ TxHash: tx.Hash(), From: tx.From(), @@ -217,22 +222,15 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha return nil } -func WriteContractsTxHashReferences(sqldb *sql.DB, tx *types.Transaction) error { - txHash := tx.Hash().Hex() - - sqlStatement := `INSERT INTO contracts(txHash) VALUES(($1)) RETURNING txHash` - insertErr := sqldb.QueryRow(sqlStatement, txHash).Scan(&txHash) - if insertErr != nil { - panic(insertErr) +func writeContractBalance(sqldb *sql.DB, tx *types.Transaction) error { + sendAndReceiveData := SendAndReceive{ + From: tx.From().Hex(), + Amount: tx.Value().String(), } - return nil -} -func WriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error { - sendAndReceiveData,balanceSen,accountNonceSen := WriteContractBalanceHelper(sqldb, tx) fromAddr := sendAndReceiveData.From amount := sendAndReceiveData.Amount - balanceSender := balanceSen + accountNonceSen := tx.Nonce() var response string sqlExistsStatement := `SELECT balance from accounts WHERE addr = ($1)` @@ -244,9 +242,14 @@ func WriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error { if insertErr != nil { panic(insertErr) } - case err != nil: - log.Fatal(err) default: + getAccountBalanceSender:= GetAccount(sqldb, fromAddr) + var senderBalance SendAndReceive + if err := json.Unmarshal([]byte(getAccountBalanceSender), &senderBalance); err != nil { + log.Fatal(err) + } + + balanceSender := senderBalance.Balance var newBalanceSender big.Int var newAccountNonceSender big.Int var nonceIncrement = big.NewInt(1) @@ -258,16 +261,12 @@ func WriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error { log.Println("error scanning value:", error) } - accountS := new(big.Int) - _, errors := fmt.Sscan(accountNonceSen, accountS) - if errors != nil { - log.Println("error scanning value:", error) - } + senderAccountNonce := new(big.Int).SetUint64(accountNonceSen) newBalanceSender.Sub(s, tx.Value()) - newAccountNonceSender.Add(accountS, nonceIncrement) + newAccountNonceSender.Add(senderAccountNonce, nonceIncrement) - _, err = sqldb.Exec(updateSQLStatement, fromAddr, newBalanceSender.String(), newAccountNonceSender.String()) + _, err := sqldb.Exec(updateSQLStatement, fromAddr, newBalanceSender.String(), newAccountNonceSender.String()) if err != nil { panic(err) } @@ -275,28 +274,9 @@ func WriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error { return nil } -func WriteContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string) { - sendAndReceiveData := SendAndReceive{ - From: tx.From().Hex(), - Amount: tx.Value().String(), - } - - fromAddr := sendAndReceiveData.From - getAccountBalanceSender:= GetAccount(sqldb, fromAddr) - - var senderBalance SendAndReceive - if err := json.Unmarshal([]byte(getAccountBalanceSender), &senderBalance); err != nil { - log.Fatal(err) - } - balanceSender := senderBalance.Balance - accountNonceSender := senderBalance.TxCountAccount - - return sendAndReceiveData, balanceSender, accountNonceSender -} - -//WriteFromBalance writes senders balance to accounts db -func WriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error { - sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := WriteBalanceHelper(sqldb, tx) +//writeFromBalance writes senders balance to accounts db +func writeFromBalance(sqldb *sql.DB, tx *types.Transaction) error { + sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := writeBalanceHelper(sqldb, tx) toAddr := sendAndReceiveData.To fromAddr := sendAndReceiveData.From amount := sendAndReceiveData.Amount @@ -306,14 +286,12 @@ func WriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error { var response string sqlExistsStatement := `SELECT balance from accounts WHERE addr = ($1)` err := sqldb.QueryRow(sqlExistsStatement, toAddr).Scan(&response) + switch { case err == sql.ErrNoRows: - i, err := strconv.Atoi(accountNonceRec) - if err != nil { - fmt.Println(err) - } + txCountAccount := strconv.FormatUint(tx.Nonce(), 10) sqlStatement := `INSERT INTO accounts(addr, balance, txCountAccount) VALUES(($1), ($2), ($3)) RETURNING addr` - insertErr := sqldb.QueryRow(sqlStatement, toAddr, amount, i).Scan(&toAddr) + insertErr := sqldb.QueryRow(sqlStatement, toAddr, amount, txCountAccount).Scan(&toAddr) if insertErr != nil { panic(insertErr) } @@ -370,7 +348,7 @@ func WriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error { return nil } -func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string, string, string) { +func writeBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string, string, string) { sendAndReceiveData := SendAndReceive{ To: tx.To().Hex(), From: tx.From().Hex(), @@ -379,7 +357,6 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s toAddr := sendAndReceiveData.To fromAddr := sendAndReceiveData.From - getAccountBalanceReceiver := GetAccount(sqldb, toAddr) getAccountBalanceSender:= GetAccount(sqldb, fromAddr) @@ -395,7 +372,6 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s balanceReceiver := receiverBalance.Balance balanceSender := senderBalance.Balance - accountNonceReceiver := receiverBalance.TxCountAccount accountNonceSender := senderBalance.TxCountAccount @@ -406,7 +382,7 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s // uncle blocks, account balance updates based on reorgs, diverges that get dropped. // Reason for this is because the accounts are not deterministic like the block and tx hashes. // @TODO: Calculate reorg -func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string { +func writeMinerRewards(sqldb *sql.DB, block *types.Block) string { minerAddr := block.Coinbase().String() shyftConduitAddress := Rewards.ShyftNetworkConduitAddress.String() // Calculate the total gas used in the block @@ -436,13 +412,13 @@ func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string { uncleAddrs = append(uncleAddrs, uncle.Coinbase.String()) } - StoreReward(sqldb, minerAddr, totalMinerReward) - StoreReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward) + storeReward(sqldb, minerAddr, totalMinerReward) + storeReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward) var uncRewards = new(big.Int) for i := 0; i < len(uncleAddrs); i++ { uncRewards := uncleRewards[i] fmt.Println(uncRewards) - StoreReward(sqldb, uncleAddrs[i], uncleRewards[i]) + storeReward(sqldb, uncleAddrs[i], uncleRewards[i]) } fullRewardValue := new(big.Int) @@ -452,7 +428,7 @@ func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string { return fullRewardValue.String() } -func StoreReward(sqldb *sql.DB, address string, reward *big.Int) { +func storeReward(sqldb *sql.DB, address string, reward *big.Int) { // Check if address exists var addressBalance string addressExistsStatement := `SELECT balance from accounts WHERE addr = ($1)` @@ -497,6 +473,10 @@ func StoreReward(sqldb *sql.DB, address string, reward *big.Int) { // Getters ////////// //GetAllBlocks returns []SBlock blocks for API + +//Look into postgres functions array_to_json(array_agg(lap)) +//Example select array_to_json(array_agg(lap)) +//from ( select * from blocks)lap; func GetAllBlocks(sqldb *sql.DB) string { var arr blockRes var blockArr string @@ -510,16 +490,16 @@ func GetAllBlocks(sqldb *sql.DB) string { for rows.Next() { var hash string var coinbase string - var gasUsed string - var gasLimit string - var txCount string - var uncleCount string + var gasUsed uint64 + var gasLimit uint64 + var txCount int + var uncleCount int var age string var parentHash string var uncleHash string var difficulty string var size string - var nonce string + var nonce uint64 var rewards string var num string @@ -570,16 +550,16 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string { row := sqldb.QueryRow(sqlStatement, blockNumber) var hash string var coinbase string - var gasUsed string - var gasLimit string - var txCount string - var uncleCount string + var gasUsed uint64 + var gasLimit uint64 + var txCount int + var uncleCount int var age string var parentHash string var uncleHash string var difficulty string var size string - var nonce string + var nonce uint64 var rewards string var num string row.Scan( @@ -623,16 +603,16 @@ func GetRecentBlock(sqldb *sql.DB) string { row := sqldb.QueryRow(sqlStatement) var hash string var coinbase string - var gasUsed string - var gasLimit string - var txCount string - var uncleCount string + var gasUsed uint64 + var gasLimit uint64 + var txCount int + var uncleCount int var age string var parentHash string var uncleHash string var difficulty string var size string - var nonce string + var nonce uint64 var rewards string var num string row.Scan( @@ -689,7 +669,7 @@ func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string { var amount string var gasprice uint64 var gas uint64 - var gasLimit string + var gasLimit uint64 var txfee uint64 var nonce uint64 var status string @@ -752,16 +732,16 @@ func GetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string { for rows.Next() { var hash string var coinbase string - var gasUsed string - var gasLimit string - var txCount string - var uncleCount string + var gasUsed uint64 + var gasLimit uint64 + var txCount int + var uncleCount int var age string var parentHash string var uncleHash string var difficulty string var size string - var nonce string + var nonce uint64 var rewards string var num string @@ -824,7 +804,7 @@ func GetAllTransactions(sqldb *sql.DB) string { var amount string var gasprice uint64 var gas uint64 - var gasLimit string + var gasLimit uint64 var txfee uint64 var nonce uint64 var status string @@ -886,7 +866,7 @@ func GetTransaction(sqldb *sql.DB, txHash string) string { var amount string var gasprice uint64 var gas uint64 - var gasLimit string + var gasLimit uint64 var txfee uint64 var nonce uint64 var status string @@ -1011,7 +991,7 @@ func GetAccountTxs(sqldb *sql.DB, address string) string { var amount string var gasprice uint64 var gas uint64 - var gasLimit string + var gasLimit uint64 var txfee uint64 var nonce uint64 var status string diff --git a/shyftDb/shyft_database_util_test.go b/shyftDb/shyft_database_util_test.go new file mode 100644 index 0000000000..bce8ac5e03 --- /dev/null +++ b/shyftDb/shyft_database_util_test.go @@ -0,0 +1,451 @@ +package shyftdb + +import ( + "testing" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "math/big" + //"time" + "encoding/json" + "github.com/ethereum/go-ethereum/crypto" + "strconv" +) + +func TestBlockToReturnBlock(t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2, mytx3} + + receipt := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt} + block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) + + // Write and verify the block in the database + if err := WriteBlock(block, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + + sqldb, err := DBConnection() + if (err != nil) { + panic(err) + } + + entry := GetBlock(sqldb, block.Number().String()) + byt := []byte(entry) + var data SBlock + json.Unmarshal(byt, &data) + + //TODO Difficulty, rewards, age + if block.Hash().String() != data.Hash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Coinbase().String() != data.Coinbase { + t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) + } + if block.Number().String() != data.Number { + t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) + } + if block.GasUsed() != data.GasUsed { + t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) + } + if block.GasLimit() != data.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Transactions().Len() != data.TxCount { + t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) + } + if len(block.Uncles()) != data.UncleCount { + t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) + } + if block.ParentHash().String() != data.ParentHash { + t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) + } + if block.UncleHash().String() != data.UncleHash { + t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) + } + if block.Size().String() != data.Size { + t.Fatalf("Size [%v]: Size not found", block.Size().String()) + } + if block.Nonce() != data.Nonce { + t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) + } + + if getAllBlocks := GetAllBlocks(sqldb); len(getAllBlocks) == 0 { + t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks) + } + + if getAllBlocksMinedByAddress := GetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 { + t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress) + } + + ClearTables() +} + +func TestGetRecentBlock(t *testing.T) { + db := InitTestDB() + + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2} + txs1 := []*types.Transaction{mytx3} + + receipt1 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt1} + block := types.NewBlock(&types.Header{Number: big.NewInt(322)}, txs, nil, receipts) + block2 := types.NewBlock(&types.Header{Number: big.NewInt(320)}, txs1, nil, receipts) + blocks := []*types.Block{block, block2} + + for _, bc := range blocks { + // Write and verify the block in the database + if err := WriteBlock(bc, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + } + + response := GetRecentBlock(db) + byteRes := []byte(response) + var recentBlock SBlock + json.Unmarshal(byteRes, &recentBlock) + + if block.Hash().String() != recentBlock.Hash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Coinbase().String() != recentBlock.Coinbase { + t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) + } + if block.Number().String() != recentBlock.Number { + t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) + } + if block.GasUsed() != recentBlock.GasUsed { + t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) + } + if block.GasLimit() != recentBlock.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Transactions().Len() != recentBlock.TxCount { + t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) + } + if len(block.Uncles()) != recentBlock.UncleCount { + t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) + } + if block.ParentHash().String() != recentBlock.ParentHash { + t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) + } + if block.UncleHash().String() != recentBlock.UncleHash { + t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) + } + if block.Size().String() != recentBlock.Size { + t.Fatalf("Size [%v]: Size not found", block.Size().String()) + } + if block.Nonce() != recentBlock.Nonce { + t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) + } + + if allTxsFromBlock:= GetAllTransactionsFromBlock(db, block2.Number().String()); len(allTxsFromBlock) == 0 { + t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock) + } + ClearTables() +} + +func TestContractCreationTx(t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce,Value, GasLimit, Gasprice, data + contractCreation := types.NewContractCreation(1, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(contractCreation, signer, key) + txs := []*types.Transaction{mytx} + + receipt2 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt2} + block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) + + if err := WriteBlock(block, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + + var contractAddressFromReciept string + for _, receipt := range receipts { + contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String() + } + + sqldb, err := DBConnection() + if (err != nil) { + panic(err) + } + + for _, tx := range txs { + txn := GetTransaction(sqldb, tx.Hash().String()) + byt := []byte(txn) + var data ShyftTxEntryPretty + json.Unmarshal(byt, &data) + + if tx.Hash().String() != data.TxHash { + t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) + } + if contractAddressFromReciept != data.To { + t.Fatalf("Contract Addr [%v]: Contract addr not found", contractAddressFromReciept) + } + if tx.From().String() != data.From { + t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) + } + if tx.Nonce() != data.Nonce { + t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) + } + if tx.Gas() != data.Gas { + t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) + } + if tx.GasPrice().Uint64() != data.GasPrice { + t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) + } + if block.GasLimit() != data.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Hash().String() != data.BlockHash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Number().String() != data.BlockNumber { + t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) + } + if tx.Value().String() != data.Amount { + t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) + } + if tx.Cost().Uint64() != data.Cost { + t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) + } + var status string + if receipt2.Status == 1 { + status = "SUCCESS" + } + if receipt2.Status == 0 { + status = "FAIL" + } + if status != data.Status { + t.Fatalf("Receipt status [%v]: Receipt status not found", status) + } + var isContract bool + if tx.To() != nil { + isContract = false + } else { + isContract = true + } + if isContract != data.IsContract { + t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) + } + } + ClearTables() +} + +func TestTransactionsToReturnTransactions(t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2, mytx3} + + receipt1 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt1} + block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) + + if err := WriteBlock(block, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + sqldb, err := DBConnection() + if (err != nil) { + panic(err) + } + + for _, tx := range txs { + txn := GetTransaction(sqldb, tx.Hash().String()) + byt := []byte(txn) + var data ShyftTxEntryPretty + json.Unmarshal(byt, &data) + + //TODO age, data + if tx.Hash().String() != data.TxHash { + t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) + } + if tx.From().String() != data.From { + t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) + } + if tx.To().String() != data.To { + t.Fatalf("To Addr [%v]: To addr not found", tx.To().String()) + } + if tx.Nonce() != data.Nonce { + t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) + } + if tx.Gas() != data.Gas { + t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) + } + if tx.GasPrice().Uint64() != data.GasPrice { + t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) + } + if block.GasLimit() != data.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Hash().String() != data.BlockHash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Number().String() != data.BlockNumber { + t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) + } + if tx.Value().String() != data.Amount { + t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) + } + if tx.Cost().Uint64() != data.Cost { + t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) + } + var status string + if receipt1.Status == 1 { + status = "SUCCESS" + } + if receipt1.Status == 0 { + status = "FAIL" + } + if status != data.Status { + t.Fatalf("Receipt status [%v]: Receipt status not found", status) + } + var isContract bool + if tx.To() != nil { + isContract = false + } else { + isContract = true + } + if isContract != data.IsContract { + t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) + } + } + + if getAllTx := GetAllTransactions(sqldb); len(getAllTx) == 0 { + t.Fatalf("GetAllTransactions [%v]: GetAllTransactions did not return correctly", getAllTx) + } + ClearTables() +} + +func TestAccountsToReturnAccounts(t *testing.T) { + db := InitTestDB() + + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2, mytx3} + + receipt1 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt1} + block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) + if err := WriteBlock(block, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + + for _, tx := range txs { + accountAddrTo := GetAccount(db, tx.To().String()) + byts := []byte(accountAddrTo) + var accountDataTo SAccounts + json.Unmarshal(byts, &accountDataTo) + + if tx.To().String() != accountDataTo.Addr { + t.Fatalf("To address [%v]: To address not found", accountDataTo.Addr) + } + if tx.Value().String() != accountDataTo.Balance { + t.Fatalf("To address balance [%v]: To address balance not found", accountDataTo.Balance) + } + if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.TxCountAccount { + t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.TxCountAccount) + } + if getAllAccountTxs := GetAccountTxs(db, tx.To().String()); len(getAllAccountTxs) == 0 { + t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs) + } + } + + if getAllAccounts := GetAllAccounts(db); len(getAllAccounts) == 0 { + t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts) + } + ClearTables() +} + + + diff --git a/shyftFullReset.sh b/shyftFullReset.sh deleted file mode 100644 index 6fbcbc1683..0000000000 --- a/shyftFullReset.sh +++ /dev/null @@ -1,5 +0,0 @@ -cd ./shyftDb/postgres_setup -sh drop_tables.sh && sh init_tables.sh -cd .. -cd .. -sh resetShyftGeth.sh && sh initShyftGeth.sh \ No newline at end of file diff --git a/simulations/deployContract.js b/simulations/deployContract.js deleted file mode 100644 index 109a58febf..0000000000 --- a/simulations/deployContract.js +++ /dev/null @@ -1,27 +0,0 @@ -// using contract from https://www.ethereum.org/greeter -// compiled on remix - -var _greeting = "Greeter Contract" ; -var greeterContract = web3.eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]); -var greeter = greeterContract.new( - _greeting, - { - from: web3.eth.accounts[0], - data: '0x6060604052341561000f57600080fd5b6040516103a93803806103a983398101604052808051820191905050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060019080519060200190610081929190610088565b505061012d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100c957805160ff19168380011785556100f7565b828001600101855582156100f7579182015b828111156100f65782518255916020019190600101906100db565b5b5090506101049190610108565b5090565b61012a91905b8082111561012657600081600090555060010161010e565b5090565b90565b61026d8061013c6000396000f30060606040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610066575b600080fd5b341561005c57600080fd5b6100646100f4565b005b341561007157600080fd5b610079610185565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b957808201518184015260208101905061009e565b50505050905090810190601f1680156100e65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610183576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b565b61018d61022d565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102235780601f106101f857610100808354040283529160200191610223565b820191906000526020600020905b81548152906001019060200180831161020657829003601f168201915b5050505050905090565b6020604051908101604052806000815250905600a165627a7a7230582015882dcaabcda0ebdb1b26a10e36f26a424e148671f4703dde3c1956ebaa67830029', - gas: '4700000' - }, function (e, contract){ - if(!e) { - // NOTE: The callback will fire twice! - // Once the contract has the transactionHash property set and once its deployed on an address. - // e.g. check tx hash on the first call (transaction send) - if(!contract.address) { - console.log("TX hash:") - console.log(contract.transactionHash) // The hash of the transaction, which deploys the contract - - } else { - console.log("Contract address:") - console.log(contract.address) // the contract address - } - - } - }) diff --git a/simulations/token_test/README.md b/simulations/token_test/README.md deleted file mode 100644 index 1160be7a88..0000000000 --- a/simulations/token_test/README.md +++ /dev/null @@ -1,9 +0,0 @@ -`npm install` -run `node deploy.js` to deploy the contract. - -this will log out a contract in the geth logs. - -set the ADDR environment variable to this contract address. -ie `export ADDR=` - -then run `node calltx.js` From 41494cbd0f2181db8d37f172fc49e251e305e972 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 13 Jun 2018 14:00:09 -0400 Subject: [PATCH 2/3] quick fix --- shyftDb/shyft_database_util_test.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/shyftDb/shyft_database_util_test.go b/shyftDb/shyft_database_util_test.go index bce8ac5e03..5e76048fc1 100644 --- a/shyftDb/shyft_database_util_test.go +++ b/shyftDb/shyft_database_util_test.go @@ -101,8 +101,6 @@ func TestBlockToReturnBlock(t *testing.T) { } func TestGetRecentBlock(t *testing.T) { - db := InitTestDB() - key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") signer := types.NewEIP155Signer(big.NewInt(2147483647)) @@ -140,7 +138,12 @@ func TestGetRecentBlock(t *testing.T) { } } - response := GetRecentBlock(db) + sqldb, err := DBConnection() + if (err != nil) { + panic(err) + } + + response := GetRecentBlock(sqldb) byteRes := []byte(response) var recentBlock SBlock json.Unmarshal(byteRes, &recentBlock) @@ -179,7 +182,7 @@ func TestGetRecentBlock(t *testing.T) { t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) } - if allTxsFromBlock:= GetAllTransactionsFromBlock(db, block2.Number().String()); len(allTxsFromBlock) == 0 { + if allTxsFromBlock:= GetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 { t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock) } ClearTables() @@ -389,8 +392,6 @@ func TestTransactionsToReturnTransactions(t *testing.T) { } func TestAccountsToReturnAccounts(t *testing.T) { - db := InitTestDB() - key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") signer := types.NewEIP155Signer(big.NewInt(2147483647)) @@ -421,8 +422,14 @@ func TestAccountsToReturnAccounts(t *testing.T) { t.Fatalf("Failed to write block into database: %v", err) } + sqldb, err := DBConnection() + if (err != nil) { + panic(err) + } + + for _, tx := range txs { - accountAddrTo := GetAccount(db, tx.To().String()) + accountAddrTo := GetAccount(sqldb, tx.To().String()) byts := []byte(accountAddrTo) var accountDataTo SAccounts json.Unmarshal(byts, &accountDataTo) @@ -436,12 +443,12 @@ func TestAccountsToReturnAccounts(t *testing.T) { if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.TxCountAccount { t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.TxCountAccount) } - if getAllAccountTxs := GetAccountTxs(db, tx.To().String()); len(getAllAccountTxs) == 0 { + if getAllAccountTxs := GetAccountTxs(sqldb, tx.To().String()); len(getAllAccountTxs) == 0 { t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs) } } - if getAllAccounts := GetAllAccounts(db); len(getAllAccounts) == 0 { + if getAllAccounts := GetAllAccounts(sqldb); len(getAllAccounts) == 0 { t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts) } ClearTables() From dfe2907f440f02895b014e7405d8406621f8816b Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 14 Jun 2018 14:27:05 -0400 Subject: [PATCH 3/3] changes made from PR comments --- shyft-cli/postgres_setup/create_tables.psql | 2 +- shyft-cli/postgres_setup/drop_tables.psql | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/shyft-cli/postgres_setup/create_tables.psql b/shyft-cli/postgres_setup/create_tables.psql index 0ca10a1426..b746384bdc 100644 --- a/shyft-cli/postgres_setup/create_tables.psql +++ b/shyft-cli/postgres_setup/create_tables.psql @@ -38,4 +38,4 @@ CREATE TABLE IF NOT EXISTS accounts ( balance numeric, txCountAccount numeric ); -shyft-cli/postgres_setup/create_tables.psql + diff --git a/shyft-cli/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql index 48a3ad9844..41563522dd 100644 --- a/shyft-cli/postgres_setup/drop_tables.psql +++ b/shyft-cli/postgres_setup/drop_tables.psql @@ -1,4 +1,3 @@ DROP TABLE txs; DROP TABLE blocks; DROP TABLE accounts; -shyft-cli/postgres_setup/drop_tables.psql