web3 0.9.1.0 → 1.0.0.0
raw patch · 146 files changed
+231/−20890 lines, 146 filesdep +web3-ethereumdep +web3-polkadotdep +web3-providerdep −OneTupledep −aesondep −asyncdep ~base
Dependencies added: web3-ethereum, web3-polkadot, web3-provider
Dependencies removed: OneTuple, aeson, async, attoparsec, base58string, basement, bitvec, bytestring, cereal, containers, cryptonite, data-default, errors, exceptions, generics-sop, hspec, hspec-contrib, hspec-discover, hspec-expectations, http-client, http-client-tls, http-media, http-types, machines, memory, microlens, microlens-aeson, microlens-mtl, microlens-th, mtl, network, parsec, random, relapse, servant, servant-client, split, stm, tagged, tar, template-haskell, text, time, transformers, unordered-containers, uuid-types, vector, vinyl, websockets
Dependency ranges changed: base
Files
- CHANGELOG.md +0/−149
- LICENSE +205/−24
- README.md +0/−81
- compiler/Language/Solidity/Compiler.hs +0/−58
- compiler/Language/Solidity/Compiler/Foreign.hsc +0/−106
- compiler/cbits/solidity_lite.cpp +0/−100
- examples/polkadot/Main.hs +0/−24
- examples/polkadot/package.yaml +0/−22
- examples/polkadot/stack.yaml +0/−70
- examples/scale/Main.hs +0/−30
- examples/scale/package.yaml +0/−23
- examples/scale/stack.yaml +0/−70
- examples/token/ERC20.hs +0/−12
- examples/token/ERC20.json +0/−1
- examples/token/Main.hs +0/−27
- examples/token/package.yaml +0/−25
- examples/token/stack.yaml +0/−71
- src/Codec/Scale.hs +0/−71
- src/Codec/Scale/Class.hs +0/−60
- src/Codec/Scale/Compact.hs +0/−70
- src/Codec/Scale/Core.hs +0/−197
- src/Codec/Scale/Generic.hs +0/−89
- src/Codec/Scale/SingletonEnum.hs +0/−30
- src/Codec/Scale/Skip.hs +0/−32
- src/Codec/Scale/TH.hs +0/−31
- src/Crypto/Ecdsa/Signature.hs +0/−96
- src/Crypto/Ecdsa/Utils.hs +0/−45
- src/Crypto/Ethereum.hs +0/−31
- src/Crypto/Ethereum/Keyfile.hs +0/−236
- src/Crypto/Ethereum/Signature.hs +0/−68
- src/Crypto/Ethereum/Utils.hs +0/−21
- src/Crypto/Random/HmacDrbg.hs +0/−67
- src/Data/ByteArray/HexString.hs +0/−67
- src/Data/Solidity/Abi.hs +0/−68
- src/Data/Solidity/Abi/Codec.hs +0/−67
- src/Data/Solidity/Abi/Generic.hs +0/−122
- src/Data/Solidity/Event.hs +0/−141
- src/Data/Solidity/Event/Internal.hs +0/−135
- src/Data/Solidity/Prim.hs +0/−30
- src/Data/Solidity/Prim/Address.hs +0/−123
- src/Data/Solidity/Prim/Bool.hs +0/−25
- src/Data/Solidity/Prim/Bytes.hs +0/−125
- src/Data/Solidity/Prim/Int.hs +0/−140
- src/Data/Solidity/Prim/List.hs +0/−56
- src/Data/Solidity/Prim/String.hs +0/−29
- src/Data/Solidity/Prim/Tagged.hs +0/−37
- src/Data/Solidity/Prim/Tuple.hs +0/−38
- src/Data/Solidity/Prim/Tuple/TH.hs +0/−34
- src/Data/String/Extra.hs +0/−25
- src/Language/Solidity/Abi.hs +0/−310
- src/Network/Ethereum.hs +0/−32
- src/Network/Ethereum/Account.hs +0/−54
- src/Network/Ethereum/Account/Class.hs +0/−55
- src/Network/Ethereum/Account/Default.hs +0/−73
- src/Network/Ethereum/Account/Internal.hs +0/−130
- src/Network/Ethereum/Account/LocalKey.hs +0/−97
- src/Network/Ethereum/Account/Personal.hs +0/−85
- src/Network/Ethereum/Account/Safe.hs +0/−55
- src/Network/Ethereum/Api/Eth.hs +0/−248
- src/Network/Ethereum/Api/Net.hs +0/−35
- src/Network/Ethereum/Api/Personal.hs +0/−93
- src/Network/Ethereum/Api/Types.hs +0/−296
- src/Network/Ethereum/Api/Web3.hs +0/−30
- src/Network/Ethereum/Chain.hs +0/−37
- src/Network/Ethereum/Contract.hs +0/−48
- src/Network/Ethereum/Contract/Event.hs +0/−22
- src/Network/Ethereum/Contract/Event/Common.hs +0/−83
- src/Network/Ethereum/Contract/Event/MultiFilter.hs +0/−481
- src/Network/Ethereum/Contract/Event/SingleFilter.hs +0/−233
- src/Network/Ethereum/Contract/Method.hs +0/−33
- src/Network/Ethereum/Contract/TH.hs +0/−348
- src/Network/Ethereum/Ens.hs +0/−60
- src/Network/Ethereum/Ens/PublicResolver.hs +0/−25
- src/Network/Ethereum/Ens/Registry.hs +0/−25
- src/Network/Ethereum/Transaction.hs +0/−59
- src/Network/Ethereum/Unit.hs +0/−191
- src/Network/Ipfs/Api/Bitswap.hs +0/−41
- src/Network/Ipfs/Api/Block.hs +0/−39
- src/Network/Ipfs/Api/Bootstrap.hs +0/−34
- src/Network/Ipfs/Api/Cid.hs +0/−44
- src/Network/Ipfs/Api/Config.hs +0/−40
- src/Network/Ipfs/Api/Core.hs +0/−88
- src/Network/Ipfs/Api/Dag.hs +0/−40
- src/Network/Ipfs/Api/Dht.hs +0/−41
- src/Network/Ipfs/Api/Files.hs +0/−74
- src/Network/Ipfs/Api/Internal.hs +0/−100
- src/Network/Ipfs/Api/Internal/Call.hs +0/−58
- src/Network/Ipfs/Api/Internal/Stream.hs +0/−41
- src/Network/Ipfs/Api/Key.hs +0/−48
- src/Network/Ipfs/Api/Log.hs +0/−42
- src/Network/Ipfs/Api/Object.hs +0/−81
- src/Network/Ipfs/Api/Pin.hs +0/−29
- src/Network/Ipfs/Api/Pubsub.hs +0/−39
- src/Network/Ipfs/Api/Repo.hs +0/−37
- src/Network/Ipfs/Api/Stats.hs +0/−28
- src/Network/Ipfs/Api/Swarm.hs +0/−49
- src/Network/Ipfs/Api/Types.hs +0/−823
- src/Network/Ipfs/Api/Types/Stream.hs +0/−154
- src/Network/Ipfs/Client.hs +0/−47
- src/Network/JsonRpc/TinyClient.hs +0/−217
- src/Network/Polkadot/Api/Account.hs +0/−28
- src/Network/Polkadot/Api/Author.hs +0/−78
- src/Network/Polkadot/Api/Babe.hs +0/−26
- src/Network/Polkadot/Api/Chain.hs +0/−49
- src/Network/Polkadot/Api/Childstate.hs +0/−67
- src/Network/Polkadot/Api/Contracts.hs +0/−54
- src/Network/Polkadot/Api/Engine.hs +0/−42
- src/Network/Polkadot/Api/Grandpa.hs +0/−25
- src/Network/Polkadot/Api/Offchain.hs +0/−42
- src/Network/Polkadot/Api/Payment.hs +0/−30
- src/Network/Polkadot/Api/Rpc.hs +0/−25
- src/Network/Polkadot/Api/State.hs +0/−184
- src/Network/Polkadot/Api/System.hs +0/−97
- src/Network/Polkadot/Api/Types.hs +0/−270
- src/Network/Web3.hs +7/−2
- src/Network/Web3/Provider.hs +0/−132
- stack.yaml +0/−21
- test/Network/Ethereum/Test/ComplexStorageSpec.hs +0/−151
- test/Network/Ethereum/Test/ERC20Spec.hs +0/−36
- test/Network/Ethereum/Test/LinearizationSpec.hs +0/−193
- test/Network/Ethereum/Test/LocalAccountSpec.hs +0/−51
- test/Network/Ethereum/Test/RegistrySpec.hs +0/−33
- test/Network/Ethereum/Test/SimpleStorageSpec.hs +0/−202
- test/Network/Ethereum/Test/Utils.hs +0/−80
- test/Network/Ipfs/Api/Test/Key.hs +0/−47
- test/Spec.hs +0/−1
- test/contracts/ComplexStorage.json +0/−4533
- test/contracts/Linearization.json +0/−2716
- test/contracts/Registry.json +0/−506
- test/contracts/SimpleStorage.json +0/−600
- unit/Codec/Scale/Test/CoreSpec.hs +0/−254
- unit/Codec/Scale/Test/SingleFieldStructSpec.hs +0/−106
- unit/Codec/Scale/Test/SkipSpec.hs +0/−81
- unit/Crypto/Ethereum/Test/KeyfileSpec.hs +0/−99
- unit/Crypto/Ethereum/Test/SignatureSpec.hs +0/−65
- unit/Crypto/Random/Test/HmacDrbgSpec.hs +0/−24
- unit/Data/Solidity/Test/AddressSpec.hs +0/−63
- unit/Data/Solidity/Test/EncodingSpec.hs +0/−265
- unit/Data/Solidity/Test/IntSpec.hs +0/−33
- unit/Language/Solidity/Test/AbiSpec.hs +0/−63
- unit/Language/Solidity/Test/CompilerSpec.hs +0/−32
- unit/Network/Ethereum/Contract/Test/THSpec.hs +0/−20
- unit/Network/Ethereum/Web3/Test/EventSpec.hs +0/−91
- unit/Network/Ethereum/Web3/Test/MethodDumpSpec.hs +0/−13
- unit/Spec.hs +0/−1
- web3.cabal +19/−588
@@ -1,149 +0,0 @@-# Changelog-All notable changes to this project will be documented in this file.--## [0.9.1.0] 2020-06-07-### Added-- SCALE codec implementation and tests -- SCALE codec example --### Changed-- Supported GHC version: >=8.4.4-- Imports optimized --### Removed-- LTS-14 support--## [0.9.0.0] 2020-05-24-### Added-- Experimental IPFS REST API client-- Experimental Polkadot JSON-RPC API client--### Changed-- Web3 abstraction moved to `Network.Web3`-- Ethereum entry point renamed `Network.Ethereum.Web3` -> `Network.Ethereum`-- Split from common ECDSA staff from `Crypto.Ethereum` to `Crypto.Ecdsa`-- Ethereum related tests moved to `Network.Ethereum.Test`--### Removed-- Support for build on LTS-11, LTS-12, LTS-13--## [0.8.4.0] 2020-05-03-### Added-- Tuple support for `pragma experimental ABIEncoderV2`-- Fixed dependencies bounds for stackage LTS-15--### Changed-- Fixed reusing of HTTP request Manager--## [0.8.3.2] 2019-05-13-### Changed-- Fixed dependencies bounds for stackage distribution-- Optimized LANGUAGE pragmas--## [0.8.3.1] 2019-01-21-### Changed-- Fixed dependencies bounds for stackage distribution--## [0.8.3.0] 2019-01-09-### Added-- Web3 secret storage v3 support--### Changed -- Cryptonite based ECC signer for messages and transactions, it removes secp256k1 dependency-- Fixed dependencies bounds for stackage LTS-13--## [0.8.2.1] 2018-11-19-### Changed-- Fixed dependencies bounds for stackage distribution--## [0.8.2.0] 2018-11-07-### Changed-- Gas estimation runs when gas limit is not set before--## [0.8.1.0] 2018-10-29-### Added-- Support vinyl-0.10 in `MultiFilter` module--## [0.8.0.0] 2018-10-26-### Added-- Support for Ethereum cryptography-- Local private key transaction signer -- Generalized JSON-RPC monad for API methods-- Support for multiple transaction sending methods via one `Account` api-- Monad based transaction sending parametrization -- Experimental support for solidity compiler (disabled by default) -- Support for Ethereum mainnet ENS resolver-- Contract typeclass with api/bytecode getters-- Gas estimation for sending transactions-- Contract typeclass TH generator-- Function for creating contracts-- Event single/multi filters-- HexString data type-- Personal api calls-- Address checksum--### Changed-- package.yaml instead web3.cabal package descriptor-- Solidity related data types and codecs moved to Data.Solidity-- Solidity related parsers and compiler moved to Language.Solidity-- Modules in Network.Ethereum.Web3 moved to Network.Ethereum.Api-- fromWei/toWei from `Unit` typeclass now operates over `Integral`--### Removed-- `convert` function from `Unit` typeclass--## [0.7.3.0] 2018-05-22-### Added-- 'Network.Ethereum.ABI.Prim' meta-module as primitive types and instances aggregator.-- Stackage nightly build compatibility.--### Changed-- Potential nullable web3 type ('Change', 'Block', 'Transaction', etc.) fields are encoded as 'Maybe'.--## [0.7.2.0] 2018-05-13-### Added-- Generic JSON-RPC API documentation improvements.-- TH generator bug fixes.--### Changed-- Generic JSON-RPC API use fixed size byte arrays.--### Removed-- 'BlockNumber', 'FilterId' types replaced by 'Quantity' type--## [0.7.1.0] 2018-05-02-### Added-- TxReceipt and Eth.getTransactionReceipt JSON-RPC method.-- Keyword escaper for TH generated names.-- Build flag to enable TLS support.--### Changed-- Library dependencies bounds fixed for GHC 8.2.2-8.4.2 (stackage LTS + Nightly).--## [0.7.0.0] 2018-04-22-### Added-- This CHANGELOG.md file for significant changes tracking.-- Descriptive types for all JSON-RPC method parameters and returned values (#15).-- Widely use of basement:Word256 type for encoding.-- Full list of ethereum abi encoding types:- * bool: `Bool`- * int256: `IntN`- * uint256: `UIntN`- * string: `Text`- * bytes: `Bytes`- * bytes32: `BytesN`- * dynamic array: `[]`- * static array: `ListN`--### Changed-- Rewriten encoding engine for best performance, it now based on cereal:Serialize instead of parsec:Parser.-- Renamed encoding type classes and methods: `ABIEncode` -> `ABIPut`, `ABIDecode` -> `ABIGet`.-- Encoding related modules moved to Network.Ethereum.ABI.-- Primitive abi encoding types are moved to separated modules in Network.Ethereum.ABI.Prim.-- Contract interation related modules moved to Network.Ethereum.Contract.-- Ethereum node communication modules stay in Network.Ethereum.Web3.-- JSON-RPC tiny client is independent now and can be used separately.--### Removed-- `Event` type class, currently TH create `Data.Default` instance for `Filter e`.-- Custom setup for live testing (it replaced by travis script).
@@ -1,30 +1,211 @@-Copyright Alexander Krupenkin (c) 2016-2020+ Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/ -All rights reserved.+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:+1. Definitions. - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.+ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document. - * Redistributions in binary form must reproduce the above- copyright notice, this list of conditions and the following- disclaimer in the documentation and/or other materials provided- with the distribution.+ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License. - * Neither the name of Alexander Krupenkin nor the names of other- contributors may be used to endorse or promote products derived- from this software without specific prior written permission.+ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++END OF TERMS AND CONDITIONS++APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++Copyright 2016-2021 Aleksandr Krupenkin ++Licensed under the Apache License, Version 2.0 (the "License");+you may not use this file except in compliance with the License.+You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing, software+distributed under the License is distributed on an "AS IS" BASIS,+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+See the License for the specific language governing permissions and+limitations under the License.++ NOTE+ +Individual files contain the following tag instead of the full license+text.++ SPDX-License-Identifier: Apache-2.0++This enables machine processing of license information based on the SPDX+License Identifiers that are here available: http://spdx.org/licenses/
@@ -1,81 +0,0 @@-Web3 API for Haskell-====================--This library implements Haskell API client for popular Web3 platforms.--[](https://hs-web3.readthedocs.io/en/latest/?badge=latest)-[](https://travis-ci.org/airalab/hs-web3)-[](https://matrix.hackage.haskell.org/package/web3)-[](http://hackage.haskell.org/package/web3)-[](http://stackage.org/lts-14/package/web3)-[](http://stackage.org/nightly/package/web3)-[](https://www.codetriage.com/airalab/hs-web3)---Install----------`stack install web3`--Usage--------```haskell-{-# LANGUAGE OverloadedStrings #-}-module Main where---- Basic imports-import Network.Ethereum-import Network.Web3---- Eth API support-import qualified Network.Ethereum.Api.Eth as Eth-import Network.Ethereum.Api.Types---- ENS support-import qualified Network.Ethereum.Ens as Ens---- Lens to simple param setting-import Lens.Micro ((.~))--main :: IO ()-main = do- -- Use default provider on http://localhost:8545- ret <- runWeb3 $ do-- -- Get address of default account- me <- head <$> Eth.accounts-- -- Get balance of default account on latest block- myBalance <- Eth.getBalance me Latest-- -- Get half of balance- let halfBalance = fromWei (myBalance / 2)-- -- Use default account- withAccount () $ do- -- Get Ethereum address via ENS- alice <- Ens.resolve "alice.address.on.eth"- bob <- Ens.resolve "bob.address.on.eth"-- -- Send transaction with value- withParam (value .~ halfBalance) $ do-- -- Send transaction to alice account- withParam (to .~ alice) $ send ()-- -- Send transaction to bob account- withParam (to .~ bob) $ send ()-- -- Return sended value- return halfBalance-- -- Web3 error handling- case ret of- Left e -> error $ show e- Right v -> print (v :: Ether) -- Print returned value in ethers-```-------Read more in the [documentation on ReadTheDocs](https://hs-web3.readthedocs.io).
@@ -1,58 +0,0 @@-{-# LANGUAGE CPP #-}-#ifdef SOLIDITY_COMPILER-{-# LANGUAGE RecordWildCards #-}-#endif---- |--- Module : Language.Solidity.Compiler--- Copyright : Alexander Krupenkin 2017--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Solidity compiler high-level bindings.-----module Language.Solidity.Compiler where--#ifdef SOLIDITY_COMPILER--import Data.ByteString (ByteString)-import Data.Map (Map)-import Data.Semigroup (Semigroup (..))-import qualified Language.Solidity.Compiler.Foreign as FFI-import System.IO.Unsafe (unsafePerformIO)---- | Input contract sources-data Sources = Sources- { sourceMap :: Map ByteString ByteString- -- ^ Source code map from contract name in keys- , libraries :: Map ByteString ByteString- -- ^ Library address map for linking- , optimization :: Bool- -- ^ Enable optimization?- } deriving (Eq, Show)--instance Semigroup Sources where- a <> b = Sources (sourceMap a `mappend` sourceMap b)- (libraries a `mappend` libraries b)- (optimization a || optimization b)--instance Monoid Sources where- mappend = (<>)- mempty = Sources mempty mempty False--type Compiled = Map ByteString (ByteString, ByteString)---- | Compile Solidity contracts-compile :: Sources- -- ^ Contract sources- -> Either ByteString Compiled- -- ^ Error string or compiled contracts ABI and hex-{-# NOINLINE compile #-}-compile Sources{..} = unsafePerformIO $- FFI.compile sourceMap libraries optimization--#endif
@@ -1,106 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE ForeignFunctionInterface #-}---- |--- Module : Language.Solidity.Compiler.Foreign--- Copyright : Alexander Krupenkin 2017--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum Solidity library FFI.-----module Language.Solidity.Compiler.Foreign where--#ifdef SOLIDITY_COMPILER-#include <solidity_lite.h>--import Data.Map as M-import Data.ByteString.Char8 as BS-import Data.Typeable (Typeable)-import Foreign.C.String (CString, peekCString, withCString)-import Foreign.C.Types (CInt(..))-import Foreign.Ptr (Ptr)-import Foreign (free)--data Solidity- deriving Typeable--foreign import ccall unsafe "create" c_create- :: IO (Ptr Solidity)-foreign import ccall unsafe "destroy" c_destroy- :: Ptr Solidity -> IO ()-foreign import ccall unsafe "addSource" c_addSource- :: Ptr Solidity -> CString -> CString -> IO CInt-foreign import ccall unsafe "addLibrary" c_addLibrary- :: Ptr Solidity -> CString -> CString -> IO CInt-foreign import ccall unsafe "compile" c_compile- :: Ptr Solidity -> CInt -> IO CInt-foreign import ccall unsafe "abi" c_abi- :: Ptr Solidity -> CString -> IO CString-foreign import ccall unsafe "binary" c_binary- :: Ptr Solidity -> CString -> IO CString-foreign import ccall unsafe "errors" c_errors- :: Ptr Solidity -> IO CString--withSolidity :: (Ptr Solidity -> IO a) -> IO a-{-# INLINE withSolidity #-}-withSolidity f = do- ptr <- c_create- r <- f ptr- c_destroy ptr- return r--withCStringPair :: (CString -> CString -> IO a) -> (ByteString, ByteString) -> IO a-{-# INLINE withCStringPair #-}-withCStringPair f (a, b) =- withCString (BS.unpack a) $ \astr ->- withCString (BS.unpack b) $ \bstr ->- f astr bstr--addSources :: Ptr Solidity -> Map ByteString ByteString -> IO ()-{-# INLINE addSources #-}-addSources ptr = mapM_ (withCStringPair $ c_addSource ptr) . M.toList--addLibraries :: Ptr Solidity -> Map ByteString ByteString -> IO ()-{-# INLINE addLibraries #-}-addLibraries ptr = mapM_ (withCStringPair $ c_addLibrary ptr) . M.toList--result :: Ptr Solidity -> ByteString -> IO (ByteString, ByteString)-result ptr name =- withCString (BS.unpack name) $ \cname -> do- abi <- c_abi ptr cname- bin <- c_binary ptr cname- res <- (,) <$> fmap BS.pack (peekCString abi)- <*> fmap BS.pack (peekCString bin)- free abi- free bin- return res--errors :: Ptr Solidity -> IO ByteString-errors ptr = do- errs <- c_errors ptr- res <- BS.pack <$> peekCString errs- free errs- return res--compile :: Map ByteString ByteString- -> Map ByteString ByteString- -> Bool- -> IO (Either ByteString (Map ByteString (ByteString, ByteString)))-compile srcs libs opt =- withSolidity $ \ptr -> do- addSources ptr srcs- addLibraries ptr libs- res <- c_compile ptr optI- let compiled = sequence $ M.mapWithKey (const . result ptr) srcs- if res < 0- then Left <$> errors ptr- else Right <$> compiled- where optI | opt = 1- | otherwise = 0--#endif
@@ -1,100 +0,0 @@-#include <solidity_lite.h>-#include <libsolidity/interface/CompilerStack.h>-#include <liblangutil/SourceReferenceFormatter.h>--using namespace dev::solidity;-using namespace langutil;-using namespace std;--struct Solidity {- Solidity() : compiler(new CompilerStack)- {}-- ~Solidity()- { delete compiler; }-- CompilerStack * compiler;- map<string, dev::h160> libs;-};--#ifdef __cplusplus-extern "C"-{-#endif--namespace dev {-namespace solidity {-namespace lite {--void * create()-{- return static_cast<void *>(new Solidity);-}--void destroy(void * self)-{- delete static_cast<Solidity *>(self);-}--int addSource(void * self, const char * name, const char * source)-{- return static_cast<Solidity*>(self)->compiler->addSource(name, source);-}--int addLibrary(void * self, const char * name, const char * address)-{- static_cast<Solidity*>(self)->libs[name] = dev::h160(address);- return 0;-}--int compile(void * self, int optimize)-{- auto s = static_cast<Solidity *>(self);-- s->compiler->setOptimiserSettings(optimize);- s->compiler->setLibraries(s->libs);- s->compiler->reset(true);- if (s->compiler->parseAndAnalyze()) - if (s->compiler->compile())- return 0;-- return -1;-}--char * c_string(const std::string &str)-{- auto c_str = (char *) calloc(1, str.size()+1);- memcpy(c_str, str.c_str(), str.size());- return c_str;-}--char * abi(void * self, const char * name)-{- auto abi_value = static_cast<Solidity *>(self)->compiler->contractABI(name);- return c_string(abi_value.toStyledString());-}--char * binary(void * self, const char * name)-{- auto bin_object = static_cast<Solidity *>(self)->compiler->object(name);- return c_string(bin_object.toHex());-}--char * errors(void * self)-{- auto compiler = static_cast<Solidity *>(self)->compiler;- stringstream error_stream;- for (auto const& error: compiler->errors()) {- SourceReferenceFormatter fmt(error_stream, [&](string const& _source) -> Scanner const& { return compiler->scanner(_source); });- fmt.printExceptionInformation(*error, (error->type() == Error::Type::Warning) ? "Warning" : "Error");- }- return c_string(error_stream.str());-}--} // solidity-} // lite-} // dev--#ifdef __cplusplus-}-#endif
@@ -1,24 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Main where--import Control.Monad.IO.Class (liftIO)--import qualified Network.Polkadot.Api.Chain as Chain-import qualified Network.Polkadot.Api.State as State-import qualified Network.Polkadot.Api.System as System-import Network.Web3.Provider (Provider (..), runWeb3')--main :: IO ()-main = do- result <- runWeb3' (WsProvider "127.0.0.1" 9944) $ do- name <- System.name- liftIO . putStrLn $ "System name: " ++ show name-- best <- Chain.getBlockHash Nothing- liftIO . putStrLn $ "Best hash: " ++ show best-- State.getRuntimeVersion best-- case result of- Left err -> error (show err)- Right version -> putStrLn (show version)
@@ -1,22 +0,0 @@-name: example-polkadot-version: 0.0.0.0-synopsis: Polkadot API example-github: "airalab/hs-web3"-license: BSD3-author: Alexander Krupenkin-maintainer: mail@akru.me-copyright: "(c) Alexander Krupenkin 2016"-category: Network--dependencies:-- base-- web3 --executables:- example-polkadot:- main: Main.hs- source-dirs: ./- ghc-options:- - -threaded- - -rtsopts- - -with-rtsopts=-N
@@ -1,70 +0,0 @@-# This file was automatically generated by 'stack init'-#-# Some commonly used options have been documented as comments in this file.-# For advanced use and comprehensive documentation of the format, please see:-# https://docs.haskellstack.org/en/stable/yaml_configuration/--# Resolver to choose a 'specific' stackage snapshot or a compiler version.-# A snapshot resolver dictates the compiler version and the set of packages-# to be used for project dependencies. For example:-#-# resolver: lts-3.5-# resolver: nightly-2015-09-21-# resolver: ghc-7.10.2-#-# The location of a snapshot can be provided as a file or url. Stack assumes-# a snapshot provided as a file might change, whereas a url resource does not.-#-# resolver: ./custom-snapshot.yaml-# resolver: https://example.com/snapshots/2018-01-01.yaml-resolver: lts-15.13--# User packages to be built.-# Various formats can be used as shown in the example below.-#-# packages:-# - some-directory-# - https://example.com/foo/bar/baz-0.0.2.tar.gz-# - location:-# git: https://github.com/commercialhaskell/stack.git-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# subdirs:-# - auto-update-# - wai-packages:-- .-- ../..-# Dependency packages to be pulled from upstream that are not in the resolver-# using the same syntax as the packages field.-# (e.g., acme-missiles-0.3)-extra-deps:-- relapse-1.0.0.0@sha256:b89ea23189e07f377be4e2a4deccf3d6ba7f547ed8ad77e27b35d78801efd81c-- vinyl-0.12.1@sha256:03f5e246fae2434250987bbfe708015dc6e23f60c20739c34738acde1383b96c--# Override default flag values for local packages and extra-deps-# flags: {}--# Extra package databases containing global packages-# extra-package-dbs: []--# Control whether we use the GHC we find on the path-# system-ghc: true-#-# Require a specific version of stack, using version ranges-# require-stack-version: -any # Default-# require-stack-version: ">=1.9"-#-# Override the architecture used by stack, especially useful on Windows-# arch: i386-# arch: x86_64-#-# Extra directories used by stack for building-# extra-include-dirs: [/path/to/dir]-# extra-lib-dirs: [/path/to/dir]-#-# Allow a newer minor version of GHC than the snapshot specifies-# compiler-check: newer-minor-nix:- packages:- - zlib
@@ -1,30 +0,0 @@-{-# LANGUAGE DeriveAnyClass #-}-{-# LANGUAGE DeriveGeneric #-}-module Main where--import Codec.Scale-import Codec.Scale.Skip-import Data.ByteArray.HexString (HexString)-import Data.Word (Word32)-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)--data MyTransaction a = Tx- { from :: Word32- , to :: Word32- , balance :: Compact Integer- , note :: Skip a- }- deriving (Show, Eq, GHC.Generic, Generic, Encode, Decode)--main :: IO ()-main = do- let alice = 42- bob = 15- my_tx = Tx { from = alice- , to = bob- , balance = Compact 1000000- , note = Skip "Hello!"- }- putStrLn "Encoded transaction:"- print (encode my_tx :: HexString)
@@ -1,23 +0,0 @@-name: example-scale-version: 0.0.0.0-synopsis: SCALE codec example-github: "airalab/hs-web3"-license: BSD3-author: Alexander Krupenkin-maintainer: mail@akru.me-copyright: "(c) Alexander Krupenkin 2016"-category: Network--dependencies:-- base-- web3 -- generics-sop--executables:- example-scale:- main: Main.hs- source-dirs: ./- ghc-options:- - -threaded- - -rtsopts- - -with-rtsopts=-N
@@ -1,70 +0,0 @@-# This file was automatically generated by 'stack init'-#-# Some commonly used options have been documented as comments in this file.-# For advanced use and comprehensive documentation of the format, please see:-# https://docs.haskellstack.org/en/stable/yaml_configuration/--# Resolver to choose a 'specific' stackage snapshot or a compiler version.-# A snapshot resolver dictates the compiler version and the set of packages-# to be used for project dependencies. For example:-#-# resolver: lts-3.5-# resolver: nightly-2015-09-21-# resolver: ghc-7.10.2-#-# The location of a snapshot can be provided as a file or url. Stack assumes-# a snapshot provided as a file might change, whereas a url resource does not.-#-# resolver: ./custom-snapshot.yaml-# resolver: https://example.com/snapshots/2018-01-01.yaml-resolver: lts-15.13--# User packages to be built.-# Various formats can be used as shown in the example below.-#-# packages:-# - some-directory-# - https://example.com/foo/bar/baz-0.0.2.tar.gz-# - location:-# git: https://github.com/commercialhaskell/stack.git-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# subdirs:-# - auto-update-# - wai-packages:-- .-- ../..-# Dependency packages to be pulled from upstream that are not in the resolver-# using the same syntax as the packages field.-# (e.g., acme-missiles-0.3)-extra-deps:-- relapse-1.0.0.0@sha256:b89ea23189e07f377be4e2a4deccf3d6ba7f547ed8ad77e27b35d78801efd81c-- vinyl-0.12.1@sha256:03f5e246fae2434250987bbfe708015dc6e23f60c20739c34738acde1383b96c--# Override default flag values for local packages and extra-deps-# flags: {}--# Extra package databases containing global packages-# extra-package-dbs: []--# Control whether we use the GHC we find on the path-# system-ghc: true-#-# Require a specific version of stack, using version ranges-# require-stack-version: -any # Default-# require-stack-version: ">=1.9"-#-# Override the architecture used by stack, especially useful on Windows-# arch: i386-# arch: x86_64-#-# Extra directories used by stack for building-# extra-include-dirs: [/path/to/dir]-# extra-lib-dirs: [/path/to/dir]-#-# Allow a newer minor version of GHC than the snapshot specifies-# compiler-check: newer-minor-nix:- packages:- - zlib
@@ -1,12 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-module ERC20 where--import Network.Ethereum.Contract.TH--[abiFrom|ERC20.json|]
@@ -1,1 +0,0 @@-[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"delegate","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"}],"name":"unapprove","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint8"},{"name":"_count","type":"uint256"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}]
@@ -1,27 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Main where--import Data.Default (def)-import Data.Text (unpack)-import Text.Printf (printf)--import Lens.Micro ((.~))-import Network.Ethereum hiding (name)-import Network.Ethereum.Account-import Network.Web3--import ERC20--main :: IO ()-main = do- result <- runWeb3 $- withAccount () $- withParam (to .~ "0xA2f4FCb0FDe2dD59f7a1873e121bc5623e3164Eb") $ do- n <- name- s <- symbol- d <- decimals- return $ printf "Token %s with symbol %s and decimals %d"- (unpack n) (unpack s) (fromIntegral d :: Int)- case result of- Left err -> error (show err)- Right info -> putStrLn info
@@ -1,25 +0,0 @@-name: example-erc20-version: 0.0.0.0-synopsis: ERC20 token example-github: "airalab/hs-web3"-license: BSD3-author: Alexander Krupenkin-maintainer: mail@akru.me-copyright: "(c) Alexander Krupenkin 2016"-category: Network--dependencies:-- base-- data-default-- microlens-- text-- web3 --executables:- example-erc20:- main: Main.hs- source-dirs: ./- ghc-options:- - -threaded- - -rtsopts- - -with-rtsopts=-N
@@ -1,71 +0,0 @@-# This file was automatically generated by 'stack init'-#-# Some commonly used options have been documented as comments in this file.-# For advanced use and comprehensive documentation of the format, please see:-# https://docs.haskellstack.org/en/stable/yaml_configuration/--# Resolver to choose a 'specific' stackage snapshot or a compiler version.-# A snapshot resolver dictates the compiler version and the set of packages-# to be used for project dependencies. For example:-#-# resolver: lts-3.5-# resolver: nightly-2015-09-21-# resolver: ghc-7.10.2-#-# The location of a snapshot can be provided as a file or url. Stack assumes-# a snapshot provided as a file might change, whereas a url resource does not.-#-# resolver: ./custom-snapshot.yaml-# resolver: https://example.com/snapshots/2018-01-01.yaml-resolver: lts-15.13--# User packages to be built.-# Various formats can be used as shown in the example below.-#-# packages:-# - some-directory-# - https://example.com/foo/bar/baz-0.0.2.tar.gz-# - location:-# git: https://github.com/commercialhaskell/stack.git-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# subdirs:-# - auto-update-# - wai-packages:-- .-- ../..-# Dependency packages to be pulled from upstream that are not in the resolver-# using the same syntax as the packages field.-# (e.g., acme-missiles-0.3)-extra-deps:-- relapse-1.0.0.0@sha256:b89ea23189e07f377be4e2a4deccf3d6ba7f547ed8ad77e27b35d78801efd81c-- vinyl-0.12.1@sha256:03f5e246fae2434250987bbfe708015dc6e23f60c20739c34738acde1383b96c--# Override default flag values for local packages and extra-deps-# flags: {}--# Extra package databases containing global packages-# extra-package-dbs: []--# Control whether we use the GHC we find on the path-# system-ghc: true-#-# Require a specific version of stack, using version ranges-# require-stack-version: -any # Default-# require-stack-version: ">=1.9"-#-# Override the architecture used by stack, especially useful on Windows-# arch: i386-# arch: x86_64-#-# Extra directories used by stack for building-# extra-include-dirs: [/path/to/dir]-# extra-lib-dirs: [/path/to/dir]-#-# Allow a newer minor version of GHC than the snapshot specifies-# compiler-check: newer-minor-nix:- packages:- - zlib- - secp256k1
@@ -1,71 +0,0 @@-{-# LANGUAGE TypeFamilies #-}---- |--- Module : Codec.Scale.Class--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ The SCALE (Simple Concatenated Aggregate Little-Endian) Codec is--- a lightweight, efficient, binary serialization and deserialization codec.------ It is designed for high-performance, copy-free encoding and decoding of data in--- resource-constrained execution contexts, like the Substrate runtime. It is not--- self-describing in any way and assumes the decoding context has all type--- knowledge about the encoded data.-----module Codec.Scale- ( encode- , decode- , encode'- , decode'- , Encode- , Decode- , module Core- ) where--import Data.ByteArray (ByteArray, ByteArrayAccess, convert)-import Data.Serialize (runGet, runPut)-import Generics.SOP (Generic, Rep, from, to)--import Codec.Scale.Class (Decode (..), Encode (..), GDecode (..),- GEncode (..))-import Codec.Scale.Core as Core---- | Encode datatype to SCALE format.-encode :: (Encode a, ByteArray ba)- => a- -> ba-{-# INLINE encode #-}-encode = convert . runPut . put---- | Generic driven version of 'encode'-encode' :: (Generic a,- Rep a ~ rep,- GEncode rep,- ByteArray ba)- => a- -> ba-{-# INLINE encode' #-}-encode' = convert . runPut . gPut . from---- | Decode datatype from SCALE format.-decode :: (ByteArrayAccess ba, Decode a)- => ba- -> Either String a-{-# INLINE decode #-}-decode = runGet get . convert---- | Generic driven version of 'decode'-decode' :: (Generic a,- Rep a ~ rep,- GDecode rep,- ByteArrayAccess ba)- => ba- -> Either String a-{-# INLINE decode' #-}-decode' = runGet (to <$> gGet) . convert
@@ -1,60 +0,0 @@-{-# LANGUAGE DefaultSignatures #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TypeFamilies #-}---- |--- Module : Codec.Scale.Class--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable-----------module Codec.Scale.Class where--import Data.Serialize (Get, Putter)-import Generics.SOP (Generic, Rep, from, to)---- | A class for encoding datatypes to SCALE format.------ If your compiler has support for the @DeriveGeneric@ and--- @DefaultSignatures@ language extensions (@ghc >= 7.2.1@),--- the 'put' method will have default generic implementations.------ To use this option, simply add a @deriving 'Generic'@ clause--- to your datatype and declare a 'Encode' instance for it without--- giving a definition for 'put'.----class Encode a where- put :: Putter a-- default put :: (Generic a, Rep a ~ rep, GEncode rep) => Putter a- put = gPut . from---- | A class for encoding generically composed datatypes to SCALE format.-class GEncode a where- gPut :: Putter a---- | A class for decoding datatypes from SCALE format.------ If your compiler has support for the @DeriveGeneric@ and--- @DefaultSignatures@ language extensions (@ghc >= 7.2.1@),--- the 'get' method will have default generic implementations.------ To use this option, simply add a @deriving 'Generic'@ clause--- to your datatype and declare a 'Decode' instance for it without--- giving a definition for 'get'.----class Decode a where- get :: Get a-- default get :: (Generic a, Rep a ~ rep, GDecode rep) => Get a- get = to <$> gGet---- | A class for decoding generically composed datatypes from SCALE format.-class GDecode a where- gGet :: Get a
@@ -1,70 +0,0 @@--- |--- Module : Codec.Scale.Compact--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Efficient general integer codec.-----module Codec.Scale.Compact (Compact(..)) where--import Control.Monad (replicateM)-import Data.Bits (shiftL, shiftR, (.&.), (.|.))-import Data.List (unfoldr)-import Data.Serialize.Get (getWord16le, getWord32le, getWord8,- lookAhead)-import Data.Serialize.Put (putWord16le, putWord32le, putWord8)--import Codec.Scale.Class (Decode (..), Encode (..))---- | A "compact" or general integer encoding is sufficient for encoding--- large integers (up to 2**536) and is more efficient at encoding most--- values than the fixed-width version.-newtype Compact a = Compact { unCompact :: a }- deriving (Eq, Ord)--instance Show a => Show (Compact a) where- show = ("Compact " ++) . show . unCompact--instance Integral a => Encode (Compact a) where- put (Compact x)- | n < 0 = error "negatives not supported by compact codec"- | n < 64 = singleByteMode- | n < 2^14 = twoByteMode- | n < 2^30 = fourByteMode- | n < 2^536 = bigIntegerMode- | otherwise = error $ "unable to encode " ++ show n ++ " as compact"- where- n = toInteger x- singleByteMode = putWord8 (fromIntegral x `shiftL` 2)- twoByteMode = putWord16le (fromIntegral x `shiftL` 2 .|. 1)- fourByteMode = putWord32le (fromIntegral x `shiftL` 2 .|. 2)- bigIntegerMode = do- let step 0 = Nothing- step i = Just (fromIntegral i, i `shiftR` 8)- unroll = unfoldr step n- putWord8 (fromIntegral (length unroll) `shiftL` 2 .|. 3)- mapM_ putWord8 unroll--instance Integral a => Decode (Compact a) where- get = do- mode <- lookAhead ((3 .&.) <$> getWord8)- Compact <$> case mode of- 0 -> fromIntegral <$> singleByteMode- 1 -> fromIntegral <$> twoByteMode- 2 -> fromIntegral <$> fourByteMode- 3 -> bigIntegerMode- _ -> fail "unexpected prefix decoding compact number"- where- singleByteMode = flip shiftR 2 <$> getWord8- twoByteMode = flip shiftR 2 <$> getWord16le- fourByteMode = flip shiftR 2 <$> getWord32le- bigIntegerMode = do- let unstep b a = a `shiftL` 8 .|. fromIntegral b- roll = fromInteger . foldr unstep 0- len <- flip shiftR 2 <$> getWord8- roll <$> replicateM (fromIntegral len) getWord8
@@ -1,197 +0,0 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Codec.Scale.Core--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Particular core type instances.-----module Codec.Scale.Core (Compact(..)) where--import Control.Monad (replicateM)-import Data.Bit (Bit, castFromWords8, cloneToWords8)-import Data.Int (Int16, Int32, Int64, Int8)-import Data.Serialize.Get (getInt16le, getInt32le, getInt64le,- getInt8, getWord16le, getWord32le,- getWord64le, getWord8)-import Data.Serialize.Put (putInt16le, putInt32le, putInt64le,- putInt8, putWord16le, putWord32le,- putWord64le, putWord8)-import Data.Vector.Unboxed (Unbox, Vector)-import qualified Data.Vector.Unboxed as V-import Data.Word (Word16, Word32, Word64, Word8)-import Generics.SOP ()--import Codec.Scale.Class (Decode (..), Encode (..))-import Codec.Scale.Compact (Compact (..))-import Codec.Scale.Generic ()-import Codec.Scale.TH (tupleInstances)------- Boolean instance.-----instance Encode Bool where- put False = putWord8 0- put True = putWord8 1--instance Decode Bool where- get = do x <- getWord8- case x of- 0 -> return False- 1 -> return True- _ -> fail "invalid boolean representation"------- Integer instances.-----instance Encode Word8 where- put = putWord8--instance Decode Word8 where- get = getWord8--instance Encode Word16 where- put = putWord16le--instance Decode Word16 where- get = getWord16le--instance Encode Word32 where- put = putWord32le--instance Decode Word32 where- get = getWord32le--instance Encode Word64 where- put = putWord64le--instance Decode Word64 where- get = getWord64le--instance Encode Int8 where- put = putInt8--instance Decode Int8 where- get = getInt8--instance Encode Int16 where- put = putInt16le--instance Decode Int16 where- get = getInt16le--instance Encode Int32 where- put = putInt32le--instance Decode Int32 where- get = getInt32le--instance Encode Int64 where- put = putInt64le--instance Decode Int64 where- get = getInt64le------- Option type instances.------- Let's map `Maybe a` type to Rust `Option<T>`: Just -> Some, Nothing -> None--instance Encode a => Encode (Maybe a) where- put (Just a) = putWord8 1 >> put a- put Nothing = putWord8 0--instance Decode a => Decode (Maybe a) where- get = do- x <- getWord8- case x of- 0 -> return Nothing- 1 -> Just <$> get- _ -> fail "unexpecded first byte decoding Option"---- Option<bool> is exception and it is always one byte--instance {-# OVERLAPPING #-} Encode (Maybe Bool) where- put Nothing = putWord8 0- put (Just False) = putWord8 1- put (Just True) = putWord8 2--instance {-# OVERLAPPING #-} Decode (Maybe Bool) where- get = do- x <- getWord8- case x of- 0 -> return Nothing- 1 -> return (Just False)- 2 -> return (Just True)- _ -> fail "unexpecded first byte decoding OptionBool"------- Result type isntances.------- Let's map `Ether a b` type to Rust `Result<T, E>`: Left -> Error, Right -> Ok--instance (Encode a, Encode b) => Encode (Either a b) where- put (Right a) = putWord8 0 >> put a- put (Left a) = putWord8 1 >> put a--instance (Decode a, Decode b) => Decode (Either a b) where- get = do- x <- getWord8- case x of- 0 -> Right <$> get- 1 -> Left <$> get- _ -> fail "unexpected first byte decoding Result"-------- Tuple type instances.-----$(concat <$> mapM tupleInstances [2..20])------- Vector type instances.-----instance Encode a => Encode [a] where- put list = do- put (Compact $ length list)- mapM_ put list--instance Decode a => Decode [a] where- get = do- len <- get- replicateM (unCompact len) get--instance (Encode a, Unbox a) => Encode (Vector a) where- put vec = do- put (Compact $ V.length vec)- V.mapM_ put vec--instance (Decode a, Unbox a) => Decode (Vector a) where- get = do- len <- get- V.replicateM (unCompact len) get--instance {-# OVERLAPPING #-} Encode (Vector Bit) where- put vec = do- let encoded = cloneToWords8 vec- put (Compact $ V.length encoded)- V.mapM_ put encoded--instance {-# OVERLAPPING #-} Decode (Vector Bit) where- get = do- len <- get- castFromWords8 <$> V.replicateM (unCompact len) get
@@ -1,89 +0,0 @@-{-# LANGUAGE BangPatterns #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeInType #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Codec.Scale.Generic--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ This module defines generic codec instances for data structures (including tuples)--- and enums (tagged-unions in Rust).-----module Codec.Scale.Generic () where--import Data.Serialize.Get (Get, getWord8)-import Data.Serialize.Put (PutM, putWord8)-import Data.Word (Word8)-import Generics.SOP (All, Compose, I (..), NP (..), NS (..),- SOP (..), unSOP, unZ)--import Codec.Scale.Class (Decode (..), Encode (..), GDecode (..),- GEncode (..))---- Enum has multiple sum types.-instance ( GEncode (NP f xs)- , GEncode (NP f ys)- , All (GEncode `Compose` NP f) xss- ) => GEncode (SOP f (xs ': ys ': xss)) where- gPut = go 0 . unSOP- where- go :: forall f as . All (GEncode `Compose` f) as => Word8 -> NS f as -> PutM ()- go !acc (Z x) = putWord8 acc >> gPut x- go !acc (S x) = go (acc + 1) x---- Structures has only one sum type.-instance GEncode (NP f xs) => GEncode (SOP f '[xs]) where- gPut = gPut . unZ . unSOP---- Product serialization is just encode each field step by step.-instance (Encode a, GEncode (NP I as)) => GEncode (NP I (a ': as)) where- gPut (I a :* as) = put a >> gPut as---- Finish when all fields handled.-instance GEncode (NP I '[]) where- gPut _ = mempty---- | Enum parser definition.------ The index of sum type to parse given as an argument.-class EnumParser xs where- enumParser :: All (GDecode `Compose` NP f) xs => Word8 -> Get (NS (NP f) xs)---- Enumerate enum index, zero means that we reach the goal.-instance EnumParser as => EnumParser (a ': as) where- enumParser !i | i > 0 = S <$> enumParser (i - 1)- | otherwise = Z <$> gGet---- When index out of type scope raise the error.-instance EnumParser '[] where- enumParser _ = fail "wrong prefix during enum decoding"---- Decode enum when multiple sum types.-instance ( GDecode (NP f xs)- , GDecode (NP f ys)- , All (GDecode `Compose` NP f) xss- , EnumParser xss- ) => GDecode (SOP f (xs ': ys ': xss)) where- gGet = SOP <$> (enumParser =<< getWord8)---- Decode plain structure when only one sum type.-instance GDecode (NP f as) => GDecode (SOP f '[as]) where- gGet = SOP . Z <$> gGet---- Decode each field in sequence.-instance (Decode a, GDecode (NP I as)) => GDecode (NP I (a ': as)) where- gGet = (:*) <$> (I <$> get) <*> gGet---- Finish decoding when empty.-instance GDecode (NP I '[]) where- gGet = return Nil
@@ -1,30 +0,0 @@--- |--- Module : Codec.Scale.SingletonEnum--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ This type helps to encode/decode singleton Rust enums like:--- `enum Enum { Data { some_data: u32 } }`-----module Codec.Scale.SingletonEnum (SingletonEnum(..)) where--import Data.Serialize.Get (getWord8)-import Data.Serialize.Put (putWord8)--import Codec.Scale.Class (Decode (..), Encode (..))---- | Haskell don't permit to make Rust-like enum type with only one element.--- For this reason it is impossible to make generic parser for singleton enum type.--- This type helps to parse Rust encoded singleton enums.-newtype SingletonEnum a = SingletonEnum { unSingletonEnum :: a }--instance Encode a => Encode (SingletonEnum a) where- put (SingletonEnum x) = putWord8 0 >> put x--instance Decode a => Decode (SingletonEnum a) where- get = getWord8 >> (SingletonEnum <$> get)
@@ -1,32 +0,0 @@--- |--- Module : Codec.Scale.Skip--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ This type helps to skip fields in encoded data type.-----module Codec.Scale.Skip (Skip(..)) where--import Data.Default (Default (..))--import Codec.Scale.Class (Decode (..), Encode (..))---- | This type hide filed from encoding context.--- It's useful in cases when serialization impossible or not needed.--- For decoding wrapped type should have 'Default' instance.-newtype Skip a = Skip { unSkip :: a }- deriving (Eq, Ord, Show)--instance Encode (Skip a) where- put _ = return ()--instance Default a => Decode (Skip a) where- get = return def--instance Default a => Default (Skip a) where- def = Skip def
@@ -1,31 +0,0 @@-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Codec.Scale.TH--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ It contains template haskell SCALE helper functions.-----module Codec.Scale.TH where---import Control.Monad (replicateM)-import Language.Haskell.TH (DecsQ, Type (VarT), appT, conT, cxt,- instanceD, newName, tupleT)--import Codec.Scale.Class (Decode, Encode)--tupleInstances :: Int -> DecsQ-tupleInstances n = do- vars <- replicateM n $ newName "a"- let types = fmap (pure . VarT) vars- sequence $- [ instanceD (cxt $ map (appT $ conT ''Decode) types) (appT (conT ''Decode) (foldl appT (tupleT n) types)) []- , instanceD (cxt $ map (appT $ conT ''Encode) types) (appT (conT ''Encode) (foldl appT (tupleT n) types)) []- ]
@@ -1,96 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Crypto.Ecdsa.Signature--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Recoverable ECC signature support.-----module Crypto.Ecdsa.Signature- (- sign- , pack- , unpack- ) where--import Control.Monad (when)-import Crypto.Hash (SHA256)-import Crypto.Number.Generate (generateBetween)-import Crypto.Number.ModArithmetic (inverse)-import Crypto.Number.Serialize (i2osp, os2ip)-import Crypto.PubKey.ECC.ECDSA (PrivateKey (..))-import Crypto.PubKey.ECC.Prim (pointMul)-import Crypto.PubKey.ECC.Types (CurveCommon (ecc_g, ecc_n),- Point (..), common_curve)-import Crypto.Random (MonadRandom, withDRG)-import Crypto.Random.HmacDrbg (HmacDrbg, initialize)-import Data.Bits (xor, (.|.))-import Data.ByteArray (ByteArray, ByteArrayAccess, Bytes,- convert, singleton, takeView,- view)-import qualified Data.ByteArray as BA (unpack)-import Data.Word (Word8)--import Crypto.Ecdsa.Utils (exportKey)---- | Sign arbitrary data by given private key.------ /WARNING:/ Vulnerable to timing attacks.-sign :: ByteArrayAccess bin- => PrivateKey- -> bin- -> (Integer, Integer, Word8)-sign pk bin = fst $ withDRG hmac_drbg $ ecsign pk (os2ip truncated)- where- hmac_drbg :: HmacDrbg SHA256- hmac_drbg = initialize $ exportKey pk <> truncated- truncated = convert $ takeView bin 32 :: Bytes--ecsign :: MonadRandom m- => PrivateKey- -> Integer- -> m (Integer, Integer, Word8)-ecsign pk@(PrivateKey curve d) z = do- k <- generateBetween 0 (n - 1)- case trySign k of- Nothing -> ecsign pk z- Just rsv -> return rsv- where- n = ecc_n (common_curve curve)- g = ecc_g (common_curve curve)- recoveryParam x y r = fromIntegral $- fromEnum (odd y) .|. if x /= r then 2 else 0- trySign k = do- (kpX, kpY) <- case pointMul curve k g of- PointO -> Nothing- Point x y -> return (x, y)- let r = kpX `mod` n- kInv <- inverse k n- let s = kInv * (z + r * d) `mod` n- when (r == 0 || s == 0) Nothing- -- Recovery param- let v = recoveryParam kpX kpY r- -- Use complement of s if it > n / 2- let (s', v') | s > n `div` 2 = (n - s, v `xor` 1)- | otherwise = (s, v)- return $ (r, s', v' + 27)---- | Unpack recoverable signature from byte array.------ Input array should have 65 byte length.-unpack :: ByteArrayAccess rsv => rsv -> (Integer, Integer, Word8)-unpack vrs = (r, s, v)- where- r = os2ip (view vrs 1 33)- s = os2ip (view vrs 33 65)- v = head (BA.unpack vrs)---- | Pack recoverable signature as byte array (65 byte length).-pack :: ByteArray rsv => (Integer, Integer, Word8) -> rsv-pack (r, s, v) = i2osp r <> i2osp s <> singleton v
@@ -1,45 +0,0 @@--- |--- Module : Crypto.Ecdsa.Utils--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ ECDSA module helper functions.-----module Crypto.Ecdsa.Utils where--import Crypto.Number.Serialize (i2osp, os2ip)-import Crypto.PubKey.ECC.ECDSA (PrivateKey (..), PublicKey (..))-import Crypto.PubKey.ECC.Generate (generateQ)-import Crypto.PubKey.ECC.Types (CurveName (SEC_p256k1), Point (..),- getCurveByName)-import Data.ByteArray (ByteArray, ByteArrayAccess)---- | Import ECDSA private key from byte array.------ Input array should have 32 byte length.-importKey :: ByteArrayAccess privateKey => privateKey -> PrivateKey-{-# INLINE importKey #-}-importKey = PrivateKey (getCurveByName SEC_p256k1) . os2ip---- | Export private key to byte array (32 byte length).-exportKey :: ByteArray privateKey => PrivateKey -> privateKey-{-# INLINE exportKey #-}-exportKey (PrivateKey _ key) = i2osp key---- | Get public key appropriate to private key.------ /WARNING:/ Vulnerable to timing attacks.-derivePubKey :: PrivateKey -> PublicKey-{-# INLINE derivePubKey #-}-derivePubKey (PrivateKey curve p) = PublicKey curve (generateQ curve p)---- | Export public key to byte array (64 byte length).-exportPubKey :: ByteArray publicKey => PublicKey -> publicKey-{-# INLINE exportPubKey #-}-exportPubKey (PublicKey _ (Point x y)) = i2osp x <> i2osp y-exportPubKey (PublicKey _ PointO) = mempty
@@ -1,31 +0,0 @@--- |--- Module : Crypto.Ethereum--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum cryptography primitives.-----module Crypto.Ethereum- (- -- * ECDSA crypto key ops- PrivateKey- , PublicKey- , importKey- , derivePubKey-- -- * Digital Signature Algorithm- , signMessage-- -- * Hash function- , keccak256- ) where--import Crypto.Ecdsa.Utils (derivePubKey, importKey)-import Crypto.Ethereum.Signature (signMessage)-import Crypto.Ethereum.Utils (keccak256)-import Crypto.PubKey.ECC.ECDSA (PrivateKey, PublicKey)
@@ -1,236 +0,0 @@-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}--- |--- Module : Crypto.Ethereum.Keyfile--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Ethereum Secret Storage implementation.--- Spec https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition.-----module Crypto.Ethereum.Keyfile- (- -- * Encrypted Ethereum private key- EncryptedKey(..)- , Cipher(..)- , Kdf(..)-- -- * Secret storage packers- , decrypt- , encrypt- ) where--import Crypto.Cipher.AES (AES128)-import Crypto.Cipher.Types (IV, cipherInit, ctrCombine, makeIV)-import Crypto.Error (throwCryptoError)-import qualified Crypto.KDF.PBKDF2 as Pbkdf2 (Parameters (..),- fastPBKDF2_SHA256)-import qualified Crypto.KDF.Scrypt as Scrypt (Parameters (..), generate)-import Crypto.Random (MonadRandom (getRandomBytes))-import Data.Aeson (FromJSON (..), ToJSON (..), Value,- object, withObject, (.:), (.=))-import Data.Aeson.Types (Parser)-import Data.ByteArray (ByteArray, ByteArrayAccess, convert)-import qualified Data.ByteArray as BA (drop, take, unpack)-import Data.Maybe (fromJust)-import Data.Text (Text)-import Data.UUID.Types (UUID)-import Data.UUID.Types.Internal (buildFromBytes)--import Crypto.Ethereum.Utils (keccak256)-import Data.ByteArray.HexString (HexString)---- | Key derivation function parameters and salt.-data Kdf = Pbkdf2 !Pbkdf2.Parameters !HexString- | Scrypt !Scrypt.Parameters !HexString---- | Cipher parameters.-data Cipher = Aes128Ctr- { cipherIv :: !(IV AES128)- , cipherText :: !HexString- }---- | Secret Storage representation on memory.-data EncryptedKey = EncryptedKey- { encryptedKeyId :: !UUID- -- ^ Random key ID- , encryptedKeyVersion :: !Int- -- ^ Version (suppoted version 3 only)- , encryptedKeyCipher :: !Cipher- -- ^ Cipher (supported AES-128-CTR only)- , encryptedKeyKdf :: !Kdf- -- ^ Key derivation function- , encryptedKeyMac :: !HexString- -- ^ MAC- }--instance Eq EncryptedKey where- a == b = encryptedKeyId a == encryptedKeyId b--instance Show EncryptedKey where- show EncryptedKey{..} = "EncryptedKey " ++ show encryptedKeyId--instance FromJSON EncryptedKey where- parseJSON = encryptedKeyParser--instance ToJSON EncryptedKey where- toJSON = encryptedKeyBuilder--encryptedKeyBuilder :: EncryptedKey -> Value-encryptedKeyBuilder EncryptedKey{..} = object- [ "id" .= encryptedKeyId- , "version" .= encryptedKeyVersion- , "crypto" .= object- [ "cipher" .= cipherName encryptedKeyCipher- , "cipherparams" .= cipherParams encryptedKeyCipher- , "ciphertext" .= cipherText encryptedKeyCipher- , "kdf" .= kdfName encryptedKeyKdf- , "kdfparams" .= kdfParams encryptedKeyKdf- , "mac" .= encryptedKeyMac- ]- ]- where- cipherName :: Cipher -> Text- cipherName Aes128Ctr{..} = "aes-128-ctr"-- cipherParams :: Cipher -> Value- cipherParams Aes128Ctr{..} = object [ "iv" .= (convert cipherIv :: HexString) ]-- kdfName :: Kdf -> Text- kdfName = \case- Pbkdf2 _ _ -> "pbkdf2"- Scrypt _ _ -> "scrypt"-- kdfParams :: Kdf -> Value- kdfParams = \case- Pbkdf2 params salt ->- object [ "salt" .= salt- , "dklen" .= Pbkdf2.outputLength params- , "c" .= Pbkdf2.iterCounts params- ]- Scrypt params salt ->- object [ "salt" .= salt- , "dklen" .= Scrypt.outputLength params- , "p" .= Scrypt.p params- , "r" .= Scrypt.r params- , "n" .= Scrypt.n params- ]--encryptedKeyParser :: Value -> Parser EncryptedKey-encryptedKeyParser = withObject "EncryptedKey" $ \v -> do- uuid <- v .: "id"- version <- v .: "version"- crypto <- v .: "crypto"- cipher <- parseCipher crypto- kdf <- parseKdf crypto- mac <- withObject "Crypto" (.: "mac") crypto- return $ EncryptedKey uuid version cipher kdf mac--parseCipher :: Value -> Parser Cipher-parseCipher = withObject "Cipher" $ \v -> do- name <- v .: "cipher"- case name :: Text of- "aes-128-ctr" -> do- params <- v .: "cipherparams"- hexiv <- params .: "iv"- text <- v .: "ciphertext"- case makeIV (hexiv :: HexString) of- Just iv -> return (Aes128Ctr iv text)- Nothing -> fail $ "Unable to make IV from " ++ show hexiv- _ -> fail $ show name ++ " not implemented yet"--parseKdf :: Value -> Parser Kdf-parseKdf = withObject "Kdf" $ \v -> do- name <- v .: "kdf"- params <- v .: "kdfparams"- dklen <- params .: "dklen"- salt <- params .: "salt"- case name :: Text of- "pbkdf2" -> do- iterations <- params .: "c"- prf <- params .: "prf"- case prf :: Text of- "hmac-sha256" -> return $ Pbkdf2 (Pbkdf2.Parameters iterations dklen) salt- _ -> fail $ show prf ++ " not implemented yet"- "scrypt" -> do- p <- params .: "p"- r <- params .: "r"- n <- params .: "n"- return $ Scrypt (Scrypt.Parameters n r p dklen) salt- _ -> fail $ show name ++ " not implemented yet"--defaultKdf :: HexString -> Kdf-defaultKdf = Scrypt (Scrypt.Parameters n r p dklen)- where- dklen = 32- n = 262144- r = 1- p = 8--deriveKey :: (ByteArrayAccess password, ByteArray ba) => Kdf -> password -> ba-deriveKey kdf password =- case kdf of- Pbkdf2 params salt -> Pbkdf2.fastPBKDF2_SHA256 params password salt- Scrypt params salt -> Scrypt.generate params password salt----- | Decrypt Ethereum private key.------ Typically Web3 Secret Storage is JSON-encoded. 'EncryptedKey' data type has 'FromJSON' instance--- to helps decode it from JSON-encoded string or file.------ @--- let decryptJSON pass = flip decrypt pass <=< decode--- @----decrypt :: (ByteArrayAccess password, ByteArray privateKey)- => EncryptedKey- -> password- -> Maybe privateKey-decrypt EncryptedKey{..} password- | mac == encryptedKeyMac = Just (convert privateKey)- | otherwise = Nothing- where- privateKey = ctrCombine cipher iv ciphertext- cipher = throwCryptoError $ cipherInit (BA.take 16 derivedKey) :: AES128- derivedKey = deriveKey encryptedKeyKdf password- ciphertext = cipherText encryptedKeyCipher- mac = keccak256 (BA.drop 16 derivedKey <> ciphertext)- iv = cipherIv encryptedKeyCipher---- | Encrypt Ethereum private key.------ @--- let encryptJSON pass key = encode <$> encrypt key pass--- @-encrypt :: (ByteArray privateKey, ByteArrayAccess password, MonadRandom m)- => privateKey- -> password- -> m EncryptedKey-encrypt privateKey password = do- kdf <- defaultKdf <$> getRandomBytes 16- iv <- randomIV- let derivedKey = deriveKey kdf password- cipher = throwCryptoError $ cipherInit (BA.take 16 derivedKey) :: AES128- ciphertext = ctrCombine cipher iv privateKey- mac = keccak256 (BA.drop 16 derivedKey <> ciphertext)- uuid <- randomUUID- return $ EncryptedKey uuid 3 (Aes128Ctr iv $ convert ciphertext) kdf mac- where- randomUUID = do- uuid <- getRandomBytes 16- let bs = BA.unpack (uuid :: HexString)- return $ buildFromBytes 4- (head bs) (bs !! 1) (bs !! 2) (bs !! 3)- (bs !! 4) (bs !! 5) (bs !! 6) (bs !! 7)- (bs !! 8) (bs !! 9) (bs !! 10) (bs !! 11)- (bs !! 12) (bs !! 13) (bs !! 14) (bs !! 15)- randomIV = do- iv <- getRandomBytes 16- return $ fromJust $ makeIV (iv :: HexString)
@@ -1,68 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Crypto.Ecdsa.Signature--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Recoverable Ethereum signature support.-----module Crypto.Ethereum.Signature- (- hashMessage- , signMessage- , signTransaction- ) where--import Crypto.Hash (Digest, Keccak_256 (..), hashWith)-import Crypto.PubKey.ECC.ECDSA (PrivateKey (..))-import Data.ByteArray (ByteArray, ByteArrayAccess, convert)-import qualified Data.ByteArray as BA (length)-import Data.ByteString.Builder (intDec, toLazyByteString)-import qualified Data.ByteString.Lazy as LBS (toStrict)-import Data.Word (Word8)--import Crypto.Ecdsa.Signature (pack, sign)---- | Make Ethereum standard signature.------ The message is before enveloped as follows:--- "\x19Ethereum Signed Message:\n" + message.length + message------ /WARNING:/ Vulnerable to timing attacks.-signMessage :: (ByteArrayAccess message, ByteArray rsv)- => PrivateKey- -> message- -> rsv-{-# INLINE signMessage #-}-signMessage pk = pack . sign pk . hashMessage---- | Ethereum standard hashed message.------ The data will be UTF-8 HEX decoded and enveloped as follows:--- "\x19Ethereum Signed Message:\n" + message.length + message and hashed using keccak256.-hashMessage :: ByteArrayAccess message => message -> Digest Keccak_256-hashMessage msg = hashWith Keccak_256 prefixed- where- len = LBS.toStrict . toLazyByteString . intDec . BA.length- prefixed = "\x19" <> "Ethereum Signed Message:\n" <> len msg <> convert msg---- | Sign Ethereum transaction.------ /WARNING:/ Vulnerable to timing attacks.-signTransaction :: ByteArray ba- => (Maybe (Integer, Integer, Word8) -> ba)- -- ^ Two way transaction packer (unsigned and signed)- -> PrivateKey- -- ^ Private key- -> ba- -- ^ Encoded transaction-signTransaction encode key = encode $ Just signed- where- unsigned = encode Nothing- signed = sign key (hashWith Keccak_256 unsigned)
@@ -1,21 +0,0 @@--- |--- Module : Crypto.Ethereum.Utils--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Ethereum crypto module helper functions.-----module Crypto.Ethereum.Utils where--import Crypto.Hash (Keccak_256 (..), hashWith)-import Data.ByteArray (ByteArray, ByteArrayAccess, convert)---- | Keccak 256 hash function.-keccak256 :: (ByteArrayAccess bin, ByteArray bout) => bin -> bout-{-# INLINE keccak256 #-}-keccak256 = convert . hashWith Keccak_256
@@ -1,67 +0,0 @@--- |--- Module : Crypto.Random.HmacDrbg--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ NIST standardized number-theoretically secure random number generator.--- https://csrc.nist.gov/csrc/media/events/random-number-generation-workshop-2004/documents/hashblockcipherdrbg.pdf------ XXX: This algorithm requires reseed after 2^48 iterations.------ > Inspired by https://github.com/TomMD/DRBG and https://github.com/indutny/hmac-drbg.-----module Crypto.Random.HmacDrbg- (- HmacDrbg- , initialize- ) where---import Crypto.Hash (HashAlgorithm, digestFromByteString,- hashDigestSize)-import Crypto.MAC.HMAC (HMAC (..), hmac)-import Crypto.Random (DRG (..))-import Data.ByteArray (ByteArray, convert, singleton)-import qualified Data.ByteArray as BA (null, take)-import qualified Data.ByteString as B (replicate)-import Data.Maybe (fromJust)-import Data.Word (Word8)---- | HMAC Deterministic Random Bytes Generator.-newtype HmacDrbg a = HmacDrbg (HMAC a, HMAC a)- deriving Eq--instance HashAlgorithm a => DRG (HmacDrbg a) where- randomBytesGenerate = generate--update :: (ByteArray bin, HashAlgorithm a)- => bin- -> HmacDrbg a- -> HmacDrbg a-update input | BA.null input = go 0x00- | otherwise = go 0x01 . go 0x00- where- go :: HashAlgorithm a => Word8 -> HmacDrbg a -> HmacDrbg a- go c (HmacDrbg (k, v)) = let k' = hmac k (convert v <> singleton c <> input)- v' = hmac k' v- in HmacDrbg (k', v')---- | Initialize HMAC-DRBG by seed.-initialize :: (ByteArray seed, HashAlgorithm a)- => seed- -> HmacDrbg a-initialize = flip update $ HmacDrbg (hmac0 undefined 0x00, hmac0 undefined 0x01)- where- hmac0 :: HashAlgorithm a => a -> Word8 -> HMAC a- hmac0 a = HMAC . fromJust . digestFromByteString . B.replicate (hashDigestSize a)--generate :: (HashAlgorithm a, ByteArray output) => Int -> HmacDrbg a -> (output, HmacDrbg a)-generate reqBytes (HmacDrbg (k, v)) = (output, HmacDrbg (k, vFinal))- where- getV (u, rest) = let v' = hmac k u in (v', rest <> convert v')- (vFinal, output) = BA.take reqBytes <$> iterate getV (v, mempty) !! reqBytes
@@ -1,67 +0,0 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Data.ByteArray.HexString--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Hex string data type and useful functions.-----module Data.ByteArray.HexString where--import Data.Aeson (FromJSON (..), ToJSON (..),- Value (String), withText)-import Data.ByteArray (ByteArray, ByteArrayAccess, convert)-import qualified Data.ByteArray as BA (drop, take)-import Data.ByteArray.Encoding (Base (Base16), convertFromBase,- convertToBase)-import Data.ByteString (ByteString)-import Data.String (IsString (..))-import Data.Text (Text)-import Data.Text.Encoding (decodeUtf8, encodeUtf8)---- | Represents a Hex string. Guarantees that all characters it contains--- are valid hex characters.-newtype HexString = HexString { unHexString :: ByteString }- deriving (Eq, Ord, Semigroup, Monoid, ByteArrayAccess, ByteArray)--instance Show HexString where- show = ("HexString " ++) . show . toText--instance IsString HexString where- fromString = hexString' . fromString- where- hexString' :: ByteString -> HexString- hexString' = either error id . hexString--instance FromJSON HexString where- parseJSON = withText "HexString" $ either fail pure . hexString . encodeUtf8--instance ToJSON HexString where- toJSON = String . toText---- | Smart constructor which trims '0x' and validates length is even.-hexString :: ByteArray ba => ba -> Either String HexString-hexString bs = HexString <$> convertFromBase Base16 bs'- where- hexStart = convert ("0x" :: ByteString)- bs' | BA.take 2 bs == hexStart = BA.drop 2 bs- | otherwise = bs---- | Reads a raw bytes and converts to hex representation.-fromBytes :: ByteArrayAccess ba => ba -> HexString-fromBytes = HexString . convert---- | Access to the raw bytes of 'HexString'.-toBytes :: ByteArray ba => HexString -> ba-toBytes = convert . unHexString---- | Access to a 'Text' representation of the 'HexString'-toText :: HexString -> Text-toText = ("0x" <>) . decodeUtf8 . convertToBase Base16 . unHexString
@@ -1,68 +0,0 @@-{-# LANGUAGE DefaultSignatures #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TypeFamilies #-}---- |--- Module : Data.Solidity.Abi--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ The Application Binary Interface is the standard way to interact with contracts--- in the Ethereum ecosystem, both from outside the blockchain and for contract-to-contract--- interaction. Data is encoded according to its type, as described in this specification.--- The encoding is not self describing and thus requires a schema in order to decode.-----module Data.Solidity.Abi where--import Data.Proxy (Proxy)-import Data.Serialize (Get, Putter)-import Generics.SOP (Generic, Rep, from, to)---- | A class for abi encoding datatype descriptions-class AbiType a where- isDynamic :: Proxy a -> Bool---- | A class for encoding datatypes to their abi encoding------ If your compiler has support for the @DeriveGeneric@ and--- @DefaultSignatures@ language extensions (@ghc >= 7.2.1@),--- the 'abiPut' method will have default generic implementations.------ To use this option, simply add a @deriving 'Generic'@ clause--- to your datatype and declare a 'AbiPut' instance for it without--- giving a definition for 'abiPut'.----class AbiType a => AbiPut a where- abiPut :: Putter a-- default abiPut :: (Generic a, Rep a ~ rep, GenericAbiPut rep) => Putter a- abiPut = gAbiPut . from---- | A class for encoding generically composed datatypes to their abi encoding-class GenericAbiPut a where- gAbiPut :: Putter a---- | A class for decoding datatypes from their abi encoding------ If your compiler has support for the @DeriveGeneric@ and--- @DefaultSignatures@ language extensions (@ghc >= 7.2.1@),--- the 'abiGet' method will have default generic implementations.------ To use this option, simply add a @deriving 'Generic'@ clause--- to your datatype and declare a 'AbiGet' instance for it without--- giving a definition for 'abiGet'.----class AbiType a => AbiGet a where- abiGet :: Get a-- default abiGet :: (Generic a, Rep a ~ rep, GenericAbiGet rep) => Get a- abiGet = to <$> gAbiGet---- | A class for decoding generically composed datatypes from their abi encoding-class GenericAbiGet a where- gAbiGet :: Get a
@@ -1,67 +0,0 @@-{-# LANGUAGE TypeFamilies #-}---- |--- Module : Data.Solidity.Abi.Codec--- Copyright : Alexander Krupenkin 2017-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Solidity contract ABI encoding functions.-----module Data.Solidity.Abi.Codec- (- -- * @AbiPut@/@AbiGet@ type class encoding- encode- , decode-- -- * Generic encoding- , encode'- , decode'- ) where--import Data.ByteArray (ByteArray, ByteArrayAccess, convert)-import Data.Serialize (runGet, runPut)-import Generics.SOP (Generic, Rep, from, to)--import Data.Solidity.Abi (AbiGet (..), AbiPut (..),- GenericAbiGet (..),- GenericAbiPut (..))-import Data.Solidity.Abi.Generic ()---- | Encode datatype to Ethereum Abi-encoding-encode :: (AbiPut a, ByteArray ba)- => a- -> ba-{-# INLINE encode #-}-encode = convert . runPut . abiPut---- | Generic driven version of 'encode'-encode' :: (Generic a,- Rep a ~ rep,- GenericAbiPut rep,- ByteArray ba)- => a- -> ba-{-# INLINE encode' #-}-encode' = convert . runPut . gAbiPut . from---- | Decode datatype from Ethereum Abi-encoding-decode :: (ByteArrayAccess ba, AbiGet a)- => ba- -> Either String a-{-# INLINE decode #-}-decode = runGet abiGet . convert---- | Generic driven version of 'decode'-decode' :: (Generic a,- Rep a ~ rep,- GenericAbiGet rep,- ByteArrayAccess ba)- => ba- -> Either String a-{-# INLINE decode' #-}-decode' = runGet (to <$> gAbiGet) . convert
@@ -1,122 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeInType #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Data.Solidity.Abi.Generic--- Copyright : Alexander Krupenkin 2017-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ This module is internal, the purpose is to define helper classes and functions--- to assist in encoding and decoding Solidity types for function calls and events.--- The user of this library should have no need to use this directly in application code.-----module Data.Solidity.Abi.Generic () where--import qualified Data.ByteString.Lazy as LBS-import Data.Int (Int64)-import qualified Data.List as L-import Data.Proxy (Proxy (..))-import Data.Serialize (Get, Put)-import Data.Serialize.Get (bytesRead, lookAheadE, skip)-import Data.Serialize.Put (runPutLazy)-import Generics.SOP (I (..), NP (..), NS (..), SOP (..))--import Data.Solidity.Abi (AbiGet (..), AbiPut (..), AbiType (..),- GenericAbiGet (..), GenericAbiPut (..))-import Data.Solidity.Prim.Int (getWord256, putWord256)--data EncodedValue = EncodedValue- { order :: Int64- , offset :: Maybe Int64- , encoding :: Put- }--instance Eq EncodedValue where- ev1 == ev2 = order ev1 == order ev2--instance Ord EncodedValue where- compare ev1 ev2 = order ev1 `compare` order ev2--combineEncodedValues :: [EncodedValue] -> Put-combineEncodedValues encodings =- let sortedEs = adjust headsOffset $ L.sort encodings- encodings' = addTailOffsets headsOffset [] sortedEs- in let heads = foldl (\acc EncodedValue{..} -> case offset of- Nothing -> acc <> encoding- Just o -> acc <> putWord256 (fromIntegral o)- ) mempty encodings'- tails = foldl (\acc EncodedValue{..} -> case offset of- Nothing -> acc- Just _ -> acc <> encoding- ) mempty encodings'- in heads <> tails- where- adjust :: Int64 -> [EncodedValue] -> [EncodedValue]- adjust n = map (\ev -> ev {offset = (+) n <$> offset ev})- addTailOffsets :: Int64 -> [EncodedValue] -> [EncodedValue] -> [EncodedValue]- addTailOffsets init' acc es = case es of- [] -> reverse acc- (e : tail') -> case offset e of- Nothing -> addTailOffsets init' (e : acc) tail'- Just _ -> addTailOffsets init' (e : acc) (adjust (LBS.length . runPutLazy . encoding $ e) tail')- headsOffset :: Int64- headsOffset = foldl (\acc e -> case offset e of- Nothing -> acc + (LBS.length . runPutLazy . encoding $ e)- Just _ -> acc + 32- ) 0 encodings--class AbiData a where- _serialize :: [EncodedValue] -> a -> [EncodedValue]--instance AbiData (NP f '[]) where- _serialize encoded _ = encoded--instance (AbiType b, AbiPut b, AbiData (NP I as)) => AbiData (NP I (b :as)) where- _serialize encoded (I b :* a) =- if isDynamic (Proxy :: Proxy b)- then _serialize (dynEncoding : encoded) a- else _serialize (staticEncoding : encoded) a- where- staticEncoding = EncodedValue { encoding = abiPut b- , offset = Nothing- , order = 1 + (fromInteger . toInteger . L.length $ encoded)- }- dynEncoding = EncodedValue { encoding = abiPut b- , offset = Just 0- , order = 1 + (fromInteger . toInteger . L.length $ encoded)- }--instance AbiData (NP f as) => GenericAbiPut (SOP f '[as]) where- gAbiPut (SOP (Z a)) = combineEncodedValues $ _serialize [] a- gAbiPut _ = error "Impossible branch"--instance GenericAbiGet (NP f '[]) where- gAbiGet = return Nil--instance (AbiGet a, GenericAbiGet (NP I as)) => GenericAbiGet (NP I (a : as)) where- gAbiGet = (:*) <$> (I <$> factorParser) <*> gAbiGet--instance GenericAbiGet (NP f as) => GenericAbiGet (SOP f '[as]) where- gAbiGet = SOP . Z <$> gAbiGet--factorParser :: forall a . AbiGet a => Get a-factorParser- | not $ isDynamic (Proxy :: Proxy a) = abiGet- | otherwise = do- dataOffset <- fromIntegral <$> getWord256- currentOffset <- bytesRead- Left x <- lookAheadE $ do- skip (dataOffset - currentOffset)- Left <$> abiGet- return x
@@ -1,141 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE PolyKinds #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE UndecidableInstances #-}---- |--- Module : Data.Solidity.Event--- Copyright : Alexander Krupenkin 2017-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ This module is internal, the purpose is to define--- helper classes and functions to assist in event decoding.--- The user of this library should have no need to use--- this directly in application code.-----module Data.Solidity.Event- (- DecodeEvent(..)- , IndexedEvent(..)- ) where--import Data.ByteArray (ByteArrayAccess)-import Data.Proxy (Proxy (..))-import Generics.SOP (Generic, I (..), NP (..),- NS (..), Rep, SOP (..), from, to)--import Data.Solidity.Abi (AbiGet)-import Data.Solidity.Abi.Codec (decode)-import Data.Solidity.Event.Internal-import Network.Ethereum.Api.Types (Change (..))---- | Indexed event args come back in as a list of encoded values. 'ArrayParser'--- | is used to decode these values so that they can be used to reconstruct the--- | entire decoded event.-class ArrayParser a where- arrayParser :: ByteArrayAccess ba- => [ba]- -> Either String a--instance ArrayParser (NP f '[]) where- arrayParser _ = Right Nil--instance (ArrayParser (NP I as), AbiGet a)- => ArrayParser (NP I (a : as)) where- arrayParser [] = Left "Empty"- arrayParser (a : as) = do- a' <- decode a- as' <- arrayParser as- return $ I a' :* as'--instance ArrayParser (NP f as) => ArrayParser (SOP f '[as]) where- arrayParser = fmap (SOP . Z) . arrayParser--genericArrayParser :: ( Generic a- , Rep a ~ rep- , ArrayParser rep- , ByteArrayAccess ba- )- => [ba]- -> Either String a-genericArrayParser = fmap to . arrayParser------------------------------------------------------------------------------------- Event Parsing-----------------------------------------------------------------------------------data Event i ni = Event i ni---- | 'parseChange' decodes both the indexed and non-indexed event components.-parseChange :: ( Generic i- , Rep i ~ irep- , ArrayParser irep- , AbiGet ni- )- => Change- -> Bool- -- ^ is anonymous event- -> Either String (Event i ni)-parseChange change anonymous =- Event <$> genericArrayParser topics <*> decode data_- where- topics | anonymous = changeTopics change- | otherwise = tail (changeTopics change)- data_ = changeData change--class IndexedEvent i ni e | e -> i ni where- isAnonymous :: Proxy e -> Bool---- | 'CombineChange' is a class which indicates that given event components of types 'i'--- | and 'ni', we can construct an event of type 'e'. The functional dependency is valid--- | becasue of how the template haskell generates the event types.-class CombineChange i ni e | e -> i ni where- combineChange :: i -> ni -> e--instance ( Generic i- , Rep i ~ irep- , Generic ni- , Rep ni ~ nirep- , Generic e- , Rep e ~ erep- , HListRep irep hli- , HListRep nirep hlni- , MergeIndexedArguments hli hlni- , MergeIndexedArguments' hli hlni ~ hle- , HListRep erep hle- , IndexedEvent i ni e- ) => CombineChange i ni e where- combineChange i ni =- let hli = toHList . from $ i- hlni = toHList . from $ ni- hle = mergeIndexedArguments hli hlni- in to . fromHList $ hle--class DecodeEvent i ni e | e -> i ni where- decodeEvent :: Change -> Either String e--instance ( IndexedEvent i ni e- , Generic i- , Rep i ~ SOP I '[hli]- , AbiGet ni- , Generic ni- , Rep ni ~ SOP I '[hlni]- , Generic e- , Rep e ~ SOP I '[hle]- , CombineChange i ni e- , ArrayParser (SOP I '[hli])- ) => DecodeEvent i ni e where- decodeEvent change = do- let anonymous = isAnonymous (Proxy :: Proxy e)- (Event i ni :: Event i ni) <- parseChange change anonymous- return $ combineChange i ni
@@ -1,135 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE PolyKinds #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeInType #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE UndecidableInstances #-}---- |--- Module : Data.Solidity.Event.Internal--- Copyright : Alexander Krupenkin 2017-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ This module is internal, the purpose is to define helper classes and types--- to assist in event decoding. The user of this library should have no need to use--- this directly in application code.-----module Data.Solidity.Event.Internal where--import Data.Kind (Type)-import Data.Proxy (Proxy (..))-import Data.Tagged (Tagged (..))-import Generics.SOP (I (..), NP (..), NS (..), SOP (..))-import GHC.TypeLits (CmpNat)--data HList :: [Type] -> Type where- HNil :: HList '[]- (:<) :: a -> HList as -> HList (a : as)--infixr 0 :<---- | Generic representation to HList representation-class HListRep a xs | a -> xs, a -> xs where- toHList :: a -> HList xs- fromHList :: HList xs -> a--instance HListRep (NP I '[]) '[] where- toHList _ = HNil- fromHList _ = Nil--instance HListRep (NP I as) as => HListRep (NP I (a:as)) (a:as) where- toHList (I a :* rest) = a :< toHList rest- fromHList (a :< rest) = I a :* fromHList rest--instance HListRep (NP f as') as => HListRep (SOP f '[as']) as where- toHList (SOP (Z rep)) = toHList rep- toHList _ = error "Impossible branch"- fromHList = SOP . Z . fromHList---- | Sort a Tagged HList-class Sort (xs :: [Type]) where- type Sort' xs :: [Type]- sort :: HList xs -> HList (Sort' xs)--instance Sort '[] where- type Sort' '[] = '[]- sort HNil = HNil--instance (Sort xs, Insert x (Sort' xs)) => Sort (x : xs) where- type Sort' (x : xs) = Insert' x (Sort' xs)- sort (x :< xs) = insert x (sort xs)--class Insert (x :: Type) (xs :: [Type]) where- type Insert' x xs :: [Type]- insert :: x -> HList xs -> HList (Insert' x xs)--instance Insert x '[] where- type Insert' x '[] = '[x]- insert x HNil = x :< HNil--instance InsertCmp (CmpNat n m) (Tagged n x) (Tagged m y) ys => Insert (Tagged n x) (Tagged m y : ys) where- type Insert' (Tagged n x) (Tagged m y : ys) = InsertCmp' (CmpNat n m) (Tagged n x) (Tagged m y) ys- insert (x :: Tagged n x) ((y :: Tagged m y) :< ys) = insertCmp (Proxy :: Proxy (CmpNat n m)) x y ys--class InsertCmp (b :: Ordering) (x :: Type) (y :: Type) (ys :: [Type]) where- type InsertCmp' b x y ys :: [Type]- insertCmp :: Proxy (b :: Ordering) -> x -> y -> HList ys -> HList (InsertCmp' b x y ys)--instance InsertCmp 'LT x y ys where- type InsertCmp' 'LT x y ys = x : (y : ys)- insertCmp _ x y ys = x :< y :< ys--instance Insert x ys => InsertCmp 'GT x y ys where- type InsertCmp' 'GT x y ys = y : Insert' x ys- insertCmp _ x y ys = y :< insert x ys---- | Unwrap all the Tagged items in an HList-class UnTag t where- type UnTag' t :: [Type]- unTag :: HList t -> HList (UnTag' t)--instance UnTag '[] where- type UnTag' '[] = '[]- unTag a = a--instance UnTag ts => UnTag (Tagged n a : ts) where- type UnTag' (Tagged n a : ts) = a : UnTag' ts- unTag (Tagged a :< ts) = a :< unTag ts--class HListMerge (as :: [Type]) (bs :: [Type]) where- type Concat as bs :: [Type]- mergeHList :: HList as -> HList bs -> HList (Concat as bs)--instance HListMerge '[] bs where- type Concat '[] bs = bs- mergeHList _ bs = bs--instance HListMerge as bs => HListMerge (a : as) bs where- type Concat (a : as) bs = a : Concat as bs- mergeHList (a :< as) bs = a :< mergeHList as bs--class HListMergeSort as bs where- type MergeSort' as bs :: [Type]- mergeSortHList :: HList as -> HList bs -> HList (MergeSort' as bs)--instance (HListMerge as bs, Concat as bs ~ cs, Sort cs, Sort' cs ~ cs') => HListMergeSort as bs where- type MergeSort' as bs = Sort' (Concat as bs)- mergeSortHList as bs = sort $ (mergeHList as bs :: HList cs)--class MergeIndexedArguments as bs where- type MergeIndexedArguments' as bs :: [Type]- mergeIndexedArguments :: HList as -> HList bs -> HList (MergeIndexedArguments' as bs)--instance (HListMergeSort as bs, MergeSort' as bs ~ cs, UnTag cs, UnTag cs' ~ ds) => MergeIndexedArguments as bs where- type MergeIndexedArguments' as bs = (UnTag' (MergeSort' as bs))- mergeIndexedArguments as bs = unTag $ mergeSortHList as bs
@@ -1,30 +0,0 @@--- |--- Module : Data.Solidity.Prim--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Solidity primitive data types.-----module Data.Solidity.Prim- (- Address- , Bytes- , BytesN- , IntN- , UIntN- , ListN- ) where--import Data.Solidity.Prim.Address (Address)-import Data.Solidity.Prim.Bool ()-import Data.Solidity.Prim.Bytes (Bytes, BytesN)-import Data.Solidity.Prim.Int (IntN, UIntN)-import Data.Solidity.Prim.List (ListN)-import Data.Solidity.Prim.String ()-import Data.Solidity.Prim.Tagged ()-import Data.Solidity.Prim.Tuple ()
@@ -1,123 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Data.Solidity.Prim.Address--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Ethreum account address.-----module Data.Solidity.Prim.Address- (- -- * The @Address@ type- Address-- -- * Hex string encoding- , toHexString- , fromHexString-- -- * Derive address from public key- , fromPubKey-- -- * EIP55 Mix-case checksum address encoding- , toChecksum- , verifyChecksum- ) where--import Control.Monad ((<=<))-import Crypto.PubKey.ECC.ECDSA (PublicKey)-import Data.Aeson (FromJSON (..), ToJSON (..))-import Data.Bits ((.&.))-import Data.Bool (bool)-import Data.ByteArray (zero)-import qualified Data.ByteArray as BA (drop)-import Data.ByteString (ByteString)-import qualified Data.ByteString as BS (take, unpack)-import qualified Data.ByteString.Char8 as C8 (drop, length, pack, unpack)-import qualified Data.Char as C (toLower, toUpper)-import Data.Default (Default (..))-import Data.String (IsString (..))-import Data.Text.Encoding as T (encodeUtf8)-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)--import Crypto.Ecdsa.Utils (exportPubKey)-import Crypto.Ethereum.Utils (keccak256)-import Data.ByteArray.HexString (HexString, fromBytes, toBytes,- toText)-import Data.Solidity.Abi (AbiGet (..), AbiPut (..),- AbiType (..))-import Data.Solidity.Abi.Codec (decode, encode)-import Data.Solidity.Prim.Int (UIntN)---- | Ethereum account address-newtype Address = Address { unAddress :: UIntN 160 }- deriving (Eq, Ord, GHC.Generic)--instance Generic Address--instance Default Address where- def = Address 0--instance Show Address where- show = show . toChecksum . T.encodeUtf8 . toText . toHexString--instance IsString Address where- fromString = either error id . fromHexString . fromString--instance AbiType Address where- isDynamic _ = False--instance AbiGet Address where- abiGet = Address <$> abiGet--instance AbiPut Address where- abiPut = abiPut . unAddress--instance FromJSON Address where- parseJSON = (either fail pure . fromHexString) <=< parseJSON--instance ToJSON Address where- toJSON = toJSON . toHexString---- | Derive address from secp256k1 public key-fromPubKey :: PublicKey -> Address-fromPubKey key =- case decode $ zero 12 <> toAddress (exportPubKey key) of- Right a -> a- Left e -> error $ "Impossible error: " ++ e- where- toAddress :: HexString -> HexString- toAddress = BA.drop 12 . keccak256---- | Decode address from hex string-fromHexString :: HexString -> Either String Address-fromHexString bs- | bslen == 20 = decode (zero 12 <> toBytes bs :: ByteString)- | otherwise = Left $ "Incorrect address length: " ++ show bslen- where bslen = C8.length (toBytes bs)---- | Encode address to hex string-toHexString :: Address -> HexString-toHexString = fromBytes . C8.drop 12 . encode---- | Encode address with mixed-case checksum--- https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md-toChecksum :: ByteString -> ByteString-toChecksum addr = ("0x" <>) . C8.pack $ zipWith ($) upcaseVector lower- where- upcaseVector = (>>= fourthBits) . BS.unpack . BS.take 20 $ keccak256 (C8.pack lower)- fourthBits n = bool id C.toUpper <$> [n .&. 0x80 /= 0, n .&. 0x08 /= 0]- lower = drop 2 . fmap C.toLower . C8.unpack $ addr---- | Verify mixed-case address checksum--- https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md-verifyChecksum :: ByteString -> Bool-verifyChecksum = toChecksum >>= (==)
@@ -1,25 +0,0 @@--- |--- Module : Data.Solidity.Prim.Bool--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Ethereum Abi boolean type.-----module Data.Solidity.Prim.Bool () where--import Data.Solidity.Abi (AbiGet (..), AbiPut (..), AbiType (..))-import Data.Solidity.Prim.Int (getWord256, putWord256)--instance AbiType Bool where- isDynamic _ = False--instance AbiGet Bool where- abiGet = toEnum . fromIntegral <$> getWord256--instance AbiPut Bool where- abiPut = putWord256 . fromIntegral . fromEnum
@@ -1,125 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Data.Solidity.Prim.Bytes--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Bytes and BytesN primitive types.-----module Data.Solidity.Prim.Bytes- (- -- * The dynamic length @Bytes@ type- Bytes-- -- * The fixed length @BytesN@ type- , BytesN- ) where--import Control.Monad (unless)-import Data.Aeson (FromJSON (..), ToJSON (..),- Value (String))-import Data.ByteArray (Bytes, convert, length, zero)-import Data.ByteArray.Encoding (Base (Base16), convertFromBase,- convertToBase)-import Data.ByteArray.Sized (SizedByteArray, unSizedByteArray,- unsafeFromByteArrayAccess)-import qualified Data.ByteArray.Sized as S (take)-import Data.ByteString (ByteString)-import qualified Data.ByteString.Char8 as C8-import Data.Proxy (Proxy (..))-import Data.Serialize (Get, Putter, getBytes, putByteString)-import Data.String (IsString (..))-import qualified Data.Text as T (append, drop, take)-import Data.Text.Encoding (decodeUtf8, encodeUtf8)-import GHC.TypeLits-import Prelude hiding (length)--import Data.Solidity.Abi (AbiGet (..), AbiPut (..),- AbiType (..))-import Data.Solidity.Prim.Int (getWord256, putWord256)--instance AbiType ByteString where- isDynamic _ = True--instance AbiGet ByteString where- abiGet = abiGetByteString--instance AbiPut ByteString where- abiPut = abiPutByteString--instance AbiType Bytes where- isDynamic _ = True--instance AbiGet Bytes where- abiGet = convert <$> abiGetByteString--instance AbiPut Bytes where- abiPut = abiPutByteString . convert--instance IsString Bytes where- fromString ('0' : 'x' : hex) = either error id $ convertFromBase Base16 (C8.pack hex)- fromString str = convert (C8.pack str)--instance FromJSON Bytes where- parseJSON (String hex)- | T.take 2 hex == "0x" =- either fail pure $ convertFromBase Base16 $ encodeUtf8 $ T.drop 2 hex- | otherwise = fail "Hex string should have '0x' prefix"- parseJSON _ = fail "Bytes should be encoded as hex string"--instance ToJSON Bytes where- toJSON = toJSON . T.append "0x" . decodeUtf8 . convertToBase Base16---- | Sized byte array with fixed length in bytes-type BytesN n = SizedByteArray n Bytes--instance (n <= 32) => AbiType (BytesN n) where- isDynamic _ = False--instance (KnownNat n, n <= 32) => AbiGet (BytesN n) where- abiGet = do- ba <- unsafeFromByteArrayAccess <$> getBytes 32- return $ S.take (ba :: BytesN 32)--instance (KnownNat n, n <= 32) => AbiPut (BytesN n) where- abiPut ba = putByteString $ convert ba <> zero (32 - len)- where len = fromIntegral $ natVal (Proxy :: Proxy n)--instance (KnownNat n, n <= 32) => IsString (BytesN n) where- fromString s = unsafeFromByteArrayAccess padded- where bytes = fromString s :: Bytes- len = fromIntegral $ natVal (Proxy :: Proxy n)- padded = bytes <> zero (len - length bytes)--instance (KnownNat n, n <= 32) => FromJSON (BytesN n) where- parseJSON v = do ba <- parseJSON v- return $ unsafeFromByteArrayAccess (ba :: Bytes)--instance (KnownNat n, n <= 32) => ToJSON (BytesN n) where- toJSON ba = toJSON (unSizedByteArray ba :: Bytes)--abiGetByteString :: Get ByteString-abiGetByteString = do- len <- fromIntegral <$> getWord256- if len == 0- then return ""- else getBytes len--abiPutByteString :: Putter ByteString-abiPutByteString bs = do- putWord256 $ fromIntegral len- unless (len == 0) $- putByteString $ bs <> zero (32 - len `mod` 32)- where len = length bs
@@ -1,140 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Data.Solidity.Prim.Int--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Ethereum Abi intN and uintN types.-----module Data.Solidity.Prim.Int- (- -- * The @IntN@ type- IntN-- -- * The @UIntN@ type- , UIntN-- -- * @Word256@ serializers- , getWord256- , putWord256- ) where--import qualified Basement.Numerical.Number as Basement (toInteger)-import Basement.Types.Word256 (Word256 (Word256))-import qualified Basement.Types.Word256 as Basement (quot, rem)-import Data.Bits (Bits (testBit), (.&.))-import Data.Proxy (Proxy (..))-import Data.Serialize (Get, Putter, Serialize (get, put))-import GHC.Generics (Generic)-import GHC.TypeLits--import Data.Solidity.Abi (AbiGet (..), AbiPut (..),- AbiType (..))--instance Real Word256 where- toRational = toRational . toInteger--instance Integral Word256 where- toInteger = Basement.toInteger- quotRem a b = (Basement.quot a b, Basement.rem a b)---- | Unsigned integer with fixed length in bits.-newtype UIntN (n :: Nat) = UIntN { unUIntN :: Word256 }- deriving (Eq, Ord, Enum, Bits, Generic)--instance (KnownNat n, n <= 256) => Num (UIntN n) where- a + b = fromInteger (toInteger a + toInteger b)- a - b = fromInteger (toInteger a - toInteger b)- a * b = fromInteger (toInteger a * toInteger b)- abs = fromInteger . abs . toInteger- negate = fromInteger . negate . toInteger- signum = fromInteger . signum . toInteger- fromInteger x- | x >= 0 = mask $ UIntN (fromInteger x)- | otherwise = mask $ UIntN (fromInteger $ 2 ^ 256 + x)- where- mask = (maxBound .&.) :: UIntN n -> UIntN n--instance (KnownNat n, n <= 256) => Show (UIntN n) where- show = show . unUIntN--instance (KnownNat n, n <= 256) => Bounded (UIntN n) where- minBound = UIntN 0- maxBound = UIntN $ 2 ^ natVal (Proxy :: Proxy n) - 1--instance (KnownNat n, n <= 256) => Real (UIntN n) where- toRational = toRational . toInteger--instance (KnownNat n, n <= 256) => Integral (UIntN n) where- toInteger = toInteger . unUIntN- quotRem (UIntN a) (UIntN b) = (UIntN $ quot a b, UIntN $ rem a b)--instance (n <= 256) => AbiType (UIntN n) where- isDynamic _ = False--instance (n <= 256) => AbiGet (UIntN n) where- abiGet = UIntN <$> getWord256--instance (n <= 256) => AbiPut (UIntN n) where- abiPut = putWord256 . unUIntN---- | Signed integer with fixed length in bits.-newtype IntN (n :: Nat) = IntN { unIntN :: Word256 }- deriving (Eq, Ord, Enum, Bits, Generic)--instance (KnownNat n, n <= 256) => Show (IntN n) where- show = show . toInteger--instance (KnownNat n, n <= 256) => Bounded (IntN n) where- minBound = IntN $ negate $ 2 ^ (natVal (Proxy :: Proxy (n :: Nat)) - 1)- maxBound = IntN $ 2 ^ (natVal (Proxy :: Proxy (n :: Nat)) - 1) - 1--instance (KnownNat n, n <= 256) => Num (IntN n) where- a + b = fromInteger (toInteger a + toInteger b)- a - b = fromInteger (toInteger a - toInteger b)- a * b = fromInteger (toInteger a * toInteger b)- abs = fromInteger . abs . toInteger- negate = fromInteger . negate . toInteger- signum = fromInteger . signum . toInteger- fromInteger x- | x >= 0 = IntN (fromInteger x)- | otherwise = IntN (fromInteger $ 2 ^ 256 + x)--instance (KnownNat n, n <= 256) => Real (IntN n) where- toRational = toRational . toInteger--instance (KnownNat n, n <= 256) => Integral (IntN n) where- quotRem (IntN a) (IntN b) = (IntN $ quot a b, IntN $ rem a b)- toInteger x- | testBit x 255 = toInteger (unIntN x) - 2 ^ 256- | otherwise = toInteger $ unIntN x--instance (n <= 256) => AbiType (IntN n) where- isDynamic _ = False--instance (n <= 256) => AbiGet (IntN n) where- abiGet = IntN <$> getWord256--instance (n <= 256) => AbiPut (IntN n) where- abiPut = putWord256 . unIntN---- | Serialize 256 bit unsigned integer.-putWord256 :: Putter Word256-putWord256 (Word256 a3 a2 a1 a0) =- put a3 >> put a2 >> put a1 >> put a0---- | Deserialize 256 bit unsigned integer.-getWord256 :: Get Word256-getWord256 = Word256 <$> get <*> get <*> get <*> get
@@ -1,56 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE UndecidableInstances #-}---- |--- Module : Data.Solidity.Prim.List--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Ethereum Abi dynamic and static size vectors based on linked lists.-----module Data.Solidity.Prim.List- (- -- * Fixed size linked list- ListN- ) where--import Basement.Nat (NatWithinBound)-import Basement.Sized.List (ListN, toListN_, unListN)-import qualified Basement.Sized.List as SL (mapM_, replicateM)-import Control.Monad (replicateM)-import GHC.Exts (IsList (..))-import GHC.TypeLits (KnownNat)--import Data.Solidity.Abi (AbiGet (..), AbiPut (..), AbiType (..))-import Data.Solidity.Prim.Int (getWord256, putWord256)--instance AbiType [a] where- isDynamic _ = True--instance AbiPut a => AbiPut [a] where- abiPut l = do putWord256 $ fromIntegral (length l)- foldMap abiPut l--instance AbiGet a => AbiGet [a] where- abiGet = do len <- fromIntegral <$> getWord256- replicateM len abiGet--instance AbiType (ListN n a) where- isDynamic _ = False--instance AbiPut a => AbiPut (ListN n a) where- abiPut = SL.mapM_ abiPut--instance (NatWithinBound Int n, KnownNat n, AbiGet a) => AbiGet (ListN n a) where- abiGet = SL.replicateM abiGet--instance (NatWithinBound Int n, KnownNat n) => IsList (ListN n a) where- type Item (ListN n a) = a- fromList = toListN_- toList = unListN
@@ -1,29 +0,0 @@--- |--- Module : Data.Solidity.Prim.String--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Ethereum Abi UTF8-encoded string type.-----module Data.Solidity.Prim.String where--import Data.Text (Text)-import Data.Text.Encoding (decodeUtf8, encodeUtf8)--import Data.Solidity.Abi (AbiGet (..), AbiPut (..),- AbiType (..))-import Data.Solidity.Prim.Bytes ()--instance AbiType Text where- isDynamic _ = True--instance AbiPut Text where- abiPut = abiPut . encodeUtf8--instance AbiGet Text where- abiGet = decodeUtf8 <$> abiGet
@@ -1,37 +0,0 @@-{-# LANGUAGE PolyKinds #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Data.Solidity.Prim.Tagged--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Ethereum Abi tagged types.-----module Data.Solidity.Prim.Tagged- (- -- * The @Tagged@ type- Tagged- ) where--import Data.Proxy (Proxy (..))-import Data.Tagged (Tagged (..))-import Generics.SOP (Generic)--import Data.Solidity.Abi (AbiGet (..), AbiPut (..), AbiType (..))--instance AbiType a => AbiType (Tagged t a) where- isDynamic _ = isDynamic (Proxy :: Proxy a)--instance AbiPut a => AbiPut (Tagged t a) where- abiPut (Tagged a) = abiPut a--instance AbiGet a => AbiGet (Tagged t a) where- abiGet = Tagged <$> abiGet--instance Generic a => Generic (Tagged t a)
@@ -1,38 +0,0 @@-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE StandaloneDeriving #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Data.Solidity.Prim.Tuple--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ Tuple type abi encoding instances.-----module Data.Solidity.Prim.Tuple where--import Data.Proxy (Proxy (..))-import Data.Tuple.OneTuple (OneTuple (..))-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)--import Data.Solidity.Abi (AbiGet, AbiPut, AbiType (..))-import Data.Solidity.Abi.Generic ()-import Data.Solidity.Prim.Tuple.TH (tupleDecs)--deriving instance GHC.Generic (OneTuple a)-instance Generic (OneTuple a)--instance AbiType a => AbiType (OneTuple a) where- isDynamic _ = isDynamic (Proxy :: Proxy a)--instance AbiGet a => AbiGet (OneTuple a)-instance AbiPut a => AbiPut (OneTuple a)--$(concat <$> mapM tupleDecs [2..20])
@@ -1,34 +0,0 @@-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Data.Solidity.Prim.Tuple.TH--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ This module is for internal usage only.--- It contains tuple abi encoding template haskell generator.-----module Data.Solidity.Prim.Tuple.TH (tupleDecs) where---import Control.Monad (replicateM)-import Language.Haskell.TH (DecsQ, Type (VarT), appT, clause, conT,- cxt, funD, instanceD, newName, normalB,- tupleT)--import Data.Solidity.Abi (AbiGet, AbiPut, AbiType (..))--tupleDecs :: Int -> DecsQ-tupleDecs n = do- vars <- replicateM n $ newName "a"- let types = fmap (pure . VarT) vars- sequence $- [ instanceD (cxt $ map (appT $ conT ''AbiType) types) (appT (conT ''AbiType) (foldl appT (tupleT n) types))- [funD 'isDynamic [clause [] (normalB [|const False|]) []]]- , instanceD (cxt $ map (appT $ conT ''AbiGet) types) (appT (conT ''AbiGet) (foldl appT (tupleT n) types)) []- , instanceD (cxt $ map (appT $ conT ''AbiPut) types) (appT (conT ''AbiPut) (foldl appT (tupleT n) types)) [] ]
@@ -1,25 +0,0 @@--- |--- Module : Data.String.Extra--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Extra string manipulation functions.-----module Data.String.Extra where--import Data.Char (toLower, toUpper)---- | Lower first char of string-toLowerFirst :: String -> String-toLowerFirst [] = []-toLowerFirst (x : xs) = toLower x : xs---- | Upper first char of string-toUpperFirst :: String -> String-toUpperFirst [] = []-toUpperFirst (x : xs) = toUpper x : xs
@@ -1,310 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Data.Solidity.Abi.Json--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : noportable------ JSON encoded contract ABI parsers.-----module Language.Solidity.Abi- (- -- * Contract ABI declarations- ContractAbi(..)- , Declaration(..)- , FunctionArg(..)- , EventArg(..)-- -- * Method/Event id encoder- , signature- , methodId- , eventId-- -- * Solidity type parser- , SolidityType(..)- , parseSolidityFunctionArgType- , parseSolidityEventArgType- ) where--import Control.Monad (void)-import Crypto.Hash (Digest, Keccak_256, hash)-import Data.Aeson (FromJSON (parseJSON), Options (constructorTagModifier, fieldLabelModifier, sumEncoding),- SumEncoding (TaggedObject),- ToJSON (toJSON), defaultOptions)-import Data.Aeson.TH (deriveJSON)-import Data.Text (Text)-import qualified Data.Text as T (dropEnd, pack, take, unlines, unpack)-import Data.Text.Encoding (encodeUtf8)-import Text.Parsec (ParseError, char, choice, digit, eof,- lookAhead, many1, manyTill, optionMaybe,- parse, string, try, (<|>))-import Text.Parsec.Text (Parser)--import Data.String.Extra (toLowerFirst)---- | Method argument-data FunctionArg = FunctionArg- { funArgName :: Text- -- ^ Argument name- , funArgType :: Text- -- ^ Argument type- , funArgComponents :: Maybe [FunctionArg]- -- ^ Argument components for tuples- }- deriving (Show, Eq, Ord)--$(deriveJSON- (defaultOptions {fieldLabelModifier = toLowerFirst . drop 6})- ''FunctionArg)---- | Event argument-data EventArg = EventArg- { eveArgName :: Text- -- ^ Argument name- , eveArgType :: Text- -- ^ Argument type- , eveArgIndexed :: Bool- -- ^ Argument is indexed (e.g. placed on topics of event)- }- deriving (Show, Eq, Ord)--$(deriveJSON- (defaultOptions {fieldLabelModifier = toLowerFirst . drop 6})- ''EventArg)---- | Elementrary contract interface item-data Declaration = DConstructor- { conInputs :: [FunctionArg]- -- ^ Contract constructor- }- | DFunction- { funName :: Text- , funConstant :: Bool- , funInputs :: [FunctionArg]- , funOutputs :: Maybe [FunctionArg]- -- ^ Method- }- | DEvent- { eveName :: Text- , eveInputs :: [EventArg]- , eveAnonymous :: Bool- -- ^ Event- }- | DFallback- { falPayable :: Bool- -- ^ Fallback function- }- deriving Show--instance Eq Declaration where- (DConstructor a) == (DConstructor b) = length a == length b- (DFunction a _ _ _) == (DFunction b _ _ _) = a == b- (DEvent a _ _) == (DEvent b _ _) = a == b- (DFallback _) == (DFallback _) = True- (==) _ _ = False--instance Ord Declaration where- compare (DConstructor a) (DConstructor b) = compare (length a) (length b)- compare (DFunction a _ _ _) (DFunction b _ _ _) = compare a b- compare (DEvent a _ _) (DEvent b _ _) = compare a b- compare (DFallback _) (DFallback _) = EQ-- compare DConstructor {} DFunction {} = LT- compare DConstructor {} DEvent {} = LT- compare DConstructor {} DFallback {} = LT-- compare DFunction {} DConstructor {} = GT- compare DFunction {} DEvent {} = LT- compare DFunction {} DFallback {} = LT-- compare DEvent {} DConstructor {} = GT- compare DEvent {} DFunction {} = GT- compare DEvent {} DFallback {} = LT-- compare DFallback {} DConstructor {} = GT- compare DFallback {} DFunction {} = GT- compare DFallback {} DEvent {} = GT--$(deriveJSON (defaultOptions {- sumEncoding = TaggedObject "type" "contents"- , constructorTagModifier = toLowerFirst . drop 1- , fieldLabelModifier = toLowerFirst . drop 3 })- ''Declaration)---- | Contract Abi is a list of method / event declarations-newtype ContractAbi = ContractAbi { unAbi :: [Declaration] }- deriving (Eq, Ord)--instance FromJSON ContractAbi where- parseJSON = fmap ContractAbi . parseJSON--instance ToJSON ContractAbi where- toJSON = toJSON . unAbi--instance Show ContractAbi where- show (ContractAbi c) = T.unpack $ T.unlines $- [ "Contract:" ]- ++ foldMap showConstructor c ++- [ "\tEvents:" ]- ++ foldMap showEvent c ++- [ "\tMethods:" ]- ++ foldMap showMethod c--showConstructor :: Declaration -> [Text]-showConstructor x = case x of- DConstructor{} -> ["\tConstructor " <> signature x]- _ -> []--showEvent :: Declaration -> [Text]-showEvent x = case x of- DEvent{} -> ["\t\t" <> signature x]- _ -> []--showMethod :: Declaration -> [Text]-showMethod x = case x of- DFunction{} ->- ["\t\t" <> methodId x <> " " <> signature x]- _ -> []---- | Take a signature by given decl, e.g. foo(uint,string)-signature :: Declaration -> Text--signature (DConstructor inputs) = "(" <> args inputs <> ")"- where- args [] = ""- args [x] = funArgType x- args (x:xs) = case funArgComponents x of- Nothing -> funArgType x <> "," <> args xs- Just cmps -> "(" <> args cmps <> ")," <> args xs--signature (DFallback _) = "()"--signature (DFunction name _ inputs _) = name <> "(" <> args inputs <> ")"- where- args :: [FunctionArg] -> Text- args [] = ""- args [x] = funArgType x- args (x:xs) = case funArgComponents x of- Nothing -> funArgType x <> "," <> args xs- Just cmps -> "(" <> args cmps <> ")," <> args xs--signature (DEvent name inputs _) = name <> "(" <> args inputs <> ")"- where- args :: [EventArg] -> Text- args = T.dropEnd 1 . foldMap (<> ",") . fmap eveArgType---- | Localy compute Keccak-256 hash of given text-sha3 :: Text -> Text-{-# INLINE sha3 #-}-sha3 x = T.pack (show digest)- where digest :: Digest Keccak_256- digest = hash (encodeUtf8 x)---- | Generate method selector by given method 'Delcaration'-methodId :: Declaration -> Text-{-# INLINE methodId #-}-methodId = ("0x" <>) . T.take 8 . sha3 . signature---- | Generate event `topic0` hash by givent event 'Delcaration'-eventId :: Declaration -> Text-{-# INLINE eventId #-}-eventId = ("0x" <>) . sha3 . signature---- | Solidity types and parsers-data SolidityType = SolidityBool- | SolidityAddress- | SolidityUint Int- | SolidityInt Int- | SolidityString- | SolidityBytesN Int- | SolidityBytes- | SolidityTuple Int [SolidityType]- | SolidityVector [Int] SolidityType- | SolidityArray SolidityType- deriving (Eq, Show)--numberParser :: Parser Int-numberParser = read <$> many1 digit--parseUint :: Parser SolidityType-parseUint = do- _ <- string "uint"- SolidityUint <$> numberParser--parseInt :: Parser SolidityType-parseInt = do- _ <- string "int"- SolidityInt <$> numberParser--parseBool :: Parser SolidityType-parseBool = string "bool" >> pure SolidityBool--parseString :: Parser SolidityType-parseString = string "string" >> pure SolidityString--parseBytes :: Parser SolidityType-parseBytes = do- _ <- string "bytes"- mn <- optionMaybe numberParser- pure $ maybe SolidityBytes SolidityBytesN mn--parseAddress :: Parser SolidityType-parseAddress = string "address" >> pure SolidityAddress--solidityBasicTypeParser :: Parser SolidityType-solidityBasicTypeParser =- choice [ try parseUint- , try parseInt- , try parseAddress- , try parseBool- , try parseString- , parseBytes- ]--parseVector :: Parser SolidityType-parseVector = do- s <- solidityBasicTypeParser- ns <- many1Till lengthParser (lookAhead (void $ string "[]") <|> eof)- pure $ SolidityVector ns s- where- many1Till :: Parser Int -> Parser () -> Parser [Int]- many1Till p end = do- a <- p- as <- manyTill p end- return (a : as)-- lengthParser = do- _ <- char '['- n <- numberParser- _ <- char ']'- pure n--parseArray :: Parser SolidityType-parseArray = do- s <- try (parseVector <* string "[]") <|> (solidityBasicTypeParser <* string "[]")- pure $ SolidityArray s---solidityTypeParser :: Parser SolidityType-solidityTypeParser =- choice [ try parseArray- , try parseVector- , solidityBasicTypeParser- ]--parseSolidityFunctionArgType :: FunctionArg -> Either ParseError SolidityType-parseSolidityFunctionArgType (FunctionArg _ typ mcmps) = case mcmps of- Nothing -> parse solidityTypeParser "Solidity" typ- Just cmps ->- SolidityTuple (length cmps)- <$> mapM parseSolidityFunctionArgType cmps---parseSolidityEventArgType :: EventArg -> Either ParseError SolidityType-parseSolidityEventArgType (EventArg _ typ _) = parse solidityTypeParser "Solidity" typ
@@ -1,32 +0,0 @@--- |--- Module : Network.Ethereum--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ TODO-----module Network.Ethereum- (- -- * Basic transaction sending- module Account-- -- * Basic EVM event listening- , EventAction(..)- , event-- -- * Primitive Solidity data types- , module Prim-- -- * Metric unit system- , module Unit- ) where--import Data.Solidity.Prim as Prim-import Network.Ethereum.Account as Account-import Network.Ethereum.Contract.Event (EventAction (..), event)-import Network.Ethereum.Unit as Unit
@@ -1,54 +0,0 @@--- |--- Module : Network.Ethereum.Account--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ In Etereun there are two types of accounts:--- * Externally owned account (EOAs): an account controlled by a private key, and if you own the private key associated with the EOA you have the ability to send ether and messages from it.--- * Contract: an account that has its own code, and is controlled by code.------ This module exports different kinds of EOAs: default, node managed and local. Node managed accounts--- use 'Personal' JSON-RPC API for signing transactions. Local account sign transaction locally and--- use 'sendRawTransaction' method to export transaction to Ethereum network.-----module Network.Ethereum.Account- (- -- * The @Account@ type- Account(..)-- -- * Default node account- , DefaultAccount-- -- * Unlockable node account- , PersonalAccount- , Personal(..)-- -- * Local key account- , LocalKeyAccount- , LocalKey(..)-- -- * Transaction paramitrization function and lenses- , withParam- , to- , value- , gasLimit- , gasPrice- , block- , account-- ) where--import Network.Ethereum.Account.Class (Account (..))-import Network.Ethereum.Account.Default (DefaultAccount)-import Network.Ethereum.Account.Internal (account, block, gasLimit,- gasPrice, to, value,- withParam)-import Network.Ethereum.Account.LocalKey (LocalKey (..),- LocalKeyAccount)-import Network.Ethereum.Account.Personal (Personal (..),- PersonalAccount)
@@ -1,55 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FunctionalDependencies #-}---- |--- Module : Network.Ethereum.Account.Class--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum external owned account abstraction.-----module Network.Ethereum.Account.Class where--import Control.Monad.Trans (MonadTrans)--import Data.Solidity.Abi (AbiGet)-import Network.Ethereum.Api.Types (TxReceipt)-import Network.Ethereum.Contract.Method (Method)-import Network.JsonRpc.TinyClient (JsonRpc)---- | Account is needed for sending transactions to blockchain------ Typically account is provided by node. In this case node manage accounts:--- encrypt and decrypt private keys, manipulate files etc. In other case web3--- can derive account from private key and send to node already signed transactions.----class MonadTrans t => Account a t | t -> a where-- -- | Run computation with given account credentials- withAccount :: JsonRpc m- => a- -- ^ Account params (like a password or private key)- -> t m b- -- ^ Computation that use account for sending transactions- -> m b- -- ^ Json-rpc monad-- -- | Send transaction to contract, like a 'write' command- send :: (JsonRpc m, Method args)- => args- -- ^ Contract method arguments- -> t m TxReceipt- -- ^ Receipt of sended transaction-- -- | Call constant method of contract, like a 'read' command- call :: (JsonRpc m, Method args, AbiGet result)- => args- -- ^ Contact method arguments- -> t m result- -- ^ Decoded result of method call-
@@ -1,73 +0,0 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Network.Ethereum.Account.Default--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Default node managed account (typically the first of accounts list).-----module Network.Ethereum.Account.Default where--import Control.Exception (TypeError (..))-import Control.Monad.Catch (throwM)-import Control.Monad.State.Strict (get, runStateT)-import Control.Monad.Trans (MonadTrans (..))-import qualified Data.ByteArray as BA (convert)-import Data.Maybe (listToMaybe)-import Data.Proxy (Proxy (..))--import Data.Solidity.Abi.Codec (decode, encode)-import Network.Ethereum.Account.Class (Account (..))-import Network.Ethereum.Account.Internal (AccountT (..),- CallParam (..),- defaultCallParam, getCall,- getReceipt)-import qualified Network.Ethereum.Api.Eth as Eth (accounts, call,- estimateGas,- sendTransaction)-import Network.Ethereum.Api.Types (Call (callData, callFrom, callGas))-import Network.Ethereum.Contract.Method (Method (..))--type DefaultAccount = AccountT ()--instance Account () DefaultAccount where- withAccount _ =- fmap fst . flip runStateT (defaultCallParam ()) . runAccountT-- send (args :: a) = do- c <- getCall- lift $ do- accounts <- Eth.accounts- let dat = selector (Proxy :: Proxy a) <> encode args- params = c { callData = Just $ BA.convert dat- , callFrom = listToMaybe accounts }-- params' <- case callGas params of- Just _ -> return params- Nothing -> do- gasLimit <- Eth.estimateGas params- return $ params { callGas = Just gasLimit }-- getReceipt =<< Eth.sendTransaction params'-- call (args :: a) = do- c <- getCall- CallParam{..} <- get- res <- lift $ do- accounts <- Eth.accounts- let dat = selector (Proxy :: Proxy a) <> encode args- params = c { callData = Just $ BA.convert dat- , callFrom = listToMaybe accounts }- Eth.call params _block- case decode res of- Right r -> return r- Left e -> lift (throwM $ TypeError e)
@@ -1,130 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RecordWildCards #-}---- |--- Module : Network.Ethereum.Account.Internal--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Internal types and functions of 'Account' module.-----module Network.Ethereum.Account.Internal where--import Control.Concurrent (threadDelay)-import Control.Monad.IO.Class (liftIO)-import Control.Monad.State.Strict (MonadState (..), StateT (..),- withStateT)-import Control.Monad.Trans (MonadTrans (..))-import Data.Default (Default (..))-import Data.Maybe (fromMaybe)-import Lens.Micro (Lens', lens)--import Data.ByteArray.HexString (HexString)-import Data.Solidity.Prim (Address)-import Network.Ethereum.Account.Class (Account)-import qualified Network.Ethereum.Api.Eth as Eth (getTransactionReceipt)-import Network.Ethereum.Api.Types (Call (..),- DefaultBlock (Latest),- TxReceipt (receiptTransactionHash))-import Network.Ethereum.Unit (Unit (..))-import Network.JsonRpc.TinyClient (JsonRpc)---- | Account is needed to send transactions to blockchain---- | Transaction parametrization data type-data CallParam p = CallParam- { _to :: Maybe Address- -- ^ Transaction recepient- , _value :: Integer- -- ^ Transaction value- , _gasLimit :: Maybe Integer- -- ^ Transaction gas limit- , _gasPrice :: Maybe Integer- -- ^ Transaction gas price- , _block :: DefaultBlock- -- ^ Call block number- , _account :: p- -- ^ Account params to sign transaction- } deriving Eq---- | Transaction recipient lens-to :: Lens' (CallParam p) Address-to = lens (fromMaybe def . _to) $ \a b -> a { _to = Just b }---- | Transaction value lens-value :: Unit value => Lens' (CallParam p) value-value = lens (fromWei . _value) $ \a b -> a { _value = toWei b }---- | Transaction gas limit lens-gasLimit :: Lens' (CallParam p) Integer-gasLimit = lens (fromMaybe def . _gasLimit) $ \a b -> a { _gasLimit = Just b }---- | Transaction gas price lens-gasPrice :: Unit gasprice => Lens' (CallParam p) gasprice-gasPrice = lens (fromWei . fromMaybe def . _gasPrice) $ \a b -> a { _gasPrice = Just (toWei b) }---- | Call execution block lens-block :: Lens' (CallParam p) DefaultBlock-block = lens _block $ \a b -> a { _block = b }---- | EOA params lens-account :: Lens' (CallParam p) p-account = lens _account $ \a b -> a { _account = b }---- | Monad transformer for sending parametrized transactions from account-newtype AccountT p m a = AccountT- { runAccountT :: StateT (CallParam p) m a }- deriving (Functor, Applicative, Monad, MonadTrans)--instance Monad m => MonadState (CallParam p) (AccountT p m) where- get = AccountT get- put = AccountT . put---- | @withParam@ is very similar to @withStateT@ function, it's used--- to set parameters of transaction locally and revert params after out of scope.------ @--- withAccount () $--- withParam (to .~ tokenAddress) $--- transfer alice 42--- @-withParam :: Account p (AccountT p)- => (CallParam p -> CallParam p)- -> AccountT p m a- -> AccountT p m a-{-# INLINE withParam #-}-withParam f m = AccountT $ withStateT f $ runAccountT m--defaultCallParam :: a -> CallParam a-{-# INLINE defaultCallParam #-}-defaultCallParam = CallParam def 0 Nothing Nothing Latest--getCall :: MonadState (CallParam p) m => m Call-getCall = do- CallParam{..} <- get- return $ def { callTo = _to- , callValue = Just $ fromInteger _value- , callGas = fromInteger <$> _gasLimit- , callGasPrice = fromInteger <$> _gasPrice- }--getReceipt :: JsonRpc m => HexString -> m TxReceipt-getReceipt tx = do- mbreceipt <- Eth.getTransactionReceipt tx- case mbreceipt of- Just receipt -> return receipt- Nothing -> do- liftIO $ threadDelay 100000- -- TODO: avoid inifinite loop- getReceipt tx--updateReceipt :: JsonRpc m => TxReceipt -> m TxReceipt-{-# INLINE updateReceipt #-}-updateReceipt = getReceipt . receiptTransactionHash
@@ -1,97 +0,0 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Network.Ethereum.Account.LocalKey--- Copyright : Alexander Krupenkin 2018--- Roy Blankman 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Using ECC for singing transactions locally, e.g. out of Ethereum node.--- Transaction will send using 'eth_sendRawTransacion' JSON-RPC method.-----module Network.Ethereum.Account.LocalKey where--import Control.Exception (TypeError (..))-import Control.Monad.Catch (throwM)-import Control.Monad.State.Strict (get, runStateT)-import Control.Monad.Trans (lift)-import Crypto.PubKey.ECC.ECDSA (PrivateKey)-import Data.ByteArray (convert)-import Data.ByteString (empty)-import Data.Default (Default (..))-import Data.Proxy (Proxy (..))--import Crypto.Ethereum (derivePubKey, importKey)-import Crypto.Ethereum.Signature (signTransaction)-import Data.Solidity.Abi.Codec (decode, encode)-import Data.Solidity.Prim.Address (fromPubKey)-import Network.Ethereum.Account.Class (Account (..))-import Network.Ethereum.Account.Internal (AccountT (..),- CallParam (..),- defaultCallParam, getCall,- getReceipt)-import qualified Network.Ethereum.Api.Eth as Eth (call, estimateGas,- getTransactionCount,- sendRawTransaction)-import Network.Ethereum.Api.Types (Call (..))-import Network.Ethereum.Chain (foundation)-import Network.Ethereum.Contract.Method (selector)-import Network.Ethereum.Transaction (encodeTransaction)---- | Local EOA params-data LocalKey = LocalKey- { localKeyPrivate :: !PrivateKey- , localKeyChainId :: !Integer- }- deriving (Eq, Show)--instance Default LocalKey where- def = LocalKey (importKey empty) foundation--type LocalKeyAccount = AccountT LocalKey--instance Account LocalKey LocalKeyAccount where- withAccount a =- fmap fst . flip runStateT (defaultCallParam a) . runAccountT-- send (args :: a) = do- CallParam{..} <- get- c <- getCall-- let dat = selector (Proxy :: Proxy a) <> encode args- address = fromPubKey (derivePubKey $ localKeyPrivate _account)-- nonce <- lift $ Eth.getTransactionCount address _block- let params = c { callFrom = Just address- , callNonce = Just nonce- , callData = Just $ convert dat }-- params' <- case callGas params of- Just _ -> return params- Nothing -> do- gasLimit <- lift $ Eth.estimateGas params- return $ params { callGas = Just gasLimit }-- let packer = encodeTransaction params' (localKeyChainId _account)- signed = signTransaction packer (localKeyPrivate _account)- lift $ getReceipt =<< Eth.sendRawTransaction signed-- call (args :: a) = do- CallParam{..} <- get- c <- getCall- let dat = selector (Proxy :: Proxy a) <> encode args- address = fromPubKey (derivePubKey $ localKeyPrivate _account)- params = c { callFrom = Just address, callData = Just $ convert dat }-- res <- lift $ Eth.call params _block- case decode res of- Right r -> return r- Left e -> lift (throwM $ TypeError e)
@@ -1,85 +0,0 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Network.Ethereum.Account.Personal--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Node managed unlockable account. Typically to send transaction from this account--- password is required.-----module Network.Ethereum.Account.Personal where--import Control.Exception (TypeError (..))-import Control.Monad.Catch (throwM)-import Control.Monad.State.Strict (get, runStateT)-import Control.Monad.Trans (lift)-import qualified Data.ByteArray as BA (convert)-import Data.Default (Default (..))-import Data.Proxy (Proxy (..))--import Data.Solidity.Abi.Codec (decode, encode)-import Data.Solidity.Prim.Address (Address)-import Network.Ethereum.Account.Class (Account (..))-import Network.Ethereum.Account.Internal (AccountT (..),- CallParam (..),- defaultCallParam, getCall,- getReceipt)-import qualified Network.Ethereum.Api.Eth as Eth (call, estimateGas)-import Network.Ethereum.Api.Personal (Passphrase)-import qualified Network.Ethereum.Api.Personal as Personal (sendTransaction)-import Network.Ethereum.Api.Types (Call (callData, callFrom, callGas))-import Network.Ethereum.Contract.Method (selector)---- | Unlockable node managed account params-data Personal = Personal- { personalAddress :: !Address- , personalPassphrase :: !Passphrase- }- deriving (Eq, Show)--instance Default Personal where- def = Personal def ""--type PersonalAccount = AccountT Personal--instance Account Personal PersonalAccount where- withAccount a =- fmap fst . flip runStateT (defaultCallParam a) . runAccountT-- send (args :: a) = do- CallParam{..} <- get- c <- getCall- lift $ do- let dat = selector (Proxy :: Proxy a) <> encode args- params = c { callFrom = Just $ personalAddress _account- , callData = Just $ BA.convert dat }-- params' <- case callGas params of- Just _ -> return params- Nothing -> do- gasLimit <- Eth.estimateGas params- return $ params { callGas = Just gasLimit }-- getReceipt =<< Personal.sendTransaction params' (personalPassphrase _account)-- call (args :: a) = do- s <- get- case s of- CallParam _ _ _ _ block (Personal address _) -> do- c <- getCall- let dat = selector (Proxy :: Proxy a) <> encode args- params = c { callFrom = Just address, callData = Just $ BA.convert dat }- res <- lift $ Eth.call params block- case decode res of- Right r -> return r- Left e -> lift (throwM $ TypeError e)
@@ -1,55 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}---- |--- Module : Network.Ethereum.Account.Safe--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Safe sending of Ethereum transaction.-----module Network.Ethereum.Account.Safe where--import Control.Concurrent (threadDelay)-import Control.Monad.IO.Class (liftIO)-import Control.Monad.Trans (lift)--import Network.Ethereum.Account.Class (Account (send))-import Network.Ethereum.Account.Internal (updateReceipt)-import qualified Network.Ethereum.Api.Eth as Eth-import Network.Ethereum.Api.Types (TxReceipt (receiptBlockNumber))-import Network.Ethereum.Contract.Method (Method)-import Network.JsonRpc.TinyClient (JsonRpc)---- | Safe version of 'send' function of 'Account' typeclass--- Waiting for some blocks of transaction confirmation before return-safeSend :: (Account p t, JsonRpc m, Method args, Monad (t m))- => Integer- -- ^ Confirmation in blocks- -> args- -- ^ Contract method arguments- -> t m TxReceipt- -- ^ Receipt of sended transaction-safeSend b a = lift . waiting =<< send a- where- waiting receipt =- case receiptBlockNumber receipt of- Nothing -> do- liftIO $ threadDelay 1000000- waiting =<< updateReceipt receipt- Just bn -> do- current <- Eth.blockNumber- if current - bn >= fromInteger b- then return receipt- else do liftIO $ threadDelay 1000000- waiting receipt---- | Count block confirmation to keep secure--- According to Vitalik post--- https://blog.ethereum.org/2015/09/14/on-slow-and-fast-block-times/-safeConfirmations :: Integer-safeConfirmations = 10
@@ -1,248 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ethereum.Web3.Eth--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Ethereum node JSON-RPC API methods with `eth_` prefix.-----module Network.Ethereum.Api.Eth where--import Data.ByteArray.HexString (HexString)-import Data.Solidity.Prim.Address (Address)-import Data.Text (Text)-import Network.Ethereum.Api.Types (Block, Call, Change, DefaultBlock,- Filter, Quantity, SyncingState,- Transaction, TxReceipt)-import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Returns the current ethereum protocol version.-protocolVersion :: JsonRpc m => m Text-{-# INLINE protocolVersion #-}-protocolVersion = remote "eth_protocolVersion"---- | Returns an object with data about the sync status or false.-syncing :: JsonRpc m => m SyncingState-{-# INLINE syncing #-}-syncing = remote "eth_syncing"---- | Returns the client coinbase address.-coinbase :: JsonRpc m => m Address-{-# INLINE coinbase #-}-coinbase = remote "eth_coinbase"---- | Returns true if client is actively mining new blocks.-mining :: JsonRpc m => m Bool-{-# INLINE mining #-}-mining = remote "eth_mining"---- | Returns the number of hashes per second that the node is mining with.-hashrate :: JsonRpc m => m Quantity-{-# INLINE hashrate #-}-hashrate = remote "eth_hashrate"---- | Returns the value from a storage position at a given address.-getStorageAt :: JsonRpc m => Address -> Quantity -> DefaultBlock -> m HexString-{-# INLINE getStorageAt #-}-getStorageAt = remote "eth_getStorageAt"---- | Returns the number of transactions sent from an address.-getTransactionCount :: JsonRpc m => Address -> DefaultBlock -> m Quantity-{-# INLINE getTransactionCount #-}-getTransactionCount = remote "eth_getTransactionCount"---- | Returns the number of transactions in a block from a block matching the given block hash.-getBlockTransactionCountByHash :: JsonRpc m => HexString -> m Quantity-{-# INLINE getBlockTransactionCountByHash #-}-getBlockTransactionCountByHash = remote "eth_getBlockTransactionCountByHash"---- | Returns the number of transactions in a block matching the--- given block number.-getBlockTransactionCountByNumber :: JsonRpc m => Quantity -> m Quantity-{-# INLINE getBlockTransactionCountByNumber #-}-getBlockTransactionCountByNumber = remote "eth_getBlockTransactionCountByNumber"---- | Returns the number of uncles in a block from a block matching the given--- block hash.-getUncleCountByBlockHash :: JsonRpc m => HexString -> m Quantity-{-# INLINE getUncleCountByBlockHash #-}-getUncleCountByBlockHash = remote "eth_getUncleCountByBlockHash"---- | Returns the number of uncles in a block from a block matching the given--- block number.-getUncleCountByBlockNumber :: JsonRpc m => Quantity -> m Quantity-{-# INLINE getUncleCountByBlockNumber #-}-getUncleCountByBlockNumber = remote "eth_getUncleCountByBlockNumber"---- | Returns code at a given address.-getCode :: JsonRpc m => Address -> DefaultBlock -> m HexString-{-# INLINE getCode #-}-getCode = remote "eth_getCode"---- | Returns an Ethereum specific signature with:--- sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))).-sign :: JsonRpc m => Address -> HexString -> m HexString-{-# INLINE sign #-}-sign = remote "eth_sign"---- | Creates new message call transaction or a contract creation,--- if the data field contains code.-sendTransaction :: JsonRpc m => Call -> m HexString-{-# INLINE sendTransaction #-}-sendTransaction = remote "eth_sendTransaction"---- | Creates new message call transaction or a contract creation for signed--- transactions.-sendRawTransaction :: JsonRpc m => HexString -> m HexString-{-# INLINE sendRawTransaction #-}-sendRawTransaction = remote "eth_sendRawTransaction"---- | Returns the balance of the account of given address.-getBalance :: JsonRpc m => Address -> DefaultBlock -> m Quantity-{-# INLINE getBalance #-}-getBalance = remote "eth_getBalance"---- | Creates a filter object, based on filter options, to notify when the--- state changes (logs). To check if the state has changed, call--- 'getFilterChanges'.-newFilter :: JsonRpc m => Filter e -> m Quantity-{-# INLINE newFilter #-}-newFilter = remote "eth_newFilter"---- | Polling method for a filter, which returns an array of logs which--- occurred since last poll.-getFilterChanges :: JsonRpc m => Quantity -> m [Change]-{-# INLINE getFilterChanges #-}-getFilterChanges = remote "eth_getFilterChanges"---- | Uninstalls a filter with given id.--- Should always be called when watch is no longer needed.-uninstallFilter :: JsonRpc m => Quantity -> m Bool-{-# INLINE uninstallFilter #-}-uninstallFilter = remote "eth_uninstallFilter"---- | Returns an array of all logs matching a given filter object.-getLogs :: JsonRpc m => Filter e -> m [Change]-{-# INLINE getLogs #-}-getLogs = remote "eth_getLogs"---- | Executes a new message call immediately without creating a--- transaction on the block chain.-call :: JsonRpc m => Call -> DefaultBlock -> m HexString-{-# INLINE call #-}-call = remote "eth_call"---- | Makes a call or transaction, which won't be added to the blockchain and--- returns the used gas, which can be used for estimating the used gas.-estimateGas :: JsonRpc m => Call -> m Quantity-{-# INLINE estimateGas #-}-estimateGas = remote "eth_estimateGas"---- | Returns information about a block by hash.-getBlockByHash :: JsonRpc m => HexString -> m Block-{-# INLINE getBlockByHash #-}-getBlockByHash = flip (remote "eth_getBlockByHash") True---- | Returns information about a block by block number.-getBlockByNumber :: JsonRpc m => Quantity -> m Block-{-# INLINE getBlockByNumber #-}-getBlockByNumber = flip (remote "eth_getBlockByNumber") True---- | Returns the information about a transaction requested by transaction hash.-getTransactionByHash :: JsonRpc m => HexString -> m (Maybe Transaction)-{-# INLINE getTransactionByHash #-}-getTransactionByHash = remote "eth_getTransactionByHash"---- | Returns information about a transaction by block hash and transaction index position.-getTransactionByBlockHashAndIndex :: JsonRpc m => HexString -> Quantity -> m (Maybe Transaction)-{-# INLINE getTransactionByBlockHashAndIndex #-}-getTransactionByBlockHashAndIndex = remote "eth_getTransactionByBlockHashAndIndex"---- | Returns information about a transaction by block number and transaction--- index position.-getTransactionByBlockNumberAndIndex :: JsonRpc m => DefaultBlock -> Quantity -> m (Maybe Transaction)-{-# INLINE getTransactionByBlockNumberAndIndex #-}-getTransactionByBlockNumberAndIndex = remote "eth_getTransactionByBlockNumberAndIndex"---- | Returns the receipt of a transaction by transaction hash.-getTransactionReceipt :: JsonRpc m => HexString -> m (Maybe TxReceipt)-{-# INLINE getTransactionReceipt #-}-getTransactionReceipt = remote "eth_getTransactionReceipt"---- | Returns a list of addresses owned by client.-accounts :: JsonRpc m => m [Address]-{-# INLINE accounts #-}-accounts = remote "eth_accounts"---- | Creates a filter in the node, to notify when a new block arrives.-newBlockFilter :: JsonRpc m => m Quantity-{-# INLINE newBlockFilter #-}-newBlockFilter = remote "eth_newBlockFilter"---- | Polling method for a block filter, which returns an array of block hashes--- occurred since last poll.-getBlockFilterChanges :: JsonRpc m => Quantity -> m [HexString]-{-# INLINE getBlockFilterChanges #-}-getBlockFilterChanges = remote "eth_getFilterChanges"---- | Returns the number of most recent block.-blockNumber :: JsonRpc m => m Quantity-{-# INLINE blockNumber #-}-blockNumber = remote "eth_blockNumber"---- | Returns the current price per gas in wei.-gasPrice :: JsonRpc m => m Quantity-{-# INLINE gasPrice #-}-gasPrice = remote "eth_gasPrice"---- | Returns information about a uncle of a block by hash and uncle index--- position.-getUncleByBlockHashAndIndex :: JsonRpc m => HexString -> Quantity -> m Block-{-# INLINE getUncleByBlockHashAndIndex #-}-getUncleByBlockHashAndIndex = remote "eth_getUncleByBlockHashAndIndex"---- | Returns information about a uncle of a block by number and uncle index--- position.-getUncleByBlockNumberAndIndex :: JsonRpc m => DefaultBlock -> Quantity -> m Block-{-# INLINE getUncleByBlockNumberAndIndex #-}-getUncleByBlockNumberAndIndex = remote "eth_getUncleByBlockNumberAndIndex"---- | Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call getFilterChanges. Returns a FilterId.-newPendingTransactionFilter :: JsonRpc m => m Quantity-{-# INLINE newPendingTransactionFilter #-}-newPendingTransactionFilter = remote "eth_newPendingTransactionFilter"---- | Returns an array of all logs matching filter with given id.-getFilterLogs :: JsonRpc m => Quantity -> m [Change]-{-# INLINE getFilterLogs #-}-getFilterLogs = remote "eth_getFilterLogs"---- | Returns the hash of the current block, the seedHash, and the boundary--- condition to be met ("target").-getWork :: JsonRpc m => m [HexString]-{-# INLINE getWork #-}-getWork = remote "eth_getWork"---- | Used for submitting a proof-of-work solution.--- Parameters:--- 1. DATA, 8 Bytes - The nonce found (64 bits)--- 2. DATA, 32 Bytes - The header's pow-hash (256 bits)--- 3. DATA, 32 Bytes - The mix digest (256 bits)-submitWork :: JsonRpc m => HexString -> HexString -> HexString -> m Bool-{-# INLINE submitWork #-}-submitWork = remote "eth_submitWork"---- | Used for submitting mining hashrate.--- Parameters:--- 1. Hashrate, a hexadecimal string representation (32 bytes) of the hash rate--- 2. ID, String - A random hexadecimal(32 bytes) ID identifying the client-submitHashrate :: JsonRpc m => HexString -> HexString -> m Bool-{-# INLINE submitHashrate #-}-submitHashrate = remote "eth_submitHashrate"
@@ -1,35 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ethereum.Api.Net--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Ethereum node JSON-RPC API methods with `net_` prefix.-----module Network.Ethereum.Api.Net where--import Data.Text (Text)-import Network.Ethereum.Api.Types (Quantity)-import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Returns the current network id.-version :: JsonRpc m => m Text-{-# INLINE version #-}-version = remote "net_version"---- | Returns true if client is actively listening for network connections.-listening :: JsonRpc m => m Bool-{-# INLINE listening #-}-listening = remote "net_listening"---- | Returns number of peers currently connected to the client.-peerCount :: JsonRpc m => m Quantity-{-# INLINE peerCount #-}-peerCount = remote "net_peerCount"
@@ -1,93 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ethereum.Api.Personal--- Copyright : Keagan McClelland 2018--- License : BSD3------ Maintainer : keagan.mcclelland@gmail.com--- Stability : experimental--- Portability : unknown------ Ethereum node JSON-RPC API methods with `personal_` prefix.-----module Network.Ethereum.Api.Personal where--import Data.ByteArray.HexString (HexString)-import Data.Solidity.Prim.Address (Address)-import Data.Text (Text)-import Network.Ethereum.Api.Types (Call)-import Network.JsonRpc.TinyClient (JsonRpc (..))--type Passphrase = Text---- | Imports the given unencrypted private key (hex string) into the key store, encrypting it with the passphrase.------ Parameters:------ 1. unencrypted private key------ 2. passphrase------ Returns: address of new account-importRawKey :: JsonRpc m => HexString -> Passphrase -> m Address-{-# INLINE importRawKey #-}-importRawKey = remote "personal_importRawKey"---- | Returns all the Ethereum account addresses of all keys in the key store.-listAccounts :: JsonRpc m => m [Address]-{-# INLINE listAccounts #-}-listAccounts = remote "personal_listAccounts"---- | Removes the private key with given address from memory. The account can no longer be used to send transactions.-lockAccount :: JsonRpc m => Address -> m Bool-{-# INLINE lockAccount #-}-lockAccount = remote "personal_lockAccount"---- | Generates a new private key and stores it in the key store directory. The key file is encrypted with the given--- passphrase. Returns the address of the new account.-newAccount :: JsonRpc m => Passphrase -> m Address-{-# INLINE newAccount #-}-newAccount = remote "personal_newAccount"---- | Decrypts the key with the given address from the key store.------ The unencrypted key will be held in memory until it is locked again------ The account can be used with eth_sign and eth_sendTransaction while it is unlocked.-unlockAccount :: JsonRpc m => Address -> Passphrase -> m Bool-{-# INLINE unlockAccount #-}-unlockAccount = remote "personal_unlockAccount"---- | Validate the given passphrase and submit transaction.------ The transaction is the same argument as for eth_sendTransaction and contains the from address. If the passphrase can--- be used to decrypt the private key belonging to the transaction 'callFrom', the transaction is verified, signed and--- send onto the network. The account is not unlocked globally in the node and cannot be used in other RPC calls.-sendTransaction :: JsonRpc m => Call -> Passphrase -> m HexString-{-# INLINE sendTransaction #-}-sendTransaction = remote "personal_sendTransaction"---- | Returns an Ethereum specific signature with:------ sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))).------ when given a passphrase to decrypt the account's private key-sign :: JsonRpc m => HexString -> Address -> Passphrase -> m HexString-{-# INLINE sign #-}-sign = remote "personal_sign"---- | Recovers address given message and signature data------ Parameters:------ 1. message: DATA, n bytes------ 2. signature: DATA, 65 bytes------ Returns: Address-ecRecover :: JsonRpc m => HexString -> HexString -> m Address-{-# INLINE ecRecover #-}-ecRecover = remote "personal_ecRecover"
@@ -1,296 +0,0 @@-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Network.Ethereum.Api.Types--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Ethereum generic JSON-RPC types.-----module Network.Ethereum.Api.Types where--import Data.Aeson (FromJSON (..), Options (fieldLabelModifier, omitNothingFields),- ToJSON (..), Value (Bool, String),- defaultOptions, object, (.=))-import Data.Aeson.TH (deriveJSON)-import Data.Default (Default (..))-import Data.Solidity.Prim.Address (Address)-import Data.String (IsString (..))-import qualified Data.Text as T (pack)-import qualified Data.Text.Lazy.Builder as B (toLazyText)-import qualified Data.Text.Lazy.Builder.Int as B (hexadecimal)-import qualified Data.Text.Read as R (decimal, hexadecimal)-import GHC.Generics (Generic)--import Data.ByteArray.HexString (HexString)-import Data.String.Extra (toLowerFirst)---- | Should be viewed as type to representing QUANTITY in Web3 JSON RPC docs------ When encoding QUANTITIES (integers, numbers): encode as hex, prefix with "0x",--- the most compact representation (slight exception: zero should be represented as "0x0").--- Examples:------ 0x41 (65 in decimal)--- 0x400 (1024 in decimal)--- WRONG: 0x (should always have at least one digit - zero is "0x0")--- WRONG: 0x0400 (no leading zeroes allowed)--- WRONG: ff (must be prefixed 0x)-newtype Quantity = Quantity { unQuantity :: Integer }- deriving (Num, Real, Integral, Enum, Eq, Ord, Generic)--instance Show Quantity where- show = show . unQuantity--instance IsString Quantity where- fromString ('0' : 'x' : hex) =- case R.hexadecimal (T.pack hex) of- Right (x, "") -> Quantity x- _ -> error ("Quantity " ++ show hex ++ " is not valid hex")- fromString num =- case R.decimal (T.pack num) of- Right (x, "") -> Quantity x- _ -> error ("Quantity " ++ show num ++ " is not valid decimal")--instance ToJSON Quantity where- toJSON (Quantity x) =- let hexValue = B.toLazyText (B.hexadecimal x)- in toJSON ("0x" <> hexValue)--instance FromJSON Quantity where- parseJSON (String v) =- case R.hexadecimal v of- Right (x, "") -> return (Quantity x)- _ -> fail $ "Quantity " ++ show v <> " is not valid hex"- parseJSON _ = fail "Quantity should be a JSON String"---- | An object with sync status data.-data SyncActive = SyncActive- { syncStartingBlock :: !Quantity- -- ^ QUANTITY - The block at which the import started (will only be reset, after the sync reached his head).- , syncCurrentBlock :: !Quantity- -- ^ QUANTITY - The current block, same as eth_blockNumber.- , syncHighestBlock :: !Quantity- -- ^ QUANTITY - The estimated highest block.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 4 }) ''SyncActive)---- | Sync state pulled by low-level call 'eth_syncing'.-data SyncingState = Syncing SyncActive- | NotSyncing- deriving (Eq, Generic, Show)--instance FromJSON SyncingState where- parseJSON (Bool _) = pure NotSyncing- parseJSON v = Syncing <$> parseJSON v---- | Changes pulled by low-level call 'eth_getFilterChanges', 'eth_getLogs',--- and 'eth_getFilterLogs'-data Change = Change- { changeLogIndex :: !(Maybe Quantity)- -- ^ QUANTITY - integer of the log index position in the block. null when its pending log.- , changeTransactionIndex :: !(Maybe Quantity)- -- ^ QUANTITY - integer of the transactions index position log was created from. null when its pending log.- , changeTransactionHash :: !(Maybe HexString)- -- ^ DATA, 32 Bytes - hash of the transactions this log was created from. null when its pending log.- , changeBlockHash :: !(Maybe HexString)- -- ^ DATA, 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.- , changeBlockNumber :: !(Maybe Quantity)- -- ^ QUANTITY - the block number where this log was in. null when its pending. null when its pending log.- , changeAddress :: !Address- -- ^ DATA, 20 Bytes - address from which this log originated.- , changeData :: !HexString- -- ^ DATA - contains one or more 32 Bytes non-indexed arguments of the log.- , changeTopics :: ![HexString]- -- ^ Array of DATA - Array of 0 to 4 32 Bytes DATA of indexed log arguments.- }- deriving (Eq, Show, Generic)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 6 }) ''Change)---- | The contract call params.-data Call = Call- { callFrom :: !(Maybe Address)- -- ^ DATA, 20 Bytes - The address the transaction is send from.- , callTo :: !(Maybe Address)- -- ^ DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to.- , callGas :: !(Maybe Quantity)- -- ^ QUANTITY - (optional, default: 3000000) Integer of the gas provided for the transaction execution. It will return unused gas.- , callGasPrice :: !(Maybe Quantity)- -- ^ QUANTITY - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas.- , callValue :: !(Maybe Quantity)- -- ^ QUANTITY - (optional) Integer of the value sent with this transaction.- , callData :: !(Maybe HexString)- -- ^ DATA - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters.- , callNonce :: !(Maybe Quantity)- -- ^ QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.- }- deriving (Eq, Show, Generic)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 4- , omitNothingFields = True }) ''Call)--instance Default Call where- def = Call Nothing Nothing (Just 3000000) Nothing (Just 0) Nothing Nothing---- | The state of blockchain for contract call.-data DefaultBlock = BlockWithNumber Quantity- | Earliest- | Latest- | Pending- deriving (Eq, Show, Generic)--instance ToJSON DefaultBlock where- toJSON (BlockWithNumber bn) = toJSON bn- toJSON parameter = toJSON . toLowerFirst . show $ parameter---- | Low-level event filter data structure.-data Filter e = Filter- { filterAddress :: !(Maybe [Address])- -- ^ DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.- , filterFromBlock :: !DefaultBlock- -- ^ QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.- , filterToBlock :: !DefaultBlock- -- ^ QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.- , filterTopics :: !(Maybe [Maybe HexString])- -- ^ Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.- }- deriving (Eq, Show, Generic)--instance ToJSON (Filter e) where- toJSON f = object [ "address" .= filterAddress f- , "fromBlock" .= filterFromBlock f- , "toBlock" .= filterToBlock f- , "topics" .= filterTopics f ]--instance Ord DefaultBlock where- compare Pending Pending = EQ- compare Latest Latest = EQ- compare Earliest Earliest = EQ- compare (BlockWithNumber a) (BlockWithNumber b) = compare a b- compare _ Pending = LT- compare Pending Latest = GT- compare _ Latest = LT- compare Earliest _ = LT- compare a b = case compare b a of- LT -> GT- GT -> LT- EQ -> EQ---- | The Receipt of a Transaction-data TxReceipt = TxReceipt- { receiptTransactionHash :: !HexString- -- ^ DATA, 32 Bytes - hash of the transaction.- , receiptTransactionIndex :: !Quantity- -- ^ QUANTITY - index of the transaction.- , receiptBlockHash :: !(Maybe HexString)- -- ^ DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.- , receiptBlockNumber :: !(Maybe Quantity)- -- ^ QUANTITY - block number where this transaction was in. null when its pending.- , receiptCumulativeGasUsed :: !Quantity- -- ^ QUANTITY - The total amount of gas used when this transaction was executed in the block.- , receiptGasUsed :: !Quantity- -- ^ QUANTITY - The amount of gas used by this specific transaction alone.- , receiptContractAddress :: !(Maybe Address)- -- ^ DATA, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null.- , receiptLogs :: ![Change]- -- ^ Array - Array of log objects, which this transaction generated.- , receiptLogsBloom :: !HexString- -- ^ DATA, 256 Bytes - Bloom filter for light clients to quickly retrieve related logs.- , receiptStatus :: !(Maybe Quantity)- -- ^ QUANTITY either 1 (success) or 0 (failure)- }- deriving (Show, Generic)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 7 }) ''TxReceipt)---- | Transaction information.-data Transaction = Transaction- { txHash :: !HexString- -- ^ DATA, 32 Bytes - hash of the transaction.- , txNonce :: !Quantity- -- ^ QUANTITY - the number of transactions made by the sender prior to this one.- , txBlockHash :: !(Maybe HexString)- -- ^ DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.- , txBlockNumber :: !(Maybe Quantity)- -- ^ QUANTITY - block number where this transaction was in. null when its pending.- , txTransactionIndex :: !(Maybe Quantity)- -- ^ QUANTITY - integer of the transactions index position in the block. null when its pending.- , txFrom :: !Address- -- ^ DATA, 20 Bytes - address of the sender.- , txTo :: !(Maybe Address)- -- ^ DATA, 20 Bytes - address of the receiver. null when its a contract creation transaction.- , txValue :: !Quantity- -- ^ QUANTITY - value transferred in Wei.- , txGasPrice :: !Quantity- -- ^ QUANTITY - gas price provided by the sender in Wei.- , txGas :: !Quantity- -- ^ QUANTITY - gas provided by the sender.- , txInput :: !HexString- -- ^ DATA - the data send along with the transaction.- }- deriving (Eq, Show, Generic)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 2 }) ''Transaction)---- | Block information.-data Block = Block- { blockNumber :: !(Maybe Quantity)- -- ^ QUANTITY - the block number. null when its pending block.- , blockHash :: !(Maybe HexString)- -- ^ DATA, 32 Bytes - hash of the block. null when its pending block.- , blockParentHash :: !HexString- -- ^ DATA, 32 Bytes - hash of the parent block.- , blockNonce :: !(Maybe HexString)- -- ^ DATA, 8 Bytes - hash of the generated proof-of-work. null when its pending block.- , blockSha3Uncles :: !HexString- -- ^ DATA, 32 Bytes - SHA3 of the uncles data in the block.- , blockLogsBloom :: !(Maybe HexString)- -- ^ DATA, 256 Bytes - the bloom filter for the logs of the block. null when its pending block.- , blockTransactionsRoot :: !HexString- -- ^ DATA, 32 Bytes - the root of the transaction trie of the block.- , blockStateRoot :: !HexString- -- ^ DATA, 32 Bytes - the root of the final state trie of the block.- , blockReceiptRoot :: !(Maybe HexString)- -- ^ DATA, 32 Bytes - the root of the receipts trie of the block.- , blockMiner :: !Address- -- ^ DATA, 20 Bytes - the address of the beneficiary to whom the mining rewards were given.- , blockDifficulty :: !Quantity- -- ^ QUANTITY - integer of the difficulty for this block.- , blockTotalDifficulty :: !Quantity- -- ^ QUANTITY - integer of the total difficulty of the chain until this block.- , blockExtraData :: !HexString- -- ^ DATA - the "extra data" field of this block.- , blockSize :: !Quantity- -- ^ QUANTITY - integer the size of this block in bytes.- , blockGasLimit :: !Quantity- -- ^ QUANTITY - the maximum gas allowed in this block.- , blockGasUsed :: !Quantity- -- ^ QUANTITY - the total used gas by all transactions in this block.- , blockTimestamp :: !Quantity- -- ^ QUANTITY - the unix timestamp for when the block was collated.- , blockTransactions :: ![Transaction]- -- ^ Array of transaction objects.- , blockUncles :: ![HexString]- -- ^ Array - Array of uncle hashes.- }- deriving (Show, Generic)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 5 }) ''Block)
@@ -1,30 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ethereum.Api.Web3--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Ethereum node JSON-RPC API methods with `web3_` prefix.-----module Network.Ethereum.Api.Web3 where--import Data.ByteArray.HexString (HexString)-import Data.Text (Text)-import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Returns current node version string.-clientVersion :: JsonRpc m => m Text-{-# INLINE clientVersion #-}-clientVersion = remote "web3_clientVersion"---- | Returns Keccak-256 (not the standardized SHA3-256) of the given data.-sha3 :: JsonRpc m => HexString -> m HexString-{-# INLINE sha3 #-}-sha3 = remote "web3_sha3"
@@ -1,37 +0,0 @@--- |--- Module : Network.Ethereum.Chain--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum chain IDs.-----module Network.Ethereum.Chain where---- | Ethereum mainnet CHAIN_ID from EIP155-foundation :: Integer-foundation = 1---- | Ethereum testnet CHAIN_ID from EIP155-ropsten :: Integer-ropsten = 3---- | Rokenby CHAIN_ID from EIP155-rikenby :: Integer-rikenby = 4---- | Kovan CHAIN_ID from EIP155-kovan :: Integer-kovan = 42---- | Ethereum Classic mainnet CHAIN_ID from EIP155-classic :: Integer-classic = 61---- | Ethereum Classic testnet CHAIN_ID from EIP155-classicTestnet :: Integer-classicTestnet = 62
@@ -1,48 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Network.Ethereum.Contract--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Smart contract type class and utils. A contract in the sense of Solidity--- is a collection of code (its functions) and data (its state) that resides--- at a specific address on the Ethereum blockchain.-----module Network.Ethereum.Contract where--import Data.Proxy (Proxy)-import Data.Text (Text)--import Data.ByteArray.HexString (HexString)-import Data.Solidity.Prim.Address (Address)-import Network.Ethereum.Account.Class (Account)-import Network.Ethereum.Account.Safe (safeConfirmations, safeSend)-import Network.Ethereum.Api.Types (receiptContractAddress)-import Network.Ethereum.Contract.Method (Method)-import Network.JsonRpc.TinyClient (JsonRpc)---- | Contract description type clase-class Contract a where- -- | Contract Solidity ABI- -- https://solidity.readthedocs.io/en/latest/abi-spec.html- abi :: Proxy a -> Text-- -- | Contract bytecode as hex string- bytecode :: Proxy a -> HexString---- | Create new smart contract on blockchain-new :: (Account p t, JsonRpc m, Method a, Monad (t m))- => a- -- ^ Contract constructor- -> t m (Maybe Address)- -- ^ Address of deployed contract when transaction success-new = fmap receiptContractAddress . safeSend safeConfirmations
@@ -1,22 +0,0 @@--- |--- Module : Network.Ethereum.Contract.Event--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum contract event support.-----module Network.Ethereum.Contract.Event- (- module Network.Ethereum.Contract.Event.Common- , module Network.Ethereum.Contract.Event.SingleFilter- , module Network.Ethereum.Contract.Event.MultiFilter- ) where--import Network.Ethereum.Contract.Event.Common-import Network.Ethereum.Contract.Event.MultiFilter-import Network.Ethereum.Contract.Event.SingleFilter
@@ -1,83 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE UndecidableInstances #-}---- |--- Module : Network.Ethereum.Contract.Event.Common--- Copyright : FOAM team <http://foam.space> 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Common event manipulation functions.-----module Network.Ethereum.Contract.Event.Common where--import Control.Concurrent (threadDelay)-import Control.Exception (Exception, throwIO)-import Control.Monad.IO.Class (liftIO)-import Data.Either (lefts, rights)--import Data.Solidity.Event (DecodeEvent (..))-import qualified Network.Ethereum.Api.Eth as Eth-import Network.Ethereum.Api.Types (Change (..), DefaultBlock (..),- Filter (..), Quantity)-import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Event callback control response-data EventAction = ContinueEvent- | TerminateEvent- deriving (Show, Eq)---data FilterChange a = FilterChange- { filterChangeRawChange :: Change- , filterChangeEvent :: a- }--data EventParseFailure = EventParseFailure String- deriving (Show)--instance Exception EventParseFailure--mkFilterChanges :: DecodeEvent i ni e- => [Change]- -> IO [FilterChange e]-mkFilterChanges changes =- let eChanges = map (\c@Change{..} -> FilterChange c <$> decodeEvent c) changes- ls = lefts eChanges- rs = rights eChanges- in if ls /= [] then throwIO (EventParseFailure $ show ls) else pure rs---data FilterStreamState e = FilterStreamState- { fssCurrentBlock :: Quantity- , fssInitialFilter :: Filter e- , fssWindowSize :: Integer- }----- | Coerce a 'DefaultBlock' into a numerical block number.-mkBlockNumber :: JsonRpc m => DefaultBlock -> m Quantity-mkBlockNumber bm = case bm of- BlockWithNumber bn -> return bn- Earliest -> return 0- _ -> Eth.blockNumber---pollTillBlockProgress :: JsonRpc m => Quantity -> m Quantity-pollTillBlockProgress currentBlock = do- bn <- Eth.blockNumber- if currentBlock >= bn- then do- liftIO $ threadDelay 3000000- pollTillBlockProgress currentBlock- else pure bn
@@ -1,481 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeApplications #-}-{-# LANGUAGE TypeFamilyDependencies #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE UndecidableInstances #-}---- |--- Module : Network.Ethereum.Contract.Event.MultiFilter--- Copyright : FOAM team <http://foam.space> 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Parallel multiple event filters.-----module Network.Ethereum.Contract.Event.MultiFilter- (- -- * The @MultiFilter@ type- MultiFilter(..)- , minStartBlock- , minEndBlock- , modifyMultiFilter-- -- * With geth filters- , multiEvent- , multiEventMany-- -- * Without geth filters- , multiEventNoFilter- , multiEventManyNoFilter-- -- * Re-exports- , Handlers- , Handler(..)- , Rec(..)- ) where--import Control.Concurrent (threadDelay)-import Control.Monad (forM, void, when)-import Control.Monad.IO.Class (MonadIO (..))-import Control.Monad.Trans.Class (lift)-import Control.Monad.Trans.Reader (ReaderT (..))-import Data.List (sortOn)-import Data.Machine (MachineT, asParts,- autoM, await,- construct, final,- repeatedly, runT,- unfoldPlan, (~>))-import Data.Machine.Plan (PlanT, stop, yield)-import Data.Maybe (catMaybes, fromJust,- listToMaybe)-import Data.Tagged (Tagged (..))-import Data.Vinyl (Rec ((:&), RNil),- RecApplicative)-import Data.Vinyl.CoRec (CoRec (..), Field,- FoldRec, Handler (H),- Handlers, coRecToRec,- firstField, match,- onField)-import Data.Vinyl.Functor (Compose (..),- Identity (..))-#if MIN_VERSION_vinyl(0,10,0)-import Data.Vinyl (RPureConstrained)-#else-import Data.Proxy (Proxy (..))-import Data.Vinyl.TypeLevel (AllAllSat)-#endif--import Data.Solidity.Event (DecodeEvent (..))-import qualified Network.Ethereum.Api.Eth as Eth-import Network.Ethereum.Api.Types (Change (..),- DefaultBlock (..),- Filter (..), Quantity)-import Network.JsonRpc.TinyClient (JsonRpc(..))-import Network.Ethereum.Contract.Event.Common------------------------------------------------------------------------------------- | MultiFilters-----------------------------------------------------------------------------------data MultiFilter (es :: [*]) where- NilFilters :: MultiFilter '[]- (:?) :: Filter e -> MultiFilter es -> MultiFilter (e ': es)--infixr 5 :?--minEndBlock- :: MultiFilter es- -> DefaultBlock-minEndBlock NilFilters = Pending-minEndBlock (Filter _ _ e _ :? fs) = e `min` minEndBlock fs--minStartBlock- :: MultiFilter es- -> DefaultBlock-minStartBlock NilFilters = Pending-minStartBlock (Filter _ s _ _ :? fs) = s `min` minStartBlock fs--modifyMultiFilter- :: (forall e. Filter e -> Filter e)- -> MultiFilter es- -> MultiFilter es-modifyMultiFilter _ NilFilters = NilFilters-modifyMultiFilter h (f :? fs) = h f :? modifyMultiFilter h fs---multiEvent- :: ( PollFilters es- , QueryAllLogs es- , MapHandlers m es (WithChange es)-#if MIN_VERSION_vinyl(0,10,0)- , RPureConstrained HasLogIndex (WithChange es)-#else- , AllAllSat '[HasLogIndex] (WithChange es)-#endif- , RecApplicative (WithChange es)- , JsonRpc m- )- => MultiFilter es- -> Handlers es (ReaderT Change m EventAction)- -> m ()-multiEvent fltrs = multiEventMany fltrs 0--data MultiFilterStreamState es =- MultiFilterStreamState { mfssCurrentBlock :: Quantity- , mfssInitialMultiFilter :: MultiFilter es- , mfssWindowSize :: Integer- }---multiEventMany- :: ( PollFilters es- , QueryAllLogs es- , MapHandlers m es (WithChange es)-#if MIN_VERSION_vinyl(0,10,0)- , RPureConstrained HasLogIndex (WithChange es)-#else- , AllAllSat '[HasLogIndex] (WithChange es)-#endif- , RecApplicative (WithChange es)- , JsonRpc m- )- => MultiFilter es- -> Integer- -> Handlers es (ReaderT Change m EventAction)- -> m ()-multiEventMany fltrs window handlers = do- start <- mkBlockNumber $ minStartBlock fltrs- let initState =- MultiFilterStreamState { mfssCurrentBlock = start- , mfssInitialMultiFilter = fltrs- , mfssWindowSize = window- }- mLastProcessedFilterState <- reduceMultiEventStream (playMultiLogs initState) handlers- case mLastProcessedFilterState of- Nothing -> startPolling (modifyMultiFilter (\f -> f {filterFromBlock = BlockWithNumber start}) fltrs)- Just (act, lastBlock) -> do- end <- mkBlockNumber . minEndBlock $ fltrs- when (act /= TerminateEvent && lastBlock < end) $- let pollingFromBlock = lastBlock + 1- in startPolling (modifyMultiFilter (\f -> f {filterFromBlock = BlockWithNumber pollingFromBlock}) fltrs)- where- startPolling fltrs' = do- fIds <- openMultiFilter fltrs'- let pollTo = minEndBlock fltrs'- void $ reduceMultiEventStream (pollMultiFilter fIds pollTo) handlers--multiFilterStream :: JsonRpc m- => MultiFilterStreamState es- -> MachineT m k (MultiFilter es)-multiFilterStream initialPlan = do- unfoldPlan initialPlan $ \s -> do- end <- lift . mkBlockNumber . minEndBlock . mfssInitialMultiFilter $ initialPlan- filterPlan end s- where- filterPlan :: JsonRpc m- => Quantity- -> MultiFilterStreamState es- -> PlanT k (MultiFilter es) m (MultiFilterStreamState es)- filterPlan end initialState@MultiFilterStreamState{..} = do- if mfssCurrentBlock > end- then stop- else do- let to' = min end $ mfssCurrentBlock + fromInteger mfssWindowSize- h :: forall e. Filter e -> Filter e- h f = f { filterFromBlock = BlockWithNumber mfssCurrentBlock- , filterToBlock = BlockWithNumber to'- }- yield (modifyMultiFilter h mfssInitialMultiFilter)- filterPlan end initialState { mfssCurrentBlock = to' + 1 }--weakenCoRec- :: ( RecApplicative ts- , FoldRec (t ': ts) (t ': ts)- )- => Field ts- -> Field (t ': ts)-weakenCoRec = fromJust . firstField . (Compose Nothing :&) . coRecToRec--type family WithChange (es :: [*]) = (es' :: [*]) | es' -> es where- WithChange '[] = '[]- WithChange (e : es) = FilterChange e : WithChange es--class QueryAllLogs (es :: [*]) where- queryAllLogs :: JsonRpc m => MultiFilter es -> m [Field (WithChange es)]--instance QueryAllLogs '[] where- queryAllLogs NilFilters = pure []--instance forall e i ni es.- ( DecodeEvent i ni e- , QueryAllLogs es- , RecApplicative (WithChange es)- , FoldRec (FilterChange e : WithChange es) (WithChange es)- ) => QueryAllLogs (e:es) where-- queryAllLogs (f :? fs) = do- changes <- Eth.getLogs f- filterChanges <- liftIO . mkFilterChanges @_ @_ @e $ changes- filterChanges' <- queryAllLogs fs- pure $ map (CoRec . Identity) filterChanges <> map weakenCoRec filterChanges'--class HasLogIndex a where- getLogIndex :: a -> Maybe (Quantity, Quantity)--instance HasLogIndex (FilterChange e) where- getLogIndex FilterChange{..} =- (,) <$> changeBlockNumber filterChangeRawChange <*> changeLogIndex filterChangeRawChange--sortChanges-#if MIN_VERSION_vinyl(0,10,0)- :: ( RPureConstrained HasLogIndex es-#else- :: ( AllAllSat '[HasLogIndex] es-#endif- , RecApplicative es- )- => [Field es]- -> [Field es]-sortChanges changes =-#if MIN_VERSION_vinyl(0,10,0)- let sorterProj change = onField @HasLogIndex getLogIndex change-#else- let sorterProj change = onField (Proxy @'[HasLogIndex]) getLogIndex change-#endif- in sortOn sorterProj changes--class MapHandlers m es es' where- mapHandlers- :: Handlers es (ReaderT Change m EventAction)- -> Handlers es' (m (Maybe (EventAction, Quantity)))--instance Monad m => MapHandlers m '[] '[] where- mapHandlers RNil = RNil--instance- ( Monad m- , MapHandlers m es es'- ) => MapHandlers m (e : es) (FilterChange e : es') where-- mapHandlers (H f :& fs) =- let f' FilterChange{..} = do- act <- runReaderT (f filterChangeEvent) filterChangeRawChange- return ((,) act <$> changeBlockNumber filterChangeRawChange)- in H f' :& mapHandlers fs---reduceMultiEventStream- :: ( Monad m- , MapHandlers m es (WithChange es)- )- => MachineT m k [Field (WithChange es)]- -> Handlers es (ReaderT Change m EventAction)- -> m (Maybe (EventAction, Quantity))-reduceMultiEventStream filterChanges handlers = fmap listToMaybe . runT $- filterChanges- ~> autoM (processChanges handlers)- ~> asParts- ~> runWhile (\(act, _) -> act /= TerminateEvent)- ~> final- where- runWhile p = repeatedly $ do- v <- await- if p v- then yield v- else yield v >> stop- processChanges handlers' changes = fmap catMaybes $- forM changes $ \fc -> match fc (mapHandlers handlers')---- | 'playLogs' streams the 'filterStream' and calls eth_getLogs on these 'Filter' objects.-playMultiLogs- :: forall es k m.- ( QueryAllLogs es-#if MIN_VERSION_vinyl(0,10,0)- , RPureConstrained HasLogIndex (WithChange es)-#else- , AllAllSat '[HasLogIndex] (WithChange es)-#endif- , RecApplicative (WithChange es)- , JsonRpc m- )- => MultiFilterStreamState es- -> MachineT m k [Field (WithChange es)]-playMultiLogs s = fmap sortChanges $- multiFilterStream s- ~> autoM queryAllLogs--data TaggedFilterIds (es :: [*]) where- TaggedFilterNil :: TaggedFilterIds '[]- TaggedFilterCons :: Tagged e Quantity -> TaggedFilterIds es -> TaggedFilterIds (e : es)--class PollFilters (es :: [*]) where- openMultiFilter :: JsonRpc m => MultiFilter es -> m (TaggedFilterIds es)- checkMultiFilter :: JsonRpc m => TaggedFilterIds es -> m [Field (WithChange es)]- closeMultiFilter :: JsonRpc m => TaggedFilterIds es -> m ()--instance PollFilters '[] where- openMultiFilter _ = pure TaggedFilterNil- checkMultiFilter _ = pure []- closeMultiFilter _ = pure ()--instance forall e i ni es.- ( DecodeEvent i ni e- , PollFilters es- , RecApplicative (WithChange es)- , FoldRec (FilterChange e : WithChange es) (WithChange es)- ) => PollFilters (e:es) where- openMultiFilter (f :? fs) = do- fId <- Eth.newFilter f- fsIds <- openMultiFilter fs- pure $ TaggedFilterCons (Tagged fId) fsIds-- checkMultiFilter (TaggedFilterCons (Tagged fId) fsIds) = do- changes <- Eth.getFilterChanges fId- filterChanges <- liftIO . mkFilterChanges @_ @_ @e $ changes- filterChanges' <- checkMultiFilter @es fsIds- pure $ map (CoRec . Identity) filterChanges <> map weakenCoRec filterChanges'-- closeMultiFilter (TaggedFilterCons (Tagged fId) fsIds) = do- _ <- Eth.uninstallFilter fId- closeMultiFilter fsIds----- | Polls a filter from the given filterId until the target toBlock is reached.-pollMultiFilter- :: ( PollFilters es- , RecApplicative (WithChange es)-#if MIN_VERSION_vinyl(0,10,0)- , RPureConstrained HasLogIndex (WithChange es)-#else- , AllAllSat '[HasLogIndex] (WithChange es)-#endif- , JsonRpc m- )- => TaggedFilterIds es- -> DefaultBlock- -> MachineT m k [Field (WithChange es)]-pollMultiFilter is = construct . pollPlan is- where- pollPlan (fIds :: TaggedFilterIds es) end = do- bn <- lift $ Eth.blockNumber- if BlockWithNumber bn > end- then do- _ <- lift $ closeMultiFilter fIds- stop- else do- liftIO $ threadDelay 1000000- changes <- lift $ sortChanges <$> checkMultiFilter fIds- yield changes- pollPlan fIds end------------------------------------------------------------------------------------multiEventNoFilter- :: ( QueryAllLogs es- , MapHandlers m es (WithChange es)-#if MIN_VERSION_vinyl(0,10,0)- , RPureConstrained HasLogIndex (WithChange es)-#else- , AllAllSat '[HasLogIndex] (WithChange es)-#endif- , RecApplicative (WithChange es)- , JsonRpc m- )- => MultiFilter es- -> Handlers es (ReaderT Change m EventAction)- -> m ()-multiEventNoFilter fltrs = multiEventManyNoFilter fltrs 0---multiEventManyNoFilter- :: ( QueryAllLogs es- , MapHandlers m es (WithChange es)-#if MIN_VERSION_vinyl(0,10,0)- , RPureConstrained HasLogIndex (WithChange es)-#else- , AllAllSat '[HasLogIndex] (WithChange es)-#endif- , RecApplicative (WithChange es)- , JsonRpc m- )- => MultiFilter es- -> Integer- -> Handlers es (ReaderT Change m EventAction)- -> m ()-multiEventManyNoFilter fltrs window handlers = do- start <- mkBlockNumber $ minStartBlock fltrs- let initState =- MultiFilterStreamState { mfssCurrentBlock = start- , mfssInitialMultiFilter = fltrs- , mfssWindowSize = window- }- mLastProcessedFilterState <- reduceMultiEventStream (playMultiLogs initState) handlers- case mLastProcessedFilterState of- Nothing ->- let pollingFilterState =- MultiFilterStreamState { mfssCurrentBlock = start- , mfssInitialMultiFilter = fltrs- , mfssWindowSize = 0- }- in void $ reduceMultiEventStream (playNewMultiLogs pollingFilterState) handlers- Just (act, lastBlock) -> do- end <- mkBlockNumber . minEndBlock $ fltrs- when (act /= TerminateEvent && lastBlock < end) $- let pollingFilterState = MultiFilterStreamState { mfssCurrentBlock = lastBlock + 1- , mfssInitialMultiFilter = fltrs- , mfssWindowSize = 0- }- in void $ reduceMultiEventStream (playNewMultiLogs pollingFilterState) handlers--newMultiFilterStream :: JsonRpc m- => MultiFilterStreamState es- -> MachineT m k (MultiFilter es)-newMultiFilterStream initialPlan = do- unfoldPlan initialPlan $ \s -> do- let end = minEndBlock . mfssInitialMultiFilter $ initialPlan- filterPlan end s- where- filterPlan :: JsonRpc m- => DefaultBlock- -> MultiFilterStreamState es- -> PlanT k (MultiFilter es) m (MultiFilterStreamState es)- filterPlan end initialState@MultiFilterStreamState{..} = do- if BlockWithNumber mfssCurrentBlock > end- then stop- else do- newestBlockNumber <- lift . pollTillBlockProgress $ mfssCurrentBlock- let h :: forall e. Filter e -> Filter e- h f = f { filterFromBlock = BlockWithNumber mfssCurrentBlock- , filterToBlock = BlockWithNumber newestBlockNumber- }- yield (modifyMultiFilter h mfssInitialMultiFilter)- filterPlan end initialState { mfssCurrentBlock = newestBlockNumber + 1 }--playNewMultiLogs- :: forall es k m.- ( QueryAllLogs es-#if MIN_VERSION_vinyl(0,10,0)- , RPureConstrained HasLogIndex (WithChange es)-#else- , AllAllSat '[HasLogIndex] (WithChange es)-#endif- , RecApplicative (WithChange es)- , JsonRpc m- )- => MultiFilterStreamState es- -> MachineT m k [Field (WithChange es)]-playNewMultiLogs s = fmap sortChanges $- newMultiFilterStream s- ~> autoM queryAllLogs
@@ -1,233 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilyDependencies #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE UndecidableInstances #-}---- |--- Module : Network.Ethereum.Contract.Event.SingleFilter--- Copyright : FOAM team <http://foam.space> 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Contract event filters.-----module Network.Ethereum.Contract.Event.SingleFilter- (- event- , eventMany- , eventNoFilter- , eventManyNoFilter- ) where--import Control.Concurrent (threadDelay)-import Control.Monad (forM, void, when)-import Control.Monad.IO.Class (MonadIO (..))-import Control.Monad.Trans.Class (lift)-import Control.Monad.Trans.Reader (ReaderT (..))-import Data.Machine (MachineT, asParts,- autoM, await,- construct, final,- repeatedly, runT,- unfoldPlan, (~>))-import Data.Machine.Plan (PlanT, stop, yield)-import Data.Maybe (catMaybes, listToMaybe)--import Data.Solidity.Event (DecodeEvent (..))-import qualified Network.Ethereum.Api.Eth as Eth-import Network.Ethereum.Api.Types (Change (..),- DefaultBlock (..),- Filter (..), Quantity)-import Network.Ethereum.Contract.Event.Common-import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Run one block at a time.-event :: (DecodeEvent i ni e, JsonRpc m)- => Filter e- -> (e -> ReaderT Change m EventAction)- -> m ()-event fltr = eventMany fltr 0---- | 'eventMany' take s a filter, a window size, and a handler.------ It runs the handler over the results of 'eventLogs' results using--- 'reduceEventStream'. If no 'TerminateEvent' action is thrown and--- the toBlock is not yet reached, it then transitions to polling.----eventMany :: (DecodeEvent i ni e, JsonRpc m)- => Filter e- -> Integer- -> (e -> ReaderT Change m EventAction)- -> m ()-eventMany fltr window handler = do- start <- mkBlockNumber $ filterFromBlock fltr- let initState = FilterStreamState { fssCurrentBlock = start- , fssInitialFilter = fltr- , fssWindowSize = window- }- mLastProcessedFilterState <- reduceEventStream (playOldLogs initState) handler- case mLastProcessedFilterState of- Nothing -> startPolling fltr {filterFromBlock = BlockWithNumber start}- Just (act, lastBlock) -> do- end <- mkBlockNumber . filterToBlock $ fltr- when (act /= TerminateEvent && lastBlock < end) $- let pollingFromBlock = lastBlock + 1- in startPolling fltr {filterFromBlock = BlockWithNumber pollingFromBlock}- where- startPolling fltr' = do- filterId <- Eth.newFilter fltr'- let pollTo = filterToBlock fltr'- void $ reduceEventStream (pollFilter filterId pollTo) handler---- | Effectively a mapM_ over the machine using the given handler.-reduceEventStream :: Monad m- => MachineT m k [FilterChange a]- -> (a -> ReaderT Change m EventAction)- -> m (Maybe (EventAction, Quantity))-reduceEventStream filterChanges handler = fmap listToMaybe . runT $- filterChanges- ~> autoM (processChanges handler)- ~> asParts- ~> runWhile (\(act, _) -> act /= TerminateEvent)- ~> final- where- runWhile p = repeatedly $ do- v <- await- if p v- then yield v- else yield v >> stop- processChanges :: Monad m- => (a -> ReaderT Change m EventAction)- -> [FilterChange a]- -> m [(EventAction, Quantity)]- processChanges handler' changes = fmap catMaybes $- forM changes $ \FilterChange{..} -> do- act <- flip runReaderT filterChangeRawChange $- handler' filterChangeEvent- return ((,) act <$> changeBlockNumber filterChangeRawChange)---- | 'playLogs' streams the 'filterStream' and calls eth_getLogs on these 'Filter' objects.-playOldLogs :: (DecodeEvent i ni e, JsonRpc m)- => FilterStreamState e- -> MachineT m k [FilterChange e]-playOldLogs s = filterStream s- ~> autoM Eth.getLogs- ~> autoM (liftIO . mkFilterChanges)---- | Polls a filter from the given filterId until the target toBlock is reached.-pollFilter :: forall i ni e k m . (DecodeEvent i ni e, JsonRpc m)- => Quantity- -> DefaultBlock- -> MachineT m k [FilterChange e]-pollFilter i = construct . pollPlan i- where- pollPlan :: Quantity -> DefaultBlock -> PlanT k [FilterChange e] m ()- pollPlan fid end = do- bn <- lift $ Eth.blockNumber- if BlockWithNumber bn > end- then do- _ <- lift $ Eth.uninstallFilter fid- stop- else do- liftIO $ threadDelay 1000000- changes <- lift $ Eth.getFilterChanges fid >>= liftIO . mkFilterChanges- yield $ changes- pollPlan fid end----- | 'filterStream' is a machine which represents taking an initial filter--- over a range of blocks b1, ... bn (where bn is possibly `Latest` or `Pending`,--- but b1 is an actual block number), and making a stream of filter objects--- which cover this filter in intervals of size `windowSize`. The machine--- halts whenever the `fromBlock` of a spanning filter either (1) excedes then--- initial filter's `toBlock` or (2) is greater than the chain head's block number.-filterStream :: JsonRpc m- => FilterStreamState e- -> MachineT m k (Filter e)-filterStream initialPlan = unfoldPlan initialPlan filterPlan- where- filterPlan :: JsonRpc m => FilterStreamState e -> PlanT k (Filter e) m (FilterStreamState e)- filterPlan initialState@FilterStreamState{..} = do- end <- lift . mkBlockNumber $ filterToBlock fssInitialFilter- if fssCurrentBlock > end- then stop- else do- let to' = min end $ fssCurrentBlock + fromInteger fssWindowSize- filter' = fssInitialFilter { filterFromBlock = BlockWithNumber fssCurrentBlock- , filterToBlock = BlockWithNumber to'- }- yield filter'- filterPlan $ initialState { fssCurrentBlock = to' + 1 }------------------------------------------------------------------------------------eventNoFilter :: (DecodeEvent i ni e, JsonRpc m)- => Filter e- -> (e -> ReaderT Change m EventAction)- -> m ()-eventNoFilter fltr = eventManyNoFilter fltr 0--eventManyNoFilter :: (DecodeEvent i ni e, JsonRpc m)- => Filter e- -> Integer- -> (e -> ReaderT Change m EventAction)- -> m ()-eventManyNoFilter fltr window handler = do- start <- mkBlockNumber $ filterFromBlock fltr- let initState = FilterStreamState { fssCurrentBlock = start- , fssInitialFilter = fltr- , fssWindowSize = window- }- mLastProcessedFilterState <- reduceEventStream (playOldLogs initState) handler- case mLastProcessedFilterState of- Nothing ->- let pollingFilterState = FilterStreamState { fssCurrentBlock = start- , fssInitialFilter = fltr- , fssWindowSize = 1- }-- in void $ reduceEventStream (playNewLogs pollingFilterState) handler- Just (act, lastBlock) -> do- end <- mkBlockNumber . filterToBlock $ fltr- when (act /= TerminateEvent && lastBlock < end) $- let pollingFilterState = FilterStreamState { fssCurrentBlock = lastBlock + 1- , fssInitialFilter = fltr- , fssWindowSize = 1- }- in void $ reduceEventStream (playNewLogs pollingFilterState) handler---- | 'playLogs' streams the 'filterStream' and calls eth_getLogs on these 'Filter' objects.-playNewLogs :: (DecodeEvent i ni e, JsonRpc m)- => FilterStreamState e- -> MachineT m k [FilterChange e]-playNewLogs s =- newFilterStream s- ~> autoM Eth.getLogs- ~> autoM (liftIO . mkFilterChanges)--newFilterStream :: JsonRpc m- => FilterStreamState e- -> MachineT m k (Filter e)-newFilterStream initialState = unfoldPlan initialState filterPlan- where- filterPlan :: JsonRpc m => FilterStreamState e -> PlanT k (Filter e) m (FilterStreamState e)- filterPlan s@FilterStreamState{..} = do- if BlockWithNumber fssCurrentBlock > filterToBlock fssInitialFilter- then stop- else do- newestBlockNumber <- lift . pollTillBlockProgress $ fssCurrentBlock- let filter' = fssInitialFilter { filterFromBlock = BlockWithNumber fssCurrentBlock- , filterToBlock = BlockWithNumber newestBlockNumber- }- yield filter'- filterPlan $ s { fssCurrentBlock = newestBlockNumber + 1 }
@@ -1,33 +0,0 @@--- |--- Module : Network.Ethereum.Contract.Method--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum contract method support.-----module Network.Ethereum.Contract.Method where--import Data.Proxy (Proxy)-import Data.Solidity.Abi (AbiPut, AbiType (..))-import Data.Solidity.Abi.Generic ()-import Data.Solidity.Prim.Bytes (Bytes)---- | Smart contract method encoding-class AbiPut a => Method a where- -- | Solidity function selector- -- https://solidity.readthedocs.io/en/latest/abi-spec.html#function-selector-and-argument-encoding- selector :: Proxy a -> Bytes--instance AbiType () where- isDynamic _ = False--instance AbiPut ()---- | Fallback contract method-instance Method () where- selector _ = mempty
@@ -1,348 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Network.Ethereum.Contract.TH--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Contract abstraction is a high level interface of web3 library.------ The Application Binary Interface is the standard way to interact--- with contracts in the Ethereum ecosystem. It can be described by--- specially JSON file, like @ERC20.json@. This module use TemplateHaskell--- for generation described in Abi contract methods and events. Helper--- functions and instances inserted in haskell module and can be used in--- another modules or in place.------ @--- import Network.Ethereum.Contract.TH------ [abiFrom|examples/ERC20.json|]------ main = do--- runWeb3 $ event' def $--- \(Transfer _ to val) -> liftIO $ do print to--- print val--- @------ Full code example available in examples folder.-----module Network.Ethereum.Contract.TH- (- -- * The contract quasiquoters- abi- , abiFrom- ) where--import Control.Applicative ((<|>))-import Control.Monad (replicateM, (<=<))-import qualified Data.Aeson as Aeson (encode)-import Data.ByteArray (convert)-import qualified Data.Char as Char-import Data.Default (Default (..))-import Data.List (group, sort, uncons)-import Data.Tagged (Tagged)-import Data.Text (Text)-import qualified Data.Text as T-import qualified Data.Text.Lazy as LT-import qualified Data.Text.Lazy.Encoding as LT-import Data.Tuple.OneTuple (only)-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)-import Language.Haskell.TH-import Language.Haskell.TH.Quote-import Lens.Micro ((^?))-import Lens.Micro.Aeson (key, _JSON, _String)--import Data.Solidity.Abi (AbiGet, AbiPut, AbiType (..))-import Data.Solidity.Event (IndexedEvent (..))-import Data.Solidity.Prim (Address, Bytes, BytesN, IntN,- ListN, UIntN)-import Data.String.Extra (toLowerFirst, toUpperFirst)-import Language.Solidity.Abi (ContractAbi (..),- Declaration (..),- EventArg (..),- FunctionArg (..),- SolidityType (..), eventId,- methodId,- parseSolidityEventArgType,- parseSolidityFunctionArgType)-import Network.Ethereum.Account.Class (Account (..))-import Network.Ethereum.Api.Types (DefaultBlock (..),- Filter (..), TxReceipt)-import qualified Network.Ethereum.Contract as Contract (Contract (..))-import Network.Ethereum.Contract.Method (Method (..))-import Network.JsonRpc.TinyClient (JsonRpc)---- | Read contract Abi from file-abiFrom :: QuasiQuoter-abiFrom = quoteFile abi---- | QQ reader for contract Abi-abi :: QuasiQuoter-abi = QuasiQuoter- { quoteDec = quoteAbiDec- , quoteExp = quoteAbiExp- , quotePat = undefined- , quoteType = undefined }---- | Instance declaration with empty context-instanceD' :: Name -> TypeQ -> [DecQ] -> DecQ-instanceD' name insType =- instanceD (cxt []) (appT insType (conT name))---- | Simple data type declaration with one constructor-dataD' :: Name -> ConQ -> [Name] -> DecQ-dataD' name rec' derive =- dataD (cxt []) name [] Nothing [rec'] [derivClause Nothing (conT <$> derive)]---- | Simple function declaration-funD' :: Name -> [PatQ] -> ExpQ -> DecQ-funD' name p f = funD name [clause p (normalB f) []]---- | Abi and Haskell types association-toHSType :: SolidityType -> TypeQ-toHSType s = case s of- SolidityBool -> conT ''Bool- SolidityAddress -> conT ''Address- SolidityUint n -> appT (conT ''UIntN) (numLit n)- SolidityInt n -> appT (conT ''IntN) (numLit n)- SolidityString -> conT ''Text- SolidityBytesN n -> appT (conT ''BytesN) (numLit n)- SolidityBytes -> conT ''Bytes- SolidityTuple n as -> foldl ( \b a -> appT b $ toHSType a ) ( tupleT n ) as- SolidityVector ns a -> expandVector ns a- SolidityArray a -> appT listT $ toHSType a- where- numLit n = litT (numTyLit $ toInteger n)- expandVector :: [Int] -> SolidityType -> TypeQ- expandVector ns a = case uncons ns of- Just (n, rest) ->- if null rest- then conT ''ListN `appT` numLit n `appT` toHSType a- else conT ''ListN `appT` numLit n `appT` expandVector rest a- _ -> error $ "Impossible Nothing branch in `expandVector`: " ++ show ns ++ " " ++ show a--typeFuncQ :: FunctionArg -> TypeQ-typeFuncQ t = case parseSolidityFunctionArgType t of- Left e -> error $ "Unable to parse solidity type: " ++ show e- Right ty -> toHSType ty--typeEventQ :: EventArg -> TypeQ-typeEventQ t = case parseSolidityEventArgType t of- Left e -> error $ "Unable to parse solidity type: " ++ show e- Right ty -> toHSType ty----- | Function argument to TH type-funBangType :: FunctionArg -> BangTypeQ-funBangType fa =- bangType (bang sourceNoUnpack sourceStrict) (typeFuncQ fa)--funWrapper :: Bool- -- ^ Is constant?- -> Name- -- ^ Function name- -> Name- -- ^ Function data name- -> [FunctionArg]- -- ^ Parameters- -> Maybe [FunctionArg]- -- ^ Results- -> DecsQ-funWrapper c name dname args result = do- vars <- replicateM (length args) (newName "t")- a <- varT <$> newName "a"- t <- varT <$> newName "t"- m <- varT <$> newName "m"--- let params = appsE $ conE dname : fmap varE vars- inputT = fmap typeFuncQ args- outputT = case result of- Nothing -> [t|$t $m ()|]- Just [x] -> [t|$t $m $(typeFuncQ x)|]- Just xs -> let outs = fmap typeFuncQ xs- in [t|$t $m $(foldl appT (tupleT (length xs)) outs)|]-- sequence [- sigD name $ [t|- (JsonRpc $m, Account $a $t, Functor ($t $m)) =>- $(arrowing $ inputT ++ [if c then outputT else [t|$t $m TxReceipt|]])- |]- , if c- then funD' name (varP <$> vars) $ case result of- Just [_] -> [|only <$> call $(params)|]- _ -> [|call $(params)|]- else funD' name (varP <$> vars) $ [|send $(params)|]- ]- where- arrowing [] = error "Impossible branch call"- arrowing [x] = x- arrowing (x : xs) = [t|$x -> $(arrowing xs)|]--mkDecl :: Declaration -> DecsQ--mkDecl ev@(DEvent uncheckedName inputs anonymous) = sequence- [ dataD' indexedName (normalC indexedName (map (toBang <=< tag) indexedArgs)) derivingD- , instanceD' indexedName (conT ''Generic) []- , instanceD' indexedName (conT ''AbiType) [funD' 'isDynamic [] [|const False|]]- , instanceD' indexedName (conT ''AbiGet) []- , dataD' nonIndexedName (normalC nonIndexedName (map (toBang <=< tag) nonIndexedArgs)) derivingD- , instanceD' nonIndexedName (conT ''Generic) []- , instanceD' nonIndexedName (conT ''AbiType) [funD' 'isDynamic [] [|const False|]]- , instanceD' nonIndexedName (conT ''AbiGet) []- , dataD' allName (recC allName (map (\(n, a) -> (\(b,t) -> return (n,b,t)) <=< toBang <=< typeEventQ $ a) allArgs)) derivingD- , instanceD' allName (conT ''Generic) []- , instanceD (cxt [])- (pure $ ConT ''IndexedEvent `AppT` ConT indexedName `AppT` ConT nonIndexedName `AppT` ConT allName)- [funD' 'isAnonymous [] [|const anonymous|]]- , instanceD (cxt [])- (pure $ ConT ''Default `AppT` (ConT ''Filter `AppT` ConT allName))- [funD' 'def [] [|Filter Nothing Latest Latest $ Just topics|] ]- ]- where- name = if Char.toLower (T.head uncheckedName) == Char.toUpper (T.head uncheckedName) then "EvT" <> uncheckedName else uncheckedName- topics = [Just (T.unpack $ eventId ev)] <> replicate (length indexedArgs) Nothing- toBang ty = bangType (bang sourceNoUnpack sourceStrict) (return ty)- tag (n, ty) = AppT (AppT (ConT ''Tagged) (LitT $ NumTyLit n)) <$> typeEventQ ty- labeledArgs = zip [1..] inputs- indexedArgs = map (\(n, ea) -> (n, ea)) . filter (eveArgIndexed . snd) $ labeledArgs- indexedName = mkName $ toUpperFirst (T.unpack name) <> "Indexed"- nonIndexedArgs = map (\(n, ea) -> (n, ea)) . filter (not . eveArgIndexed . snd) $ labeledArgs- nonIndexedName = mkName $ toUpperFirst (T.unpack name) <> "NonIndexed"- allArgs :: [(Name, EventArg)]- allArgs = makeArgs name $ map (\i -> (eveArgName i, i)) inputs- allName = mkName $ toUpperFirst (T.unpack name)- derivingD = [''Show, ''Eq, ''Ord, ''GHC.Generic]---- TODO change this type name also--- | Method delcarations maker-mkDecl fun@(DFunction name constant inputs outputs) = (++)- <$> funWrapper constant fnName dataName inputs outputs- <*> sequence- [ dataD' dataName (normalC dataName bangInput) derivingD- , instanceD' dataName (conT ''Generic) []- , instanceD' dataName (conT ''AbiType)- [funD' 'isDynamic [] [|const False|]]- , instanceD' dataName (conT ''AbiPut) []- , instanceD' dataName (conT ''AbiGet) []- , instanceD' dataName (conT ''Method)- [funD' 'selector [] [|const mIdent|]]- ]- where mIdent = T.unpack (methodId $ fun {funName = T.replace "'" "" name})- dataName = mkName (toUpperFirst (T.unpack $ T.dropWhile (== '_') name <> "Data"))- fnName = mkName (toLowerFirst (T.unpack name))- bangInput = fmap funBangType inputs- derivingD = [''Show, ''Eq, ''Ord, ''GHC.Generic]--mkDecl _ = return []--mkContractDecl :: Text -> Text -> Text -> Declaration -> DecsQ-mkContractDecl name a b (DConstructor inputs) = sequence- [ dataD' dataName (normalC dataName bangInput) derivingD- , instanceD' dataName (conT ''Generic) []- , instanceD' dataName (conT ''AbiType)- [funD' 'isDynamic [] [|const False|]]- , instanceD' dataName (conT ''AbiPut) []- , instanceD' dataName (conT ''Method)- [funD' 'selector [] [|convert . Contract.bytecode|]]- , instanceD' dataName (conT ''Contract.Contract)- [ funD' 'Contract.abi [] [|const abiString|]- , funD' 'Contract.bytecode [] [|const bytecodeString|]- ]- ]- where abiString = T.unpack a- bytecodeString = T.unpack b- dataName = mkName (toUpperFirst (T.unpack $ name <> "Contract"))- bangInput = fmap funBangType inputs- derivingD = [''Show, ''Eq, ''Ord, ''GHC.Generic]--mkContractDecl _ _ _ _ = return []---- | this function gives appropriate names for the accessors in the following way--- | argName -> evArgName--- | arg_name -> evArg_name--- | _argName -> evArgName--- | "" -> evi , for example Transfer(address, address uint256) ~> Transfer {transfer1 :: address, transfer2 :: address, transfer3 :: Integer}-makeArgs :: Text -> [(Text, EventArg)] -> [(Name, EventArg)]-makeArgs prefix ns = go 1 ns- where- prefixStr = toLowerFirst . T.unpack $ prefix- go :: Int -> [(Text, EventArg)] -> [(Name, EventArg)]- go _ [] = []- go i ((h, ty) : tail')- | T.null h = (mkName $ prefixStr ++ show i, ty) : go (i + 1) tail'- | otherwise = (mkName . (++ "_") . (++) prefixStr . toUpperFirst . T.unpack $ h, ty) : go (i + 1) tail'--escape :: [Declaration] -> [Declaration]-escape = escapeEqualNames . fmap escapeReservedNames--escapeEqualNames :: [Declaration] -> [Declaration]-escapeEqualNames = concatMap go . group . sort- where go [] = []- go (x : xs) = x : zipWith appendToName xs hats- hats = [T.replicate n "'" | n <- [1..]]- appendToName d@(DFunction n _ _ _) a = d { funName = n <> a }- appendToName d@(DEvent n _ _) a = d { eveName = n <> a }- appendToName d _ = d--escapeReservedNames :: Declaration -> Declaration-escapeReservedNames d@(DFunction n _ _ _)- | isKeyword n = d { funName = n <> "'" }- | otherwise = d-escapeReservedNames d = d--isKeyword :: Text -> Bool-isKeyword = flip elem [ "as", "case", "of", "class"- , "data", "family", "instance"- , "default", "deriving", "do"- , "forall", "foreign", "hiding"- , "if", "then", "else", "import"- , "infix", "infixl", "infixr"- , "let", "in", "mdo", "module"- , "newtype", "proc", "qualified"- , "rec", "type", "where"- ]--constructorSpec :: String -> Maybe (Text, Text, Text, Declaration)-constructorSpec str = do- name <- str ^? key "contractName" . _String- abiValue <- str ^? key "abi"- bytecode <- str ^? key "bytecode" . _String- decl <- filter isContructor . unAbi <$> str ^? key "abi" . _JSON- return (name, jsonEncode abiValue, bytecode, toConstructor decl)- where- jsonEncode = LT.toStrict . LT.decodeUtf8 . Aeson.encode- isContructor (DConstructor _) = True- isContructor _ = False- toConstructor [] = DConstructor []- toConstructor [a] = a- toConstructor _ = error "Broken ABI: more that one constructor"---- | Abi to declarations converter-quoteAbiDec :: String -> DecsQ-quoteAbiDec str =- case str ^? _JSON <|> str ^? key "abi" . _JSON <|> str ^? key "compilerOutput" . key "abi" . _JSON of- Nothing -> fail "Unable to decode contract ABI"- Just (ContractAbi decs) -> do- funEvDecs <- concat <$> mapM mkDecl (escape decs)- case constructorSpec str of- Nothing -> return funEvDecs- Just (a, b, c, d) -> (funEvDecs ++) <$> mkContractDecl a b c d---- | Abi information string-quoteAbiExp :: String -> ExpQ-quoteAbiExp str =- case str ^? _JSON <|> str ^? key "abi" . _JSON of- Nothing -> fail "Unable to decode contract ABI"- Just a@(ContractAbi _) -> stringE (show a)
@@ -1,60 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ethereum.Ens--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ ENS offers a secure & decentralised way to address resources both on--- and off the blockchain using simple, human-readable names.------ This module provide basic ENS resolvers.-----module Network.Ethereum.Ens where--import Crypto.Hash (Digest, Keccak_256, hash)-import Data.ByteArray (convert, zero)-import Data.ByteArray.Sized (unsafeFromByteArrayAccess)-import Data.ByteString (ByteString)-import Data.ByteString.Char8 (split)-import Lens.Micro ((.~))--import Data.Solidity.Prim (Address, BytesN)-import Network.Ethereum.Account.Class (Account)-import Network.Ethereum.Account.Internal (AccountT, to, withParam)-import qualified Network.Ethereum.Ens.PublicResolver as Resolver-import qualified Network.Ethereum.Ens.Registry as Reg-import Network.JsonRpc.TinyClient (JsonRpc)---- | Namehash algorithm--- http://docs.ens.domains/en/latest/implementers.html#algorithm-namehash :: ByteString- -- ^ Domain name- -> BytesN 32- -- ^ Associated ENS node-namehash =- unsafeFromByteArrayAccess . foldr algo (zero 32) . split '.'- where- algo a b = sha3 (b <> sha3 a)- sha3 :: ByteString -> ByteString- sha3 bs = convert (hash bs :: Digest Keccak_256)---- | Get address of ENS domain-resolve :: (JsonRpc m, Account p (AccountT p))- => ByteString- -- ^ Domain name- -> AccountT p m Address- -- ^ Associated address-resolve name = do- r <- ensRegistry $ Reg.resolver node- withParam (to .~ r) $ Resolver.addr node- where- node = namehash name- ensRegistry = withParam $ to .~ "0x314159265dD8dbb310642f98f50C066173C1259b"
@@ -1,25 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}---- |--- Module : Network.Ethereum.Ens.PublicResolver--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum Name System public resolver smart contract.-----module Network.Ethereum.Ens.PublicResolver where--import Network.Ethereum.Contract.TH--[abi|[{"constant":true,"inputs":[{"name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"},{"name":"contentTypes","type":"uint256"}],"name":"ABI","outputs":[{"name":"contentType","type":"uint256"},{"name":"data","type":"bytes"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"x","type":"bytes32"},{"name":"y","type":"bytes32"}],"name":"setPubkey","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"content","outputs":[{"name":"ret","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"addr","outputs":[{"name":"ret","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"contentType","type":"uint256"},{"name":"data","type":"bytes"}],"name":"setABI","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"name","outputs":[{"name":"ret","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"name","type":"string"}],"name":"setName","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"hash","type":"bytes32"}],"name":"setContent","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"pubkey","outputs":[{"name":"x","type":"bytes32"},{"name":"y","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"addr","type":"address"}],"name":"setAddr","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"ensAddr","type":"address"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"a","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"hash","type":"bytes32"}],"name":"ContentChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"name","type":"string"}],"name":"NameChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"contentType","type":"uint256"}],"name":"ABIChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"x","type":"bytes32"},{"indexed":false,"name":"y","type":"bytes32"}],"name":"PubkeyChanged","type":"event"}]|]
@@ -1,25 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}---- |--- Module : Network.Ethereum.Ens.Registry--- Copyright : Alexander Krupenkin 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum Name System registry smart contract.-----module Network.Ethereum.Ens.Registry where--import Network.Ethereum.Contract.TH--[abi|[{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"resolver","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"label","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setSubnodeOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"ttl","type":"uint64"}],"name":"setTTL","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"ttl","outputs":[{"name":"","type":"uint64"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"label","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"resolver","type":"address"}],"name":"NewResolver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"ttl","type":"uint64"}],"name":"NewTTL","type":"event"}]|]
@@ -1,59 +0,0 @@-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Network.Ethereum.Transaction--- Copyright : Alexander Krupenkin 2018--- Roy Blankman 2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Transaction managing utils.-----module Network.Ethereum.Transaction where--import Data.ByteArray (ByteArray, convert)-import Data.ByteString (ByteString, empty)-import Data.Maybe (fromJust, fromMaybe)-import Data.RLP (packRLP, rlpEncode)-import Data.Word (Word8)--import Data.ByteArray.HexString (toBytes)-import Data.Solidity.Prim.Address (toHexString)-import Network.Ethereum.Api.Types (Call (..), Quantity (unQuantity))-import Network.Ethereum.Unit (Shannon, toWei)---- | Ethereum transaction packer.------ Two way RLP encoding of Ethereum transaction: for unsigned and signed.--- Packing scheme described in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md-encodeTransaction :: ByteArray ba- => Call- -- ^ Transaction call- -> Integer- -- ^ Chain ID- -> Maybe (Integer, Integer, Word8)- -- ^ Should contain signature when transaction signed- -> ba- -- ^ RLP encoded transaction-encodeTransaction Call{..} chain_id rsv =- let (to :: ByteString) = maybe mempty (toBytes . toHexString) callTo- (value :: Integer) = unQuantity $ fromJust callValue- (nonce :: Integer) = unQuantity $ fromJust callNonce- (gasPrice :: Integer) = maybe defaultGasPrice unQuantity callGasPrice- (gasLimit :: Integer) = unQuantity $ fromJust callGas- (input :: ByteString) = convert $ fromMaybe mempty callData-- in convert . packRLP $ case rsv of- -- Unsigned transaction by EIP155- Nothing -> rlpEncode (nonce, gasPrice, gasLimit, to, value, input, chain_id, empty, empty)- -- Signed transaction- Just (r, s, v) ->- let v' = fromIntegral v + 8 + 2 * chain_id -- Improved 'v' according to EIP155- in rlpEncode (nonce, gasPrice, gasLimit, to, value, input, v', r, s)- where- defaultGasPrice = toWei (10 :: Shannon)
@@ -1,191 +0,0 @@-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Network.Ethereum.Unit--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ethereum has a metric system of denominations used as units of ether.--- Each denomination has its own unique name (some bear the family name--- of seminal figures playing a role in evolution of computer science--- and cryptoeconomics). The smallest denomination aka base unit of ether--- is called 'Wei'. Below is a list of the named denominations and their--- value in 'Wei'. Following a common (although somewhat ambiguous) pattern,--- ether also designates a unit (of 1e18 or one quintillion 'Wei') of the--- currency. Note that the currency is not called Ethereum as many mistakenly--- think, nor is Ethereum a unit.------ In Haskell the Ethereum unit system presented as set of types: 'Wei',--- 'Szabo', 'Finney', etc. They are members of 'Unit' typeclass. Also available--- standart 'Show', 'Read', 'Num' operations over Ethereum units.------ @--- > let x = 1.2 :: Ether--- > toWei x--- 1200000000000000000------ > let y = x + 2--- > y--- 3.20 ether------ > let z = 15 :: Szabo--- > y + z------ <interactive>:6:5: error:--- • Couldn't match type ‘Network.Ethereum.Unit.U4’--- with ‘Network.Ethereum.Unit.U6’--- Expected type: Ether--- Actual type: Szabo--- @-----module Network.Ethereum.Unit- (- -- * The @Unit@ type class- Unit(..)-- -- * Ethereum value metrics- , Wei- , Babbage- , Lovelace- , Shannon- , Szabo- , Finney- , Ether- , KEther- ) where--import Data.Proxy (Proxy (..))-import Data.Text.Lazy (Text, unpack)-import GHC.Generics (Generic)-import GHC.Read-import Text.ParserCombinators.ReadPrec-import Text.Printf-import qualified Text.Read.Lex as L---- | Ethereum value unit-class (Read a, Show a, UnitSpec a, Fractional a) => Unit a where- -- | Make a value from integer wei- fromWei :: Integral b => b -> a-- -- | Convert a value to integer wei- toWei :: Integral b => a -> b---- | Unit specification-class UnitSpec a where- divider :: RealFrac b => proxy a -> b- name :: proxy a -> Text---- | Value abstraction-newtype Value a = MkValue { unValue :: Integer }- deriving (Eq, Ord, Generic)--mkValue :: forall a b . (UnitSpec a, RealFrac b) => b -> Value a-mkValue = MkValue . round . (* divider (Proxy :: Proxy a))--instance UnitSpec a => Unit (Value a) where- fromWei = MkValue . toInteger- toWei = fromInteger . unValue--instance UnitSpec a => UnitSpec (Value a) where- divider = const $ divider (Proxy :: Proxy a)- name = const $ name (Proxy :: Proxy a)--instance UnitSpec a => Num (Value a) where- a + b = MkValue (unValue a + unValue b)- a - b = MkValue (unValue a - unValue b)- a * b = MkValue (unValue a * unValue b)-- signum (MkValue a) = MkValue (abs a)- abs (MkValue a) = MkValue (abs a)- fromInteger = mkValue . fromIntegral--instance UnitSpec a => Fractional (Value a) where- a / b = MkValue (unValue a `div` unValue b)- fromRational = mkValue--instance UnitSpec a => Show (Value a) where- show val = printf "%F %s" (x / d :: Double) (name val)- where- x = fromIntegral (unValue val)- d = divider val--instance UnitSpec a => Read (Value a) where- readPrec = parens $ do- x <- readPrec- let res = mkValue x- resName = unpack (name res)- step $ expectP (L.Ident resName)- return res--data U0-data U1-data U2-data U3-data U4-data U5-data U6-data U7---- | Wei unit type-type Wei = Value U0--instance UnitSpec U0 where- divider = const 1- name = const "wei"---- | Babbage unit type-type Babbage = Value U1--instance UnitSpec U1 where- divider = const 1e3- name = const "babbage"---- | Lovelace unit type-type Lovelace = Value U2--instance UnitSpec U2 where- divider = const 1e6- name = const "lovelace"---- | Shannon unit type-type Shannon = Value U3--instance UnitSpec U3 where- divider = const 1e9- name = const "shannon"---- | Szabo unit type-type Szabo = Value U4--instance UnitSpec U4 where- divider = const 1e12- name = const "szabo"---- | Finney unit type-type Finney = Value U5--instance UnitSpec U5 where- divider = const 1e15- name = const "finney"---- | Ether unit type-type Ether = Value U6--instance UnitSpec U6 where- divider = const 1e18- name = const "ether"---- | KEther unit type-type KEther = Value U7--instance UnitSpec U7 where- divider = const 1e21- name = const "kether"
@@ -1,41 +0,0 @@--- |--- Module : Network.Ipfs.Api.Bitswap--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `bitswap` prefix.-----module Network.Ipfs.Api.Bitswap where--import Control.Monad.IO.Class (MonadIO (..))-import Data.Text (Text)--import Network.Ipfs.Api.Internal (_bitswapLedger,- _bitswapReprovide,- _bitswapStat, _bitswapWL)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (BitswapLedgerObj,- BitswapStatObj, BitswapWLObj,- ReprovideReturnType)-import Network.Ipfs.Client (IpfsT)---- | 'Show some diagnostic information on the bitswap agent.-stat :: MonadIO m => IpfsT m BitswapStatObj-stat = call _bitswapStat---- | Show blocks currently on the wantlist.-wl :: MonadIO m => IpfsT m BitswapWLObj-wl = call _bitswapWL---- | Show the current ledger for a peer.-ledger :: MonadIO m => Text -> IpfsT m BitswapLedgerObj-ledger = call . _bitswapLedger---- | Trigger reprovider.-reprovide :: MonadIO m => IpfsT m ReprovideReturnType-reprovide = call _bitswapReprovide
@@ -1,39 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ipfs.Api.Block--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `block` prefix.-----module Network.Ipfs.Api.Block where--import Control.Monad.IO.Class (MonadIO)-import Data.Aeson (decode)-import Data.Text (Text)-import Network.HTTP.Client (responseBody)--import Network.Ipfs.Api.Internal (_blockGet, _blockStat)-import Network.Ipfs.Api.Internal.Call (call, multipartCall)-import Network.Ipfs.Api.Types (BlockObj, BlockReturnType)-import Network.Ipfs.Client (IpfsT)---- | Get a raw IPFS block.-get :: MonadIO m => Text -> IpfsT m BlockReturnType-get = call . _blockGet---- | Store input as an IPFS block.-put :: MonadIO m => Text -> IpfsT m (Maybe BlockObj)-put = fmap decodeResponse . multipartCall "block/put"- where- decodeResponse = decode . responseBody---- | Print information of a raw IPFS block.-stat :: MonadIO m => Text -> IpfsT m BlockObj-stat = call . _blockStat
@@ -1,34 +0,0 @@--- |--- Module : Network.Ipfs.Api.Bootstrap--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `bootstrap` prefix.-----module Network.Ipfs.Api.Bootstrap where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)--import Network.Ipfs.Api.Internal (_bootstrapAdd, _bootstrapList,- _bootstrapRM)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (BootstrapObj)-import Network.Ipfs.Client (IpfsT)---- | Add peers to the bootstrap list.-add :: MonadIO m => Text -> IpfsT m BootstrapObj-add = call . _bootstrapAdd . Just---- | Show peers in the bootstrap list.-list :: MonadIO m => IpfsT m BootstrapObj-list = call _bootstrapList---- | Remove peers from the bootstrap list.-rm :: MonadIO m => Text -> IpfsT m BootstrapObj-rm = call . _bootstrapRM . Just
@@ -1,44 +0,0 @@--- |--- Module : Network.Ipfs.Api.Cid--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `cid` prefix.-----module Network.Ipfs.Api.Cid where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)--import Network.Ipfs.Api.Internal (_cidBase32, _cidBases,- _cidCodecs, _cidFormat,- _cidHashes)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (CidBasesObj, CidCodecsObj,- CidHashesObj, CidObj)-import Network.Ipfs.Client (IpfsT)---- | List available multibase encodings.-bases :: MonadIO m => IpfsT m [CidBasesObj]-bases = call _cidBases---- | List available CID codecs.-codecs :: MonadIO m => IpfsT m [CidCodecsObj]-codecs = call _cidCodecs---- | List available multihashes.-hashes :: MonadIO m => IpfsT m [CidHashesObj]-hashes = call _cidHashes---- | Convert CIDs to Base32 CID version 1.-base32 :: MonadIO m => Text -> IpfsT m CidObj-base32 = call . _cidBase32---- | Format and convert a CID in various useful ways.-format :: MonadIO m => Text -> IpfsT m CidObj-format = call . _cidFormat
@@ -1,40 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ipfs.Api.Config--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `config` prefix.-----module Network.Ipfs.Api.Config where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)-import Network.HTTP.Client (responseStatus)-import Network.HTTP.Types (Status (..))--import Network.Ipfs.Api.Internal (_configGet, _configSet)-import Network.Ipfs.Api.Internal.Call (call, multipartCall)-import Network.Ipfs.Api.Types (ConfigObj)-import Network.Ipfs.Client (IpfsT)----- | Get ipfs config values.-get :: MonadIO m => Text -> IpfsT m ConfigObj-get = call . _configGet---- | Set ipfs config values.-set :: MonadIO m => Text -> Maybe Text -> IpfsT m ConfigObj-set key = call . _configSet key---- | Replace the config with the file at <filePath>.-replace :: MonadIO m => Text -> IpfsT m Bool-replace = fmap isSuccess . multipartCall "config/replace"- where- isSuccess = (== 200) . statusCode . responseStatus
@@ -1,88 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ipfs.Api.Core--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Core IPFS API calls.-----module Network.Ipfs.Api.Core where--import qualified Codec.Archive.Tar as Tar-import Control.Monad.IO.Class (MonadIO (..))-import Data.Aeson (decode)-import Data.ByteString.Lazy (fromStrict)-import Data.Text (Text)-import Data.Text.Encoding (encodeUtf8)-import Network.HTTP.Client (responseBody)-import Servant.API.ContentTypes (NoContent)--import Network.Ipfs.Api.Internal (_cat, _dns, _get, _id,- _idPeer, _ls, _shutdown,- _version)-import Network.Ipfs.Api.Internal.Call (call, multipartCall,- streamCall)-import Network.Ipfs.Api.Internal.Stream (_ping, _refs, _refsLocal)-import Network.Ipfs.Api.Types (AddObj, CatReturnType,- DnsObj, IdObj, LsObj,- VersionObj)-import Network.Ipfs.Client (IpfsT)---- | Show IPFS object data.-cat :: MonadIO m => Text -> IpfsT m CatReturnType-cat = call . _cat---- | Add a file or directory to ipfs.-add :: MonadIO m => Text -> IpfsT m (Maybe AddObj)-add = fmap decodeResponse . multipartCall "add"- where- decodeResponse = decode . responseBody---- | List directory contents for Unix filesystem objects.-ls :: MonadIO m => Text -> IpfsT m LsObj-ls = call . _ls---- | Download IPFS objects.-get :: MonadIO m => Text -> IpfsT m Text-get hash = do- ret <- call $ _get hash- do liftIO $ Tar.unpack "getResponseDirectory" . Tar.read . fromStrict $ encodeUtf8 ret- pure "The content has been stored in getResponseDirectory."---- | Show ipfs version information.-version :: MonadIO m => IpfsT m VersionObj-version = call _version---- | Show ipfs node id info.-id :: MonadIO m => IpfsT m IdObj-id = call _id---- | Show ipfs node id info of the given peerId.-idPeer :: MonadIO m => Text -> IpfsT m IdObj-idPeer = call . _idPeer---- | Resolve DNS links.-dns :: MonadIO m => Text -> IpfsT m DnsObj-dns = call . _dns---- | List links (references) from an object.-refs :: MonadIO m => Text -> m ()-refs = streamCall . _refs---- | List all local references.-refsLocal :: MonadIO m => m ()-refsLocal = streamCall _refsLocal---- | Send echo request packets to IPFS hosts.-ping :: MonadIO m => Text -> m ()-ping = streamCall . _ping---- | Shut down the ipfs daemon.-shutdown :: MonadIO m => IpfsT m NoContent-shutdown = call _shutdown
@@ -1,40 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ipfs.Api.Dag--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `dag` prefix.-----module Network.Ipfs.Api.Dag where--import Control.Monad.IO.Class (MonadIO)-import Data.Aeson (decode)-import Data.Text (Text)-import Network.HTTP.Client (responseBody)--import Network.Ipfs.Api.Internal (_dagGet, _dagResolve)-import Network.Ipfs.Api.Internal.Call (call, multipartCall)-import Network.Ipfs.Api.Types (DagPutObj, DagResolveObj,- DagReturnType)-import Network.Ipfs.Client (IpfsT)---- | Get a dag node from ipfs.-get :: MonadIO m => Text -> IpfsT m DagReturnType-get = call . _dagGet---- | Resolve ipld block.-resolve :: MonadIO m => Text -> IpfsT m DagResolveObj-resolve = call . _dagResolve---- | Add a dag node to ipfs.-put :: MonadIO m => Text -> IpfsT m (Maybe DagPutObj)-put = fmap decodeResponse . multipartCall "dag/put"- where- decodeResponse = decode . responseBody
@@ -1,41 +0,0 @@--- |--- Module : Network.Ipfs.Api.Dht--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `dht` prefix.-----module Network.Ipfs.Api.Dht where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)--import Network.Ipfs.Api.Internal.Call (streamCall)-import Network.Ipfs.Api.Internal.Stream (_dhtFindPeer, _dhtFindProvs,- _dhtGet, _dhtProvide,- _dhtQuery)---- | Find the multiaddresses associated with the given peerId.-findPeer :: MonadIO m => Text -> m ()-findPeer = streamCall . _dhtFindPeer---- | Find peers that can provide a specific value, given a key.-findProvs :: MonadIO m => Text -> m ()-findProvs = streamCall . _dhtFindProvs---- | Given a key, query the routing system for its best value.-get :: MonadIO m => Text -> m ()-get cid = streamCall $ _dhtGet cid---- | Announce to the network that you are providing given values.-provide :: MonadIO m => Text -> m ()-provide = streamCall . _dhtProvide---- | Find the closest Peer IDs to a given peerID by querying the DHT.-query :: MonadIO m => Text -> m ()-query = streamCall . _dhtQuery
@@ -1,74 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ipfs.Api.Files--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `files` prefix.-----module Network.Ipfs.Api.Files where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text, pack)-import Network.HTTP.Client (responseStatus)-import Network.HTTP.Types (Status (..))-import Servant.API.ContentTypes (NoContent)--import Network.Ipfs.Api.Internal (_filesChcid, _filesCp,- _filesFlush, _filesLs,- _filesMkdir, _filesMv,- _filesRead, _filesRm,- _filesStat)-import Network.Ipfs.Api.Internal.Call (call, multipartCall)-import Network.Ipfs.Api.Types (FilesFlushObj, FilesLsObj,- FilesReadType, FilesStatObj)-import Network.Ipfs.Client (IpfsT)---- | Change the cid version or hash function of the root node of a given mfsPath.-chcidVer :: MonadIO m => Text -> Int -> IpfsT m NoContent-chcidVer mfsPath = call . _filesChcid (Just mfsPath) . Just---- | Copy files into mfs.-cp :: MonadIO m => Text -> Text -> IpfsT m NoContent-cp src = call . _filesCp (Just src) . Just---- | Flush a given path's data to disk.-flush :: MonadIO m => Text -> IpfsT m FilesFlushObj-flush = call . _filesFlush . Just---- | List directories in the local mutable namespace.-ls :: MonadIO m => Text -> IpfsT m FilesLsObj-ls = call . _filesLs . Just---- | Make directories.-mkdir :: MonadIO m => Text -> IpfsT m NoContent-mkdir = call . _filesMkdir . Just---- | Move files.-mv :: MonadIO m => Text -> Text -> IpfsT m NoContent-mv src = call . _filesMv (Just src) . Just---- | Read a file in a given mfs.-read :: MonadIO m => Text -> IpfsT m FilesReadType-read = call . _filesRead . Just---- | Display file status.-stat :: MonadIO m => Text -> IpfsT m FilesStatObj-stat = call . _filesStat . Just---- | Remove a file.-filesRm :: MonadIO m => Text -> IpfsT m NoContent-filesRm = call . flip _filesRm (Just True) . Just---- | Write to a mutable file in a given filesystem.-write :: MonadIO m => Text -> Text -> Bool -> IpfsT m Bool-write mfsPath filePath toTruncate = isSuccess <$> multipartCall uri filePath- where- uri = "files/write?arg=" <> mfsPath <> "&create=true" <> "&truncate=" <> (pack $ show toTruncate)- isSuccess = (200 ==) . statusCode . responseStatus
@@ -1,100 +0,0 @@--- |--- Module : Network.Ipfs.Api.Internal--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ IPFS API internals.-----module Network.Ipfs.Api.Internal where--import Data.Proxy (Proxy (..))-import Data.Text (Text)-import Servant.API-import Servant.Client (ClientM, client)--import Network.Ipfs.Api.Types--_ipfsApi :: Proxy IpfsApi-_ipfsApi = Proxy--_cat :: Text -> ClientM CatReturnType-_ls :: Text -> ClientM LsObj-_get :: Text -> ClientM GetReturnType-_swarmPeers :: ClientM SwarmPeersObj-_swarmConnect :: Maybe Text -> ClientM SwarmObj-_swarmDisconnect :: Maybe Text -> ClientM SwarmObj-_swarmFilters :: ClientM SwarmObj-_swarmFilterAdd :: Maybe Text -> ClientM SwarmObj-_swarmFilterRm :: Maybe Text -> ClientM SwarmObj-_bitswapStat :: ClientM BitswapStatObj-_bitswapWL :: ClientM BitswapWLObj-_bitswapLedger :: Text -> ClientM BitswapLedgerObj-_bitswapReprovide :: ClientM ReprovideReturnType-_cidBases :: ClientM [CidBasesObj]-_cidCodecs :: ClientM [CidCodecsObj]-_cidHashes :: ClientM [CidHashesObj]-_cidBase32 :: Text -> ClientM CidObj-_cidFormat :: Text -> ClientM CidObj-_blockGet :: Text -> ClientM BlockReturnType-_blockStat :: Text -> ClientM BlockObj-_dagGet :: Text -> ClientM DagReturnType-_dagResolve :: Text -> ClientM DagResolveObj-_configGet :: Text -> ClientM ConfigObj-_configSet :: Text -> Maybe Text -> ClientM ConfigObj-_objectData :: Text -> ClientM ObjectReturnType-_objectNew :: ClientM ObjectObj-_objectGetLinks :: Text -> ClientM ObjectLinksObj-_objectAddLink :: Text -> Maybe Text -> Maybe Text -> ClientM ObjectLinksObj-_objectRmLink :: Text -> Maybe Text -> ClientM ObjectLinksObj-_objectGet :: Text -> ClientM ObjectGetObj-_objectDiff :: Text -> Maybe Text -> ClientM ObjectDiffObj-_objectStat :: Text -> ClientM ObjectStatObj-_pinAdd :: Text -> ClientM PinObj-_pinRemove :: Text -> ClientM PinObj-_bootstrapAdd :: Maybe Text -> ClientM BootstrapObj-_bootstrapList :: ClientM BootstrapObj-_bootstrapRM :: Maybe Text -> ClientM BootstrapObj-_statsBw :: ClientM StatsBwObj-_statsRepo :: ClientM StatsRepoObj-_version :: ClientM VersionObj-_id :: ClientM IdObj-_idPeer :: Text -> ClientM IdObj-_dns :: Text -> ClientM DnsObj-_pubsubLs :: ClientM PubsubObj-_pubsubPeers :: ClientM PubsubObj-_pubsubPublish :: Text -> Maybe Text -> ClientM NoContent-_logLs :: ClientM LogLsObj-_logLevel :: Text -> Maybe Text -> ClientM LogLevelObj-_repoVersion :: ClientM RepoVersionObj-_repoFsck :: ClientM RepoFsckObj-_keyGen :: Text -> (Maybe Text) -> ClientM KeyDetailsObj-_keyList :: ClientM KeyObj-_keyRename :: Text -> (Maybe Text) -> ClientM KeyRenameObj-_keyRm :: Text -> ClientM KeyObj-_filesChcid :: Maybe Text -> Maybe Int -> ClientM NoContent-_filesCp :: Maybe Text -> Maybe Text -> ClientM NoContent-_filesFlush :: Maybe Text -> ClientM FilesFlushObj-_filesLs :: Maybe Text -> ClientM FilesLsObj-_filesMkdir :: Maybe Text -> ClientM NoContent-_filesMv :: Maybe Text -> Maybe Text -> ClientM NoContent-_filesRead :: Maybe Text -> ClientM FilesReadType-_filesRm :: Maybe Text -> Maybe Bool -> ClientM NoContent-_filesStat :: Maybe Text -> ClientM FilesStatObj-_shutdown :: ClientM NoContent--_cat :<|> _ls :<|> _get :<|> _swarmPeers :<|> _swarmConnect :<|> _swarmDisconnect :<|>- _swarmFilters :<|> _swarmFilterAdd :<|> _swarmFilterRm :<|> _bitswapStat :<|> _bitswapWL :<|> _bitswapLedger :<|>- _bitswapReprovide :<|> _cidBases :<|> _cidCodecs :<|> _cidHashes :<|> _cidBase32 :<|> _cidFormat :<|>- _blockGet :<|> _blockStat :<|> _dagGet :<|> _dagResolve :<|> _configGet :<|>- _configSet :<|> _objectData :<|> _objectNew :<|> _objectGetLinks :<|> _objectAddLink :<|> _objectRmLink :<|>- _objectGet :<|> _objectDiff :<|> _objectStat :<|> _pinAdd :<|> _pinRemove :<|> _bootstrapAdd :<|>- _bootstrapList :<|> _bootstrapRM :<|> _statsBw :<|> _statsRepo :<|> _version :<|> _id :<|> _idPeer :<|>- _dns :<|> _pubsubLs :<|> _pubsubPeers :<|> _pubsubPublish :<|> _logLs :<|> _logLevel :<|> _repoVersion :<|>- _repoFsck :<|> _keyGen :<|> _keyList :<|> _keyRename :<|> _keyRm :<|> _filesChcid :<|> _filesCp :<|>- _filesFlush :<|> _filesLs :<|> _filesMkdir :<|> _filesMv :<|> _filesRead :<|> _filesRm :<|> _filesStat :<|>- _shutdown = client _ipfsApi
@@ -1,58 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Network.Ipfs.Api.Internal.Call--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Module containing IPFS API call functions.-----module Network.Ipfs.Api.Internal.Call where--import Control.Monad.Except-import Control.Monad.Reader-import Data.ByteString.Lazy (ByteString)-import Data.Text (Text, pack, unpack)-import Network.HTTP.Client as Net hiding (Proxy)-import Network.HTTP.Client.MultipartFormData-import Servant.Client-import qualified Servant.Client.Streaming as S-import Servant.Types.SourceT (SourceT (..), foreach)--import Network.Ipfs.Client (IpfsT)---- | Regular Call function.-call :: MonadIO m => ClientM a -> IpfsT m a-call func = do- (manager', url, _) <- ask- resp <- liftIO (runClientM func (mkClientEnv manager' url))- case resp of- Left l -> throwError l- Right r -> return r---- | Call function for ‘multipart/form-data’.-multipartCall :: MonadIO m => Text -> Text -> IpfsT m (Net.Response ByteString)-multipartCall funcUri filePath = do- (reqManager, _, url) <- ask- req <- liftIO $ parseRequest $ unpack (pack url <> "/" <> funcUri )- liftIO $ flip httpLbs reqManager =<< formDataBody form req- where- form = [ partFileSource "file" $ unpack filePath ]---- | Call function for Streams.-streamCall :: (MonadIO m, Show a) => S.ClientM (SourceT IO a) -> m ()-streamCall func = liftIO $ do- manager' <- newManager defaultManagerSettings- S.withClientM func (S.mkClientEnv manager' (BaseUrl Http "localhost" 5001 "/api/v0")) $ \e -> case e of- Left err -> putStrLn $ "Error: " ++ show err- Right rs -> foreach fail print rs
@@ -1,41 +0,0 @@--- |--- Module : Network.Ipfs.Api.Internal.Stream--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Ipfs Stream API provider.-----module Network.Ipfs.Api.Internal.Stream where--import qualified Data.ByteString.Lazy.Char8 ()-import Data.Proxy-import Data.Text-import Network.HTTP.Client ()-import Servant.API-import Servant.Client.Streaming as S--import Network.Ipfs.Api.Types.Stream--_ipfsStreamApi :: Proxy IpfsStreamApi-_ipfsStreamApi = Proxy--_ping :: Text -> ClientM (SourceIO PingObj)-_dhtFindPeer :: Text -> ClientM (SourceIO DhtObj)-_dhtFindProvs :: Text -> ClientM (SourceIO DhtObj)-_dhtGet :: Text -> ClientM (SourceIO DhtObj)-_dhtProvide :: Text -> ClientM (SourceIO DhtObj)-_dhtQuery :: Text -> ClientM (SourceIO DhtObj)-_logTail :: ClientM (SourceIO LogReturnType)-_repoGc :: ClientM (SourceIO RepoGcObj)-_repoVerify :: ClientM (SourceIO RepoVerifyObj)-_refs :: Text -> ClientM (SourceIO RefsObj)-_refsLocal :: ClientM (SourceIO RefsObj)-_pubsubSubscribe :: Text -> ClientM (SourceIO PubsubSubObj)--_ping :<|> _dhtFindPeer :<|> _dhtFindProvs :<|> _dhtGet :<|> _dhtProvide :<|> _dhtQuery :<|>- _logTail :<|> _repoGc :<|> _repoVerify :<|> _refs :<|> _refsLocal :<|> _pubsubSubscribe = client _ipfsStreamApi
@@ -1,48 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Network.Ipfs.Api.Key--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `key` prefix.-----module Network.Ipfs.Api.Key where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)--import Network.Ipfs.Api.Internal (_keyGen, _keyList, _keyRename,- _keyRm)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (KeyDetailsObj, KeyObj,- KeyRenameObj)-import Network.Ipfs.Client (IpfsT)----- | 'List all local keypairs.-list :: MonadIO m => IpfsT m KeyObj-list = call _keyList---- | Create a new keypair.-gen :: MonadIO m => Text -> Text -> IpfsT m KeyDetailsObj-gen name = call . _keyGen name . Just---- | Rename a keypair.-rename :: MonadIO m => Text -> Text -> IpfsT m KeyRenameObj-rename was = call . _keyRename was . Just---- | Remove a keypair.-rm :: MonadIO m => Text -> IpfsT m KeyObj-rm = call . _keyRm-
@@ -1,42 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Network.Ipfs.Api.Log--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `log` prefix.-----module Network.Ipfs.Api.Log where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)--import Network.Ipfs.Api.Internal (_logLevel, _logLs)-import Network.Ipfs.Api.Internal.Call (call, streamCall)-import Network.Ipfs.Api.Internal.Stream (_logTail)-import Network.Ipfs.Api.Types (LogLevelObj, LogLsObj)-import Network.Ipfs.Client (IpfsT)----- | Change the logging level.-level :: MonadIO m => Text -> Text -> IpfsT m LogLevelObj-level subsystem = call . _logLevel subsystem . Just---- | Read the event log.-tail :: MonadIO m => m ()-tail = streamCall _logTail---- | List the logging subsystems.-ls :: MonadIO m => IpfsT m LogLsObj-ls = call _logLs
@@ -1,81 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ipfs.Api.Object--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `object` prefix.-----module Network.Ipfs.Api.Object where--import Control.Monad.IO.Class (MonadIO)-import Data.Aeson (decode)-import Data.Text (Text)-import Network.HTTP.Client (responseBody)--import Network.Ipfs.Api.Internal (_objectAddLink, _objectData,- _objectDiff, _objectGet,- _objectGetLinks, _objectNew,- _objectRmLink, _objectStat)-import Network.Ipfs.Api.Internal.Call (call, multipartCall)-import Network.Ipfs.Api.Types (ObjectDiffObj, ObjectGetObj,- ObjectLinksObj, ObjectObj,- ObjectReturnType,- ObjectStatObj)-import Network.Ipfs.Client (IpfsT)---- | Output the raw bytes of an IPFS object.-object :: MonadIO m => Text -> IpfsT m ObjectReturnType-object = call . _objectData---- | Create a new object from an ipfs template.-new :: MonadIO m => IpfsT m ObjectObj-new = call _objectNew---- | Output the links pointed to by the specified object.-getLinks :: MonadIO m => Text -> IpfsT m ObjectLinksObj-getLinks = call . _objectGetLinks---- | Add a Merkle-link to the given object and return the hash of the result.-addLink :: MonadIO m => Text -> Text -> Text -> IpfsT m ObjectLinksObj-addLink hash name = call . _objectAddLink hash (Just name) . Just---- | Remove a Merkle-link from the given object and return the hash of the result.-rmLink :: MonadIO m => Text -> Text -> IpfsT m ObjectLinksObj-rmLink key = call . _objectRmLink key . Just---- | Append data to what already exists in the data segment in the given object.-appendData :: MonadIO m => Text -> Text -> IpfsT m (Maybe ObjectLinksObj)-appendData key = fmap decodeResponse . multipartCall ("object/patch/append-data?arg=" <> key)- where- decodeResponse = decode . responseBody---- | Set the data field of an IPFS object.-setData :: MonadIO m => Text -> Text -> IpfsT m (Maybe ObjectLinksObj)-setData key = fmap decodeResponse . multipartCall ("object/patch/set-data?arg=" <> key)- where- decodeResponse = decode . responseBody---- | Get and serialize the DAG node named by key.-get :: MonadIO m => Text -> IpfsT m ObjectGetObj-get = call . _objectGet---- | 'Display the diff between two ipfs objects.-diff :: MonadIO m => Text -> Text -> IpfsT m ObjectDiffObj-diff firstKey = call . _objectDiff firstKey . Just---- | Store input as a DAG object, print its key.-put :: MonadIO m => Text -> IpfsT m (Maybe ObjectObj)-put = fmap decodeResponse . multipartCall "object/put"- where- decodeResponse = decode . responseBody---- | Get stats for the DAG node named by key.-objectStat :: MonadIO m => Text -> IpfsT m ObjectStatObj-objectStat = call . _objectStat
@@ -1,29 +0,0 @@--- |--- Module : Network.Ipfs.Api.Pin--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `pin` prefix.-----module Network.Ipfs.Api.Pin where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)--import Network.Ipfs.Api.Internal (_pinAdd, _pinRemove)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (PinObj)-import Network.Ipfs.Client (IpfsT)---- | Pin objects to local storage.-add :: MonadIO m => Text -> IpfsT m PinObj-add = call . _pinAdd---- | Remove pinned objects from local storage.-remove :: MonadIO m => Text -> IpfsT m PinObj-remove = call . _pinRemove
@@ -1,39 +0,0 @@--- |--- Module : Network.Ipfs.Api.Pubsub--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `pubsub` prefix.-----module Network.Ipfs.Api.Pubsub where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)-import Servant.API.ContentTypes (NoContent)--import Network.Ipfs.Api.Internal (_pubsubLs, _pubsubPeers,- _pubsubPublish)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (PubsubObj)-import Network.Ipfs.Client (IpfsT)---- | List subscribed topics by name.-ls :: MonadIO m => IpfsT m PubsubObj-ls = call _pubsubLs---- | List peers we are currently pubsubbing with.-peers :: MonadIO m => IpfsT m PubsubObj-peers = call _pubsubPeers---- | Publish a message to a given pubsub topic.-publish :: MonadIO m => Text -> Text -> IpfsT m NoContent-publish topic = call . _pubsubPublish topic . Just---- | Subscribe to messages on a given topic.---subscribe :: Text -> m ()---subscribe = pubsubCall . _pubsubSubscribe
@@ -1,37 +0,0 @@--- |--- Module : Network.Ipfs.Api.Repo--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `repo` prefix.-----module Network.Ipfs.Api.Repo where--import Control.Monad.IO.Class (MonadIO)--import Network.Ipfs.Api.Internal (_repoFsck, _repoVersion)-import Network.Ipfs.Api.Internal.Call (call, streamCall)-import Network.Ipfs.Api.Internal.Stream (_repoGc, _repoVerify)-import Network.Ipfs.Api.Types (RepoFsckObj, RepoVersionObj)-import Network.Ipfs.Client (IpfsT)---- | Show the repo version.-version :: MonadIO m => IpfsT m RepoVersionObj-version = call _repoVersion---- | Remove repo lockfiles.-fsck :: MonadIO m => IpfsT m RepoFsckObj-fsck = call _repoFsck---- | Perform a garbage collection sweep on the repo.-gc :: MonadIO m => m ()-gc = streamCall _repoGc---- | Verify all blocks in repo are not corrupted.-repoVerify :: MonadIO m => m ()-repoVerify = streamCall _repoVerify
@@ -1,28 +0,0 @@--- |--- Module : Network.Ipfs.Api.Stats--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `stats` prefix.-----module Network.Ipfs.Api.Stats where--import Control.Monad.IO.Class (MonadIO)--import Network.Ipfs.Api.Internal (_statsBw, _statsRepo)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (StatsBwObj, StatsRepoObj)-import Network.Ipfs.Client (IpfsT)---- | IPFS bandwidth information.-bw :: MonadIO m => IpfsT m StatsBwObj-bw = call _statsBw---- | Get stats for the currently used repo.-repo :: MonadIO m => IpfsT m StatsRepoObj-repo = call _statsRepo
@@ -1,49 +0,0 @@--- |--- Module : Network.Ipfs.Api.Swarm--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Api calls with `swarm` prefix.-----module Network.Ipfs.Api.Swarm where--import Control.Monad.IO.Class (MonadIO)-import Data.Text (Text)--import Network.Ipfs.Api.Internal (_swarmConnect,- _swarmDisconnect,- _swarmFilterAdd,- _swarmFilterRm, _swarmFilters,- _swarmPeers)-import Network.Ipfs.Api.Internal.Call (call)-import Network.Ipfs.Api.Types (SwarmObj, SwarmPeersObj)-import Network.Ipfs.Client (IpfsT)---- | List peers with open connections.-swarmPeers :: MonadIO m => IpfsT m SwarmPeersObj-swarmPeers = call _swarmPeers---- | Open connection to a given address. 'peerId' has to be of the format - /ipfs/id-connect :: MonadIO m => Text -> IpfsT m SwarmObj-connect = call . _swarmConnect . Just---- | Close connection to a given address. 'peerId' has to be of the format - /ipfs/id-disconnect :: MonadIO m => Text -> IpfsT m SwarmObj-disconnect = call . _swarmDisconnect . Just---- | Manipulate address filters.-filters :: MonadIO m => IpfsT m SwarmObj-filters = call _swarmFilters---- | Add an address filter. 'peerId' has to be of the format - /ip4/{IP addr of peer}/ipcidr/{ip network prefix}-filterAdd :: MonadIO m => Text -> IpfsT m SwarmObj-filterAdd = call . _swarmFilterAdd . Just---- | Remove an address filter.-filterRm :: MonadIO m => Text -> IpfsT m SwarmObj-filterRm = call . _swarmFilterRm . Just
@@ -1,823 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Network.Ipfs.Api.Types--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ IPFS API types.-----module Network.Ipfs.Api.Types where--import Control.Arrow (left)-import Control.Monad-import Data.Aeson-import Data.ByteString.Lazy (toStrict)-import qualified Data.ByteString.Lazy.Char8 ()-import qualified Data.HashMap.Strict as H-import Data.Int-import Data.Text (Text)-import qualified Data.Text.Encoding as TextS-import Data.Typeable-import Network.HTTP.Client ()-import qualified Network.HTTP.Media as M ((//))-import Servant.API--type CatReturnType = Text-type ReprovideReturnType = Text-type GetReturnType = Text-type BlockReturnType = Text-type DagReturnType = Text-type ObjectReturnType = Text-type FilesReadType = Text--data DirLink = DirLink- { dlName :: Text- , dlHash :: Text- , dlSize :: Int64- , dlContentType :: Int- , dlTarget :: Text- }- deriving (Show, Eq)--data DirObj = DirObj- { dirHash :: Text- , links :: [DirLink]- }- deriving (Show, Eq)--data AddObj = AddObj- { name :: Text- , hash :: Text- , size :: Text- }- deriving (Show, Eq)--instance FromJSON AddObj where- parseJSON (Object o) =- AddObj <$> o .: "Name"- <*> o .: "Hash"- <*> o .: "Size"-- parseJSON _ = mzero--data LsObj = LsObj- { objs :: [DirObj]- }- deriving (Show, Eq)--data SwarmStreamObj = SwarmStreamObj- { protocol :: Text- }- deriving (Show, Eq)--data SwarmPeerObj = SwarmPeerObj- { address :: Text- , direction :: Int- , latency :: Text- , muxer :: Text- , peer :: Text- , streams :: Maybe [SwarmStreamObj]- }- deriving (Show, Eq)--data SwarmPeersObj = SwarmPeersObj- { peers :: [SwarmPeerObj]- }- deriving (Show, Eq)--data SwarmObj = SwarmObj- { strings :: [Text]- }- deriving (Show, Eq)--data WantlistObj = WantlistObj- { forSlash :: Text- }- deriving (Show, Eq)--data BitswapStatObj = BitswapStatObj- { blocksReceived :: Int64- , blocksSent :: Int64- , dataReceived :: Int64- , dataSent :: Int64- , dupBlksReceived :: Int64- , dupDataReceived :: Int64- , messagesReceived :: Int64- , bitswapPeers :: [Text]- , provideBufLen :: Int- , wantlist :: [WantlistObj]- }- deriving (Show, Eq)--data BitswapWLObj = BitswapWLObj- { bitswapKeys :: [WantlistObj]- }- deriving (Show, Eq)--data BitswapLedgerObj = BitswapLedgerObj- { exchanged :: Int64- , ledgerPeer :: Text- , recv :: Int64- , sent :: Int64- , value :: Double- }- deriving (Show, Eq)--data CidBasesObj = CidBasesObj- { baseCode :: Int- , baseName :: Text- }- deriving (Show, Eq)--data CidCodecsObj = CidCodecsObj- { codecCode :: Int- , codecName :: Text- }- deriving (Show, Eq)--data CidHashesObj = CidHashesObj- { multihashCode :: Int- , multihashName :: Text- }- deriving (Show, Eq)--data CidObj = CidObj- { cidStr :: Text- , errorMsg :: Text- , formatted :: Text- }- deriving (Show, Eq)--data BlockObj = BlockObj- { key :: Text- , blockSize :: Int- }- deriving (Show, Eq)--data DagCidObj = DagCidObj- { cidSlash :: Text- }- deriving (Show, Eq)--data DagResolveObj = DagResolveObj- { cid :: DagCidObj- , remPath :: Text- }- deriving (Show, Eq)--data DagPutObj = DagPutObj- { putCid :: DagCidObj- }- deriving (Show, Eq)--data ConfigObj = ConfigObj- { configKey :: Text- , configValue :: Text- }- deriving (Show, Eq)--data ObjectLinkObj = ObjectLinkObj- { linkHash :: Text- , linkName :: Text- , linkSize :: Int64- }- deriving (Show, Eq)--data ObjectObj = ObjectObj- { newObjectHash :: Text- }- deriving (Show, Eq)--data ObjectLinksObj = WithLinks- { objectHash :: Text- , objectLinks :: [ObjectLinkObj]- }- | WithoutLinks- { objectHash :: Text- }- deriving (Show, Eq)--data ObjectGetObj = ObjectGetObj- { objectName :: Text- , objectGetLinks :: [ObjectLinkObj]- }- deriving (Show, Eq)--data ObjectStatObj = ObjectStatObj- { objBlockSize :: Int- , cumulativeSize :: Int- , dataSize :: Int- , objHash :: Text- , linksSize :: Int- , numLinks :: Int- }- deriving (Show, Eq)--data DiffObj = DiffObj- { diffSlash :: Text- }- deriving (Show, Eq)--data ObjectChangeObj = ObjectChangeObj- { after :: Maybe DiffObj- , before :: DiffObj- , path :: Text- , diffType :: Int- }- deriving (Show, Eq)--data ObjectDiffObj = ObjectDiffObj- { changes :: [ObjectChangeObj]- }- deriving (Show, Eq)--data PinObj = WithoutProgress- { pins :: [Text]- }- | WithProgress- { pins :: [Text]- , progress :: Int- }- deriving (Show, Eq)--data BootstrapObj = BootstrapObj- { bootstrapPeers :: [Text]- }- deriving (Show, Eq)--data StatsBwObj = StatsBwObj- { rateIn :: Double- , rateOut :: Double- , totalIn :: Int64- , totalOut :: Int64- }- deriving (Show, Eq)--data StatsRepoObj = StatsRepoObj- { numObjects :: Int64- , repoPath :: Text- , repoSize :: Int64- , storageMax :: Int64- , repoVersion :: Text- }- deriving (Show, Eq)--data VersionObj = VersionObj- { commit :: Text- , golang :: Text- , repo :: Text- , system :: Text- , version :: Text- }- deriving (Show, Eq)--data IdObj = IdObj- { addresses :: [Text]- , agentVersion :: Text- , id :: Text- , protocolVersion :: Text- , publicKey :: Text- }- deriving (Show, Eq)--data DnsObj = DnsObj- { dnsPath :: Text- }- deriving (Show, Eq)--data PubsubObj = PubsubObj- { pubsubStrings :: [Text]- }- deriving (Show, Eq)--data LogLsObj = LogLsObj- { logLsStrings :: [Text]- }- deriving (Show, Eq)--data LogLevelObj = LogLevelObj- { message :: Text- }- deriving (Show, Eq)--data RepoVersionObj = RepoVersionObj- { repoVer :: Text- }- deriving (Show, Eq)--data RepoFsckObj = RepoFsckObj- { repoMessage :: Text- }- deriving (Show, Eq)--data KeyDetailsObj = KeyDetailsObj- { keyId :: Text- , keyName :: Text- }- deriving (Show, Eq)--data KeyObj = KeyObj- { keys :: [KeyDetailsObj]- }- deriving (Show, Eq)--data KeyRenameObj = KeyRenameObj- { peerId :: Text- , now :: Text- , overwrite :: Bool- , was :: Text- }- deriving (Show, Eq)--data FilesStatObj = FilesStatObj- { fileObjectHash :: Text- , objectSize :: Int- , cumulativeObjectSize :: Int- , blocks :: Int- , objectType :: Text- }- deriving (Show, Eq)--data FilesEntryObj = FilesEntryObj- { entryName :: Text- , entryType :: Int- , entrySize :: Int- , entryHash :: Text- }- deriving (Show, Eq)--data FilesLsObj = FilesLsObj- { enteries :: [FilesEntryObj]- }- deriving (Show, Eq)--data FilesFlushObj = FilesFlushObj- { fileCid :: Text- }- deriving (Show, Eq)--instance FromJSON DirLink where- parseJSON (Object o) =- DirLink <$> o .: "Name"- <*> o .: "Hash"- <*> o .: "Size"- <*> o .: "Type"- <*> o .: "Target"-- parseJSON _ = mzero--instance FromJSON DirObj where- parseJSON (Object o) =- DirObj <$> o .: "Hash"- <*> o .: "Links"-- parseJSON _ = mzero--instance FromJSON LsObj where- parseJSON (Object o) =- LsObj <$> o .: "Objects"-- parseJSON _ = mzero---instance FromJSON SwarmStreamObj where- parseJSON (Object o) =- SwarmStreamObj <$> o .: "Protocol"-- parseJSON _ = mzero--instance FromJSON SwarmPeerObj where- parseJSON (Object o) =- SwarmPeerObj <$> o .: "Addr"- <*> o .: "Direction"- <*> o .: "Latency"- <*> o .: "Muxer"- <*> o .: "Peer"- <*> o .: "Streams"-- parseJSON _ = mzero--instance FromJSON SwarmPeersObj where- parseJSON (Object o) =- SwarmPeersObj <$> o .: "Peers"-- parseJSON _ = mzero---instance FromJSON SwarmObj where- parseJSON (Object o) =- SwarmObj <$> o .: "Strings"-- parseJSON _ = mzero--instance FromJSON WantlistObj where- parseJSON (Object o) =- WantlistObj <$> o .: "/"-- parseJSON _ = mzero--instance FromJSON BitswapStatObj where- parseJSON (Object o) =- BitswapStatObj <$> o .: "BlocksReceived"- <*> o .: "BlocksSent"- <*> o .: "DataReceived"- <*> o .: "DataSent"- <*> o .: "DupBlksReceived"- <*> o .: "DupDataReceived"- <*> o .: "MessagesReceived"- <*> o .: "Peers"- <*> o .: "ProvideBufLen"- <*> o .: "Wantlist"-- parseJSON _ = mzero---instance FromJSON BitswapWLObj where- parseJSON (Object o) =- BitswapWLObj <$> o .: "Keys"-- parseJSON _ = mzero--instance FromJSON BitswapLedgerObj where- parseJSON (Object o) =- BitswapLedgerObj <$> o .: "Exchanged"- <*> o .: "Peer"- <*> o .: "Recv"- <*> o .: "Sent"- <*> o .: "Value"-- parseJSON _ = mzero--instance FromJSON CidBasesObj where- parseJSON (Object o) =- CidBasesObj <$> o .: "Code"- <*> o .: "Name"-- parseJSON _ = mzero--instance FromJSON CidCodecsObj where- parseJSON (Object o) =- CidCodecsObj <$> o .: "Code"- <*> o .: "Name"-- parseJSON _ = mzero--instance FromJSON CidHashesObj where- parseJSON (Object o) =- CidHashesObj <$> o .: "Code"- <*> o .: "Name"-- parseJSON _ = mzero--instance FromJSON CidObj where- parseJSON (Object o) =- CidObj <$> o .: "CidStr"- <*> o .: "ErrorMsg"- <*> o .: "Formatted"-- parseJSON _ = mzero--instance FromJSON BlockObj where- parseJSON (Object o) =- BlockObj <$> o .: "Key"- <*> o .: "Size"-- parseJSON _ = mzero--instance FromJSON DagCidObj where- parseJSON (Object o) =- DagCidObj <$> o .: "/"-- parseJSON _ = mzero--instance FromJSON DagResolveObj where- parseJSON (Object o) =- DagResolveObj <$> o .: "Cid"- <*> o .: "RemPath"-- parseJSON _ = mzero--instance FromJSON DagPutObj where- parseJSON (Object o) =- DagPutObj <$> o .: "Cid"-- parseJSON _ = mzero--instance FromJSON ConfigObj where- parseJSON (Object o) =- ConfigObj <$> o .: "Key"- <*> o .: "Value"-- parseJSON _ = mzero--instance FromJSON ObjectLinkObj where- parseJSON (Object o) =- ObjectLinkObj <$> o .: "Hash"- <*> o .: "Name"- <*> o .: "Size"-- parseJSON _ = mzero--instance FromJSON ObjectObj where- parseJSON (Object o) =- ObjectObj <$> o .: "Hash"-- parseJSON _ = mzero--instance FromJSON ObjectLinksObj where- parseJSON (Object v) =- case H.lookup "Links" v of- Just (_) -> WithLinks <$> v .: "Hash"- <*> v .: "Links"-- Nothing ->- case H.lookup "Hash" v of- Just (_) -> WithoutLinks <$> v .: "Hash"- Nothing -> mzero-- parseJSON _ = mzero--instance FromJSON ObjectGetObj where- parseJSON (Object o) =- ObjectGetObj <$> o .: "Data"- <*> o .: "Links"-- parseJSON _ = mzero--instance FromJSON ObjectStatObj where- parseJSON (Object o) =- ObjectStatObj <$> o .: "BlockSize"- <*> o .: "CumulativeSize"- <*> o .: "DataSize"- <*> o .: "Hash"- <*> o .: "LinksSize"- <*> o .: "NumLinks"-- parseJSON _ = mzero--instance FromJSON ObjectChangeObj where- parseJSON (Object o) =- ObjectChangeObj <$> o .: "After"- <*> o .: "Before"- <*> o .: "Path"- <*> o .: "Type"-- parseJSON _ = mzero--instance FromJSON DiffObj where- parseJSON (Object o) =- DiffObj <$> o .: "/"-- parseJSON _ = mzero--instance FromJSON ObjectDiffObj where- parseJSON (Object o) =- ObjectDiffObj <$> o .: "Changes"-- parseJSON _ = mzero--instance FromJSON PinObj where- parseJSON (Object v) =- case H.lookup "Progress" v of- Just (_) -> WithProgress <$> v .: "Pins"- <*> v .: "Progress"-- Nothing ->- case H.lookup "Pins" v of- Just (_) -> WithoutProgress <$> v .: "Pins"- Nothing -> mzero-- parseJSON _ = mzero--instance FromJSON BootstrapObj where- parseJSON (Object o) =- BootstrapObj <$> o .: "Peers"-- parseJSON _ = mzero--instance FromJSON StatsBwObj where- parseJSON (Object o) =- StatsBwObj <$> o .: "RateIn"- <*> o .: "RateOut"- <*> o .: "TotalIn"- <*> o .: "TotalOut"-- parseJSON _ = mzero--instance FromJSON StatsRepoObj where- parseJSON (Object o) =- StatsRepoObj <$> o .: "NumObjects"- <*> o .: "RepoPath"- <*> o .: "RepoSize"- <*> o .: "StorageMax"- <*> o .: "Version"-- parseJSON _ = mzero--instance FromJSON VersionObj where- parseJSON (Object o) =- VersionObj <$> o .: "Commit"- <*> o .: "Golang"- <*> o .: "Repo"- <*> o .: "System"- <*> o .: "Version"-- parseJSON _ = mzero--instance FromJSON IdObj where- parseJSON (Object o) =- IdObj <$> o .: "Addresses"- <*> o .: "AgentVersion"- <*> o .: "ID"- <*> o .: "ProtocolVersion"- <*> o .: "PublicKey"-- parseJSON _ = mzero--instance FromJSON DnsObj where- parseJSON (Object o) =- DnsObj <$> o .: "Path"-- parseJSON _ = mzero--instance FromJSON PubsubObj where- parseJSON (Object o) =- PubsubObj <$> o .: "Strings"-- parseJSON _ = mzero--instance FromJSON LogLsObj where- parseJSON (Object o) =- LogLsObj <$> o .: "Strings"-- parseJSON _ = mzero--instance FromJSON LogLevelObj where- parseJSON (Object o) =- LogLevelObj <$> o .: "Message"-- parseJSON _ = mzero--instance FromJSON RepoVersionObj where- parseJSON (Object o) =- RepoVersionObj <$> o .: "Version"-- parseJSON _ = mzero--instance FromJSON RepoFsckObj where- parseJSON (Object o) =- RepoFsckObj <$> o .: "Message"-- parseJSON _ = mzero---instance FromJSON KeyDetailsObj where- parseJSON (Object o) =- KeyDetailsObj <$> o .: "Id"- <*> o .: "Name"-- parseJSON _ = mzero--instance FromJSON KeyObj where- parseJSON (Object o) =- KeyObj <$> o .: "Keys"-- parseJSON _ = mzero--instance FromJSON KeyRenameObj where- parseJSON (Object o) =- KeyRenameObj <$> o .: "Id"- <*> o .: "Now"- <*> o .: "Overwrite"- <*> o .: "Was"-- parseJSON _ = mzero--instance FromJSON FilesStatObj where- parseJSON (Object o) =- FilesStatObj <$> o .: "Hash"- <*> o .: "Size"- <*> o .: "CumulativeSize"- <*> o .: "Blocks"- <*> o .: "Type"-- parseJSON _ = mzero--instance FromJSON FilesEntryObj where- parseJSON (Object o) =- FilesEntryObj <$> o .: "Name"- <*> o .: "Type"- <*> o .: "Size"- <*> o .: "Hash"-- parseJSON _ = mzero--instance FromJSON FilesLsObj where- parseJSON (Object o) =- FilesLsObj <$> o .: "Entries"-- parseJSON _ = mzero--instance FromJSON FilesFlushObj where- parseJSON (Object o) =- FilesFlushObj <$> o .: "Cid"-- parseJSON _ = mzero---- | Defining a content type same as PlainText without charset-data IpfsText deriving Typeable--instance Servant.API.Accept IpfsText where- contentType _ = "text" M.// "plain"---- | @left show . TextS.decodeUtf8' . toStrict@-instance MimeUnrender IpfsText Text where- mimeUnrender _ = left show . TextS.decodeUtf8' . toStrict----- | Defining a content type same as IpfsJSON-data IpfsJSON deriving Typeable--instance Servant.API.Accept IpfsJSON where- contentType _ = "application" M.// "json"---- | @left show . TextS.decodeUtf8' . toStrict@-instance MimeUnrender IpfsJSON Text where- mimeUnrender _ = left show . TextS.decodeUtf8' . toStrict--type IpfsApi = "cat" :> Capture "arg" Text :> Get '[IpfsText] CatReturnType- :<|> "ls" :> Capture "arg" Text :> Get '[JSON] LsObj- :<|> "get" :> Capture "arg" Text :> Get '[IpfsText] GetReturnType- :<|> "swarm" :> "peers" :> Get '[JSON] SwarmPeersObj- :<|> "swarm" :> "connect" :> QueryParam "arg" Text :> Get '[JSON] SwarmObj- :<|> "swarm" :> "disconnect" :> QueryParam "arg" Text :> Get '[JSON] SwarmObj- :<|> "swarm" :> "filters" :> Get '[JSON] SwarmObj- :<|> "swarm" :> "filters" :> "add" :> QueryParam "arg" Text :> Get '[JSON] SwarmObj- :<|> "swarm" :> "filters" :> "rm" :> QueryParam "arg" Text :> Get '[JSON] SwarmObj- :<|> "bitswap" :> "stat" :> Get '[JSON] BitswapStatObj- :<|> "bitswap" :> "wantlist" :> Get '[JSON] BitswapWLObj- :<|> "bitswap" :> "ledger" :> Capture "peerId" Text :> Get '[JSON] BitswapLedgerObj- :<|> "bitswap" :> "reprovide" :> Get '[IpfsText] ReprovideReturnType- :<|> "cid" :> "bases" :> Get '[JSON] [CidBasesObj]- :<|> "cid" :> "codecs" :> Get '[JSON] [CidCodecsObj]- :<|> "cid" :> "hashes" :> Get '[JSON] [CidHashesObj]- :<|> "cid" :> "base32" :> Capture "cid" Text :> Get '[JSON] CidObj- :<|> "cid" :> "format" :> Capture "cid" Text :> Get '[JSON] CidObj- :<|> "block" :> "get" :> Capture "key" Text :> Get '[IpfsText] BlockReturnType- :<|> "block" :> "stat" :> Capture "key" Text :> Get '[JSON] BlockObj- :<|> "dag" :> "get" :> Capture "ref" Text :> Get '[IpfsJSON] DagReturnType- :<|> "dag" :> "resolve" :> Capture "ref" Text :> Get '[JSON] DagResolveObj- :<|> "config" :> Capture "ref" Text :> Get '[JSON] ConfigObj- :<|> "config" :> Capture "arg" Text :> QueryParam "arg" Text :> Get '[JSON] ConfigObj- :<|> "object" :> "data" :> Capture "ref" Text :> Get '[IpfsText] ObjectReturnType- :<|> "object" :> "new" :> Get '[JSON] ObjectObj- :<|> "object" :> "links" :> Capture "ref" Text :> Get '[JSON] ObjectLinksObj- :<|> "object" :> "patch" :> "add-link" :> Capture "arg" Text- :> QueryParam "arg" Text :> QueryParam "arg" Text :> Get '[JSON] ObjectLinksObj- :<|> "object" :> "patch" :> "rm-link" :> Capture "arg" Text- :> QueryParam "arg" Text :> Get '[JSON] ObjectLinksObj- :<|> "object" :> "get" :> Capture "arg" Text :> Get '[JSON] ObjectGetObj- :<|> "object" :> "diff" :> Capture "arg" Text :> QueryParam "arg" Text :> Get '[JSON] ObjectDiffObj- :<|> "object" :> "stat" :> Capture "arg" Text :> Get '[JSON] ObjectStatObj- :<|> "pin" :> "add" :> Capture "arg" Text :> Get '[JSON] PinObj- :<|> "pin" :> "rm" :> Capture "arg" Text :> Get '[JSON] PinObj- :<|> "bootstrap" :> "add" :> QueryParam "arg" Text :> Get '[JSON] BootstrapObj- :<|> "bootstrap" :> "list" :> Get '[JSON] BootstrapObj- :<|> "bootstrap" :> "rm" :> QueryParam "arg" Text :> Get '[JSON] BootstrapObj- :<|> "stats" :> "bw" :> Get '[JSON] StatsBwObj- :<|> "stats" :> "repo" :> Get '[JSON] StatsRepoObj- :<|> "version" :> Get '[JSON] VersionObj- :<|> "id" :> Get '[JSON] IdObj- :<|> "id" :> Capture "arg" Text :> Get '[JSON] IdObj- :<|> "dns" :> Capture "arg" Text :> Get '[JSON] DnsObj- :<|> "pubsub" :> "ls" :> Get '[JSON] PubsubObj- :<|> "pubsub" :> "peers" :> Get '[JSON] PubsubObj- :<|> "pubsub" :> "pub" :> Capture "arg" Text :> QueryParam "arg" Text :> Get '[JSON] NoContent- :<|> "log" :> "ls" :> Get '[JSON] LogLsObj- :<|> "log" :> "level" :> Capture "arg" Text :> QueryParam "arg" Text :> Get '[JSON] LogLevelObj- :<|> "repo" :> "version" :> Get '[JSON] RepoVersionObj- :<|> "repo" :> "fsck" :> Get '[JSON] RepoFsckObj- :<|> "key" :> "gen" :> Capture "arg" Text :> QueryParam "type" Text :> Get '[JSON] KeyDetailsObj- :<|> "key" :> "list" :> Get '[JSON] KeyObj- :<|> "key" :> "rename" :> Capture "arg" Text :> QueryParam "arg" Text :> Get '[JSON] KeyRenameObj- :<|> "key" :> "rm" :> Capture "arg" Text :> Get '[JSON] KeyObj- :<|> "files" :> "chcid" :> QueryParam "arg" Text :> QueryParam "cid-version" Int :> Get '[JSON] NoContent- :<|> "files" :> "cp" :> QueryParam "arg" Text :> QueryParam "arg" Text :> Get '[JSON] NoContent- :<|> "files" :> "flush" :> QueryParam "arg" Text :> Get '[JSON] FilesFlushObj- :<|> "files" :> "ls" :> QueryParam "arg" Text :> Get '[JSON] FilesLsObj- :<|> "files" :> "mkdir" :> QueryParam "arg" Text :> Get '[JSON] NoContent- :<|> "files" :> "mv" :> QueryParam "arg" Text :> QueryParam "arg" Text :> Get '[JSON] NoContent- :<|> "files" :> "read" :> QueryParam "arg" Text :> Get '[IpfsText] FilesReadType- :<|> "files" :> "rm" :> QueryParam "arg" Text :> QueryParam "recursive" Bool :> Get '[JSON] NoContent- :<|> "files" :> "stat" :> QueryParam "arg" Text :> Get '[JSON] FilesStatObj- :<|> "shutdown" :> Get '[JSON] NoContent
@@ -1,154 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeOperators #-}---- |--- Module : Network.Ipfs.Api.Types.Stream--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Ipfs Stream API types.-----module Network.Ipfs.Api.Types.Stream where--import Control.Monad-import Data.Aeson-import qualified Data.ByteString.Lazy.Char8 ()-import Data.Int-import Data.Text-import Network.HTTP.Client ()-import Servant.API--import Network.Ipfs.Api.Types (IpfsText)--type LogReturnType = Text--data PingObj = PingObj- { success :: Bool- , text :: Text- , time :: Int64- }- deriving (Show, Eq)--data ResponseObj = ResponseObj- { addrs :: Maybe [Text]- , id :: Text- }- deriving (Show, Eq)--data DhtObj = DhtObj- { extra :: Text- , addrid :: Text- , responses :: Maybe [ResponseObj]- , addrType :: Int- }- deriving (Show, Eq)--data RepoKeyObj = RepoKeyObj- { repoSlash :: Text- }- deriving (Show, Eq)--data RepoGcObj = RepoGcObj- { repoKey :: RepoKeyObj- }- deriving (Show, Eq)--data RepoVerifyObj = RepoVerifyObj- { msg :: Text- , progress :: Int- }- deriving (Show, Eq)--data RefsObj = RefsObj- { error :: Text- , ref :: Text- }- deriving (Show, Eq)--data PubsubSubObj = PubsubSubObj- { mssgdata :: Text- , from :: Text- , seqno :: Text- , topicIDs :: [Text]- }- deriving (Show, Eq)--instance FromJSON PingObj where- parseJSON (Object o) =- PingObj <$> o .: "Success"- <*> o .: "Text"- <*> o .: "Time"-- parseJSON _ = mzero--instance FromJSON DhtObj where- parseJSON (Object o) =- DhtObj <$> o .: "Extra"- <*> o .: "ID"- <*> o .: "Responses"- <*> o .: "Type"-- parseJSON _ = mzero--instance FromJSON ResponseObj where- parseJSON (Object o) =- ResponseObj <$> o .: "Addrs"- <*> o .: "ID"-- parseJSON _ = mzero--instance FromJSON RepoKeyObj where- parseJSON (Object o) =- RepoKeyObj <$> o .: "/"-- parseJSON _ = mzero--instance FromJSON RepoGcObj where- parseJSON (Object o) =- RepoGcObj <$> o .: "Key"-- parseJSON _ = mzero--instance FromJSON RepoVerifyObj where- parseJSON (Object o) =- RepoVerifyObj <$> o .: "Msg"- <*> o .: "Progress"-- parseJSON _ = mzero--instance FromJSON RefsObj where- parseJSON (Object o) =- RefsObj <$> o .: "Err"- <*> o .: "Ref"-- parseJSON _ = mzero--instance FromJSON PubsubSubObj where- parseJSON (Object o) =- PubsubSubObj <$> o .: "data"- <*> o .: "from"- <*> o .: "seqno"- <*> o .: "topicIDs"-- parseJSON _ = mzero--type IpfsStreamApi = "ping" :> Capture "arg" Text :> StreamGet NewlineFraming JSON ( SourceIO PingObj )- :<|> "dht" :> "findpeer" :> Capture "arg" Text :> StreamGet NewlineFraming JSON ( SourceIO DhtObj )- :<|> "dht" :> "findprovs" :> Capture "arg" Text :> StreamGet NewlineFraming JSON ( SourceIO DhtObj )- :<|> "dht" :> "get" :> Capture "arg" Text :> StreamGet NewlineFraming JSON ( SourceIO DhtObj )- :<|> "dht" :> "provide" :> Capture "arg" Text :> StreamGet NewlineFraming JSON ( SourceIO DhtObj )- :<|> "dht" :> "query" :> Capture "arg" Text :> StreamGet NewlineFraming JSON ( SourceIO DhtObj )- :<|> "log" :> "tail" :> StreamGet NewlineFraming IpfsText ( SourceIO LogReturnType)- :<|> "repo" :> "gc" :> StreamGet NewlineFraming JSON ( SourceIO RepoGcObj)- :<|> "repo" :> "verify" :> StreamGet NewlineFraming JSON ( SourceIO RepoVerifyObj)- :<|> "refs" :> Capture "arg" Text :> StreamGet NewlineFraming JSON (SourceIO RefsObj)- :<|> "refs" :> "local" :> StreamGet NewlineFraming JSON (SourceIO RefsObj)- :<|> "pubsub" :> "sub" :> Capture "arg" Text :> StreamGet NewlineFraming JSON ( SourceIO PubsubSubObj )
@@ -1,47 +0,0 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}---- |--- Module : Network.Ipfs.Client--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ IPFS daemon HTTP client.-----module Network.Ipfs.Client where--import Control.Monad.Except-import Control.Monad.Reader-import Network.HTTP.Client as Net hiding (Proxy)-import Servant.Client--newtype IpfsT m a = IpfsT { unIpfs :: ReaderT (Manager, BaseUrl, String) (ExceptT ClientError m) a }- deriving ( Functor- , Applicative- , Monad- , MonadIO- , MonadReader (Manager, BaseUrl, String)- , MonadError ClientError- )--instance MonadTrans IpfsT where- lift = IpfsT . lift . lift--type Ipfs a = IpfsT IO a---- | 'IpfsT' monad runner.-runIpfs' :: BaseUrl -> Ipfs a -> IO ()-runIpfs' url ipfs = do- manager' <- liftIO $ newManager defaultManagerSettings- ret <- runExceptT (runReaderT (unIpfs ipfs) (manager', url, showBaseUrl url))- case ret of- Left err -> putStrLn $ "Error: " ++ show err- Right _ -> putStr ""---- | 'IpfsT' monad runner with default arguments.-runIpfs :: Ipfs a -> IO ()-runIpfs = runIpfs' (BaseUrl Http "localhost" 5001 "/api/v0")
@@ -1,217 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE UndecidableInstances #-}---- |--- Module : Network.JsonRpc.TinyClient--- Copyright : Alexander Krupenkin 2016-2018--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Tiny JSON-RPC 2.0 client.--- Functions for implementing the client side of JSON-RPC 2.0.--- See <http://www.jsonrpc.org/specification>.------ If you have monad with 'MonadIO', 'MonadThrow' and 'MonadReader' instances,--- it can be used as base for JSON-RPC calls.------ Example:------ @--- newtype MyMonad a = ...------ instance JsonRpc MyMonad------ foo :: Mymonad Text--- foo = remote "foo"--- @------ Arguments of function are stored into @params@ request array.------ Example:------ @--- myMethod :: JsonRpc m => Int -> Bool -> m String--- myMethod = remote "myMethod"--- @-----module Network.JsonRpc.TinyClient- (- -- * The JSON-RPC remote call monad- JsonRpc(..)- , MethodName-- -- * JSON-RPC client settings- , JsonRpcClient(..)- , defaultSettings-- -- * Error handling- , JsonRpcException(..)- , RpcError(..)- ) where--import Control.Applicative ((<|>))-import Control.Exception (Exception)-import Control.Monad ((<=<))-import Control.Monad.Catch (MonadThrow (..))-import Control.Monad.IO.Class (MonadIO (..))-import Control.Monad.State (MonadState, get)-import Crypto.Number.Generate (generateMax)-import Data.Aeson (FromJSON (..), ToJSON (..),- Value (String), eitherDecode, encode,- object, withObject, (.:), (.:?), (.=))-import Data.ByteString.Lazy (ByteString)-import Data.Text (Text, unpack)-import Network.HTTP.Client (Manager, RequestBody (RequestBodyLBS),- httpLbs, method, newManager,- parseRequest, requestBody,- requestHeaders, responseBody)-import Network.HTTP.Client.TLS (tlsManagerSettings)-import qualified Network.WebSockets as WS (Connection, receiveData,- sendTextData)---- | JSON-RPC monad constrait.-type JsonRpcM m = (MonadIO m, MonadThrow m, MonadState JsonRpcClient m)---- | JSON-RPC client state vars.-data JsonRpcClient = JsonRpcHttpClient- { jsonRpcManager :: Manager- -- ^ HTTP connection manager.- , jsonRpcServer :: String- -- ^ Remote server URI.- }- | JsonRpcWsClient- { jsonRpcWsConnection :: WS.Connection- -- ^ WebSocket connection.- }---- | Create default 'JsonRpcClient' settings.-defaultSettings :: MonadIO m- => String -- ^ JSON-RPC server URI- -> m JsonRpcClient-defaultSettings srv = liftIO $ JsonRpcHttpClient- <$> newManager tlsManagerSettings- <*> pure srv--instance Show JsonRpcClient where- show JsonRpcHttpClient{..} = "<JSON-RPC HTTP Client>"- show JsonRpcWsClient{..} = "<JSON-RPC WebSocket Client>"---- | JSON-RPC request.-data Request = Request- { rqMethod :: !Text- , rqId :: !Int- , rqParams :: !Value- }- deriving (Eq, Show)--instance ToJSON Request where- toJSON rq = object [ "jsonrpc" .= String "2.0"- , "method" .= rqMethod rq- , "params" .= rqParams rq- , "id" .= rqId rq- ]---- | JSON-RPC response.-data Response = Response- { rsResult :: !(Either RpcError Value)- }- deriving (Eq, Show)--instance FromJSON Response where- parseJSON =- withObject "JSON-RPC response object" $- \v -> Response <$>- (Right <$> v .: "result" <|> Left <$> v .: "error")---- | JSON-RPC error message-data RpcError = RpcError- { errCode :: !Int- , errMessage :: !Text- , errData :: !(Maybe Value)- }- deriving Eq--instance Show RpcError where- show (RpcError code msg dat) =- "JSON-RPC error " ++ show code ++ ": " ++ unpack msg- ++ ". Data: " ++ show dat--instance FromJSON RpcError where- parseJSON = withObject "JSON-RPC error object" $- \v -> RpcError <$> v .: "code"- <*> v .: "message"- <*> v .:? "data"--data JsonRpcException = ParsingException String- | CallException RpcError- deriving (Show, Eq)--instance Exception JsonRpcException--class JsonRpcM m => Remote m a | a -> m where- remote' :: ([Value] -> m ByteString) -> a--instance (ToJSON a, Remote m b) => Remote m (a -> b) where- remote' f x = remote' (\xs -> f (toJSON x : xs))--instance {-# INCOHERENT #-} (JsonRpcM m, FromJSON b) => Remote m (m b) where- remote' f = decodeResponse =<< f []---- | Name of called method.-type MethodName = Text---- | JSON-RPC call monad.-class JsonRpcM m => JsonRpc m where- -- | Remote call of JSON-RPC method.- remote :: Remote m a => MethodName -> a- {-# INLINE remote #-}- remote = remote' . call--call :: JsonRpcM m- => MethodName- -> [Value]- -> m ByteString-call m r = do- rid <- liftIO $ generateMax maxInt- connection . encode $ Request m (fromInteger rid) (toJSON r)- where- maxInt = toInteger (maxBound :: Int)- connection body = do- jsonRpcInstance <- get- case jsonRpcInstance of- JsonRpcHttpClient{..} -> do- request <- parseRequest jsonRpcServer- let request' = request {- requestBody = RequestBodyLBS body- , requestHeaders = [("Content-Type", "application/json")]- , method = "POST"- }- responseBody <$> liftIO (httpLbs request' jsonRpcManager)-- JsonRpcWsClient{..} -> liftIO $ do- WS.sendTextData jsonRpcWsConnection body- WS.receiveData jsonRpcWsConnection----decodeResponse :: (MonadThrow m, FromJSON a)- => ByteString- -> m a-decodeResponse = (tryParse . eitherDecode . encode)- <=< tryResult . rsResult- <=< tryParse . eitherDecode- where- tryParse = either (throwM . ParsingException) return- tryResult = either (throwM . CallException) return
@@ -1,28 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Account--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `account` prefix.-----module Network.Polkadot.Api.Account where--import Data.Text (Text)--import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Retrieves the next accountIndex as available on the node.-nextIndex :: JsonRpc m- => Text- -- ^ AccountId- -> m Int-{-# INLINE nextIndex #-}-nextIndex = remote "account_nextIndex"
@@ -1,78 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Author--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `author` prefix.-----module Network.Polkadot.Api.Author where--import Data.Text (Text)--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Returns true if the keystore has private keys for the given public key and key type.-hasKey :: JsonRpc m- => HexString- -- ^ Public key- -> Text- -- ^ Key type- -> m Bool-{-# INLINE hasKey #-}-hasKey = remote "author_hasKey"---- | Returns true if the keystore has private keys for the given session public keys.-hasSessionKeys :: JsonRpc m- => HexString- -- ^ Session keys- -> m Bool-{-# INLINE hasSessionKeys #-}-hasSessionKeys = remote "author_hasSessionKeys"---- | Insert a key into the keystore.-insertKey :: JsonRpc m- => Text- -- ^ Key type- -> Text- -- ^ Key secret URI- -> HexString- -- ^ Public key- -> m HexString-{-# INLINE insertKey #-}-insertKey = remote "author_insertKey"---- | Returns all pending extrinsics, potentially grouped by sender.-pendingExtrinsics :: JsonRpc m => m [HexString]-{-# INLINE pendingExtrinsics #-}-pendingExtrinsics = remote "author_pendingExtrinsics"---- | Remove given extrinsic from the pool and temporarily ban it to prevent reimporting.-removeExtrinsic :: JsonRpc m- => [HexString]- -- ^ Extrinsic or hash- -> m HexString-{-# INLINE removeExtrinsic #-}-removeExtrinsic = remote "author_removeExtrinsic"---- | Generate new session keys and returns the corresponding public keys.-rotateKeys :: JsonRpc m => m HexString-{-# INLINE rotateKeys #-}-rotateKeys = remote "author_rotateKeys"---- | Submit a fully formatted extrinsic for block inclusion.-submitExtrinsic :: JsonRpc m- => HexString- -- ^ Extrinsic- -> m HexString- -- ^ Hash-{-# INLINE submitExtrinsic #-}-submitExtrinsic = remote "author_submitExtrinsic"
@@ -1,26 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Babe--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `babe` prefix.-----module Network.Polkadot.Api.Babe where--import Data.Aeson (Object)--import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Returns data about which slots (primary or secondary) can be claimed--- in the current epoch with the keys in the keystore.-epochAuthorship :: JsonRpc m => m Object-{-# INLINE epochAuthorship #-}-epochAuthorship = remote "babe_epochAuthorship"
@@ -1,49 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Chain--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `chain` prefix.-----module Network.Polkadot.Api.Chain where--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))-import Network.Polkadot.Api.Types (Header, SignedBlock)---- | Get header and body of a relay chain block.-getBlock :: JsonRpc m- => Maybe HexString- -- ^ Block hash- -> m (Maybe SignedBlock)-{-# INLINE getBlock #-}-getBlock = remote "chain_getBlock"---- | Get the block hash for a specific block.-getBlockHash :: JsonRpc m- => Maybe Int- -- ^ Block number- -> m (Maybe HexString)-{-# INLINE getBlockHash #-}-getBlockHash = remote "chain_getBlockHash"---- | Get hash of the last finalized block in the canon chain.-getFinalizedHead :: JsonRpc m => m HexString-{-# INLINE getFinalizedHead #-}-getFinalizedHead = remote "chain_getFinalizedHead"---- | Retrieves the header for a specific block.-getHeader :: JsonRpc m- => Maybe HexString- -- ^ Block hash- -> m (Maybe Header)-{-# INLINE getHeader #-}-getHeader = remote "chain_getHeader"
@@ -1,67 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Childstate--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `childstate` prefix.-----module Network.Polkadot.Api.Childstate where--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Returns the keys with prefix from a child storage, leave empty to get all the keys.-getKeys :: JsonRpc m- => HexString- -- ^ Prefixed storage key- -> HexString- -- ^ Storage key- -> Maybe HexString- -- ^ Block hash- -> m [HexString]-{-# INLINE getKeys #-}-getKeys = remote "childstate_getKeys"---- | Returns a child storage entry at a specific block state.-getStorage :: JsonRpc m- => HexString- -- ^ Prefixed storage key- -> HexString- -- ^ Storage key- -> Maybe HexString- -- ^ Block hash- -> m (Maybe HexString)-{-# INLINE getStorage #-}-getStorage = remote "childstate_getStorage"---- | Returns the hash of a child storage entry at a block state-getStorageHash :: JsonRpc m- => HexString- -- ^ Prefixed storage key- -> HexString- -- ^ Storage key- -> Maybe HexString- -- ^ Block hash- -> m (Maybe HexString)-{-# INLINE getStorageHash #-}-getStorageHash = remote "childstate_getStorageHash"---- | Returns the size of a child storage entry at a block state.-getStorageSize :: JsonRpc m- => HexString- -- ^ Prefixed storage key- -> HexString- -- ^ Storage key- -> Maybe HexString- -- ^ Block hash- -> m (Maybe Int)-{-# INLINE getStorageSize #-}-getStorageSize = remote "childstate_getStorageSize"
@@ -1,54 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Contracts--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `contracts` prefix.-----module Network.Polkadot.Api.Contracts where--import Data.Text (Text)--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))-import Network.Polkadot.Api.Types (ContractCall, ContractExecResult)---- | Executes a call to a contract.-call :: JsonRpc m- => ContractCall- -- ^ Contract call- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m ContractExecResult-{-# INLINE call #-}-call = remote "contracts_call"---- | Returns the value under a specified storage key in a contract-getStorage :: JsonRpc m- => Text- -- ^ AccountId- -> HexString- -- ^ Storage key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m (Maybe HexString)-{-# INLINE getStorage #-}-getStorage = remote "contracts_getStorage"---- | Returns the projected time a given contract will be able to sustain paying its rent.-rentProjection :: JsonRpc m- => Text- -- ^ AccountId- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m (Maybe Int)-{-# INLINE rentProjection #-}-rentProjection = remote "contracts_rentProjection"
@@ -1,42 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Engine--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `engine` prefix.-----module Network.Polkadot.Api.Engine where--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))-import Network.Polkadot.Api.Types (CreatedBlock)---- | Instructs the manual-seal authorship task to create a new block.-createBlock :: JsonRpc m- => Bool- -- ^ Create empty- -> Bool- -- ^ Finalize- -> Maybe HexString- -- ^ Parent hash- -> m CreatedBlock-{-# INLINE createBlock #-}-createBlock = remote "engine_createBlock"---- | Instructs the manual-seal authorship task to finalize a block.-finalizeBlock :: JsonRpc m- => HexString- -- ^ Block hash- -> Maybe HexString- -- ^ Justification- -> m Bool-{-# INLINE finalizeBlock #-}-finalizeBlock = remote "engine_finalizeBlock"
@@ -1,25 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Grandpa--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `grandpa` prefix.-----module Network.Polkadot.Api.Grandpa where--import Data.Aeson (Object)--import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Returns the state of the current best round state as well as the ongoing background rounds.-roundState :: JsonRpc m => m Object-{-# INLINE roundState #-}-roundState = remote "grandpa_roundState"
@@ -1,42 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Offchain--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `offchain` prefix.-----module Network.Polkadot.Api.Offchain where--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))-import Network.Polkadot.Api.Types (StorageKind)---- | Get offchain local storage under given key and prefix.-localStorageGet :: JsonRpc m- => StorageKind- -- ^ Offchain storage kind- -> HexString- -- ^ Key- -> m (Maybe HexString)-{-# INLINE localStorageGet #-}-localStorageGet = remote "offchain_localStorageGet"---- | Set offchain local storage under given key and prefix-localStorageSet :: JsonRpc m- => StorageKind- -- ^ Offchain storage kind- -> HexString- -- ^ Key- -> HexString- -- ^ Value- -> m ()-{-# INLINE localStorageSet #-}-localStorageSet = remote "offchain_localStorageSet"
@@ -1,30 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Payment--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `payment` prefix.-----module Network.Polkadot.Api.Payment where--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))-import Network.Polkadot.Api.Types (RuntimeDispatchInfo)---- | Retrieves the fee information for an encoded extrinsic.-queryInfo :: JsonRpc m- => HexString- -- ^ Extrinsic- -> Maybe HexString- -- ^ Block hash or nothing for head block- -> m RuntimeDispatchInfo-{-# INLINE queryInfo #-}-queryInfo = remote "payment_queryInfo"
@@ -1,25 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.Rpc--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `rpc` prefix.-----module Network.Polkadot.Api.Rpc where--import Data.Aeson (Value)--import Network.JsonRpc.TinyClient (JsonRpc (..))---- | Retrieves the list of RPC methods that are exposed by the node.-methods :: JsonRpc m => m Value-{-# INLINE methods #-}-methods = remote "rpc_methods"
@@ -1,184 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.State--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `state` prefix.-----module Network.Polkadot.Api.State where--import Data.Text (Text)--import Data.ByteArray.HexString (HexString)-import Network.JsonRpc.TinyClient (JsonRpc (..))-import Network.Polkadot.Api.Types (Metadata, ReadProof,- RuntimeVersion, StorageChangeSet)---- | Perform a call to a builtin on the chain.-call :: JsonRpc m- => Text- -- ^ Call method- -> HexString- -- ^ Call data- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m HexString-{-# INLINE call #-}-call = remote "state_call"---- | Retrieves the keys with prefix of a specific child storage.-getChildKeys :: JsonRpc m- => HexString- -- ^ Child storage key- -> HexString- -- ^ Child definition- -> Int- -- ^ Child type- -> HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m [HexString]-{-# INLINE getChildKeys #-}-getChildKeys = remote "state_getChildKeys"---- | Retrieves the child storage for a key.-getChildStorage :: JsonRpc m- => HexString- -- ^ Child storage key- -> HexString- -- ^ Child definition- -> Int- -- ^ Child type- -> HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m HexString-{-# INLINE getChildStorage #-}-getChildStorage = remote "state_getChildStorage"---- | Retrieves the child storage hash.-getChildStorageHash :: JsonRpc m- => HexString- -- ^ Child storage key- -> HexString- -- ^ Child definition- -> Int- -- ^ Child type- -> HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m HexString-{-# INLINE getChildStorageHash #-}-getChildStorageHash = remote "state_getChildStorageHash"---- | Retrieves the child storage size.-getChildStorageSize :: JsonRpc m- => HexString- -- ^ Child storage key- -> HexString- -- ^ Child definition- -> Int- -- ^ Child type- -> HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m Int-{-# INLINE getChildStorageSize #-}-getChildStorageSize = remote "state_getChildStorageSize"---- | Retrieves the keys with a certain prefix.-getKeys :: JsonRpc m- => HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m [HexString]-{-# INLINE getKeys #-}-getKeys = remote "state_getKeys"---- | Returns the runtime metadata.-getMetadata :: JsonRpc m => m Metadata-{-# INLINE getMetadata #-}-getMetadata = remote "state_getMetadata"---- | Returns proof of storage entries at a specific block state.-getReadProof :: JsonRpc m- => [HexString]- -- ^ Keys- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m ReadProof-{-# INLINE getReadProof #-}-getReadProof = remote "state_getReadProof"---- | Get runtime version.-getRuntimeVersion :: JsonRpc m- => Maybe HexString- -- ^ Block hash or nothing for head- -> m RuntimeVersion-{-# INLINE getRuntimeVersion #-}-getRuntimeVersion = remote "state_getRuntimeVersion"---- | Retrieves the storage for a key.-getStorage :: JsonRpc m- => HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m HexString-{-# INLINE getStorage #-}-getStorage = remote "state_getStorage"---- | Retrieves the storage hash.-getStorageHash :: JsonRpc m- => HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m HexString-{-# INLINE getStorageHash #-}-getStorageHash = remote "state_getStorageHash"---- | Retrieves the storage size.-getStorageSize :: JsonRpc m- => HexString- -- ^ Key- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m Int-{-# INLINE getStorageSize #-}-getStorageSize = remote "state_getStorageSize"---- | Query historical storage entries (by key) starting from a start block.-queryStorage :: JsonRpc m- => [HexString]- -- ^ Storage keys- -> HexString- -- ^ From block hash- -> Maybe HexString- -- ^ To block hash- -> m [StorageChangeSet]-{-# INLINE queryStorage #-}-queryStorage = remote "state_queryStorage"---- | Query storage entries (by key) starting at block hash given as the second parameter.-queryStorageAt :: JsonRpc m- => [HexString]- -- ^ Storage keys- -> Maybe HexString- -- ^ Block hash or nothing for head- -> m [StorageChangeSet]-{-# INLINE queryStorageAt #-}-queryStorageAt = remote "state_queryStorageAt"
@@ -1,97 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Polkadot.Api.System--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot RPC methods with `system` prefix.-----module Network.Polkadot.Api.System where--import Data.Aeson (Object)-import Data.Text (Text)--import Network.JsonRpc.TinyClient (JsonRpc (..))-import Network.Polkadot.Api.Types (ChainType, Health, NodeRole,- PeerInfo)---- | Adds a reserved peer.-addReservedPeer :: JsonRpc m- => Text- -- ^ Peer URI- -> m Text-{-# INLINE addReservedPeer #-}-addReservedPeer = remote "system_addReservedPeer"---- | Retrieves the chain.-chain :: JsonRpc m => m Text-{-# INLINE chain #-}-chain = remote "system_chain"---- | Retrieves the chain type.-chainType :: JsonRpc m => m ChainType-{-# INLINE chainType #-}-chainType = remote "system_chainType"---- | Return health status of the node.-health :: JsonRpc m => m Health-{-# INLINE health #-}-health = remote "system_health"---- | The addresses include a trailing /p2p/ with the local PeerId,--- and are thus suitable to be passed to addReservedPeer or as a bootnode address.-localListenAddresses :: JsonRpc m => m [Text]-{-# INLINE localListenAddresses #-}-localListenAddresses = remote "system_localListenAddresses"---- | Returns the base58-encoded PeerId of the node.-localPeerId :: JsonRpc m => m Text-{-# INLINE localPeerId #-}-localPeerId = remote "system_localPeerId"---- | Retrieves the node name.-name :: JsonRpc m => m Text-{-# INLINE name #-}-name = remote "system_name"---- | Returns current state of the network.------ Warning: This API isn't stable.-networkState :: JsonRpc m => m Object-{-# INLINE networkState #-}-networkState = remote "system_networkState"---- | Returns the roles the node is running as.-nodeRoles :: JsonRpc m => m [NodeRole]-{-# INLINE nodeRoles #-}-nodeRoles = remote "system_nodeRoles"---- | Returns the currently connected peers.-peers :: JsonRpc m => m [PeerInfo]-{-# INLINE peers #-}-peers = remote "system_peers"---- | Get a custom set of properties as a JSON object, defined in the chain spec.-properties :: JsonRpc m => m Object-{-# INLINE properties #-}-properties = remote "system_properties"---- | Remove a reserved peer.-removeReservedPeer :: JsonRpc m- => Text- -- ^ Peer URI- -> m Text-{-# INLINE removeReservedPeer #-}-removeReservedPeer = remote "system_removeReservedPeer"---- | Retrieves the version of the node.-version :: JsonRpc m => m Text-{-# INLINE version #-}-version = remote "system_version"
@@ -1,270 +0,0 @@-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Network.Polkadot.Api.Types--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Polkadot JSON-RPC types.-----module Network.Polkadot.Api.Types where--import Data.Aeson (FromJSON (..),- Options (fieldLabelModifier),- ToJSON (..), Value (String),- defaultOptions)-import Data.Aeson.TH (deriveJSON)-import Data.Text (Text)-import Data.Word (Word32, Word64, Word8)-import GHC.Generics (Generic)--import Data.ByteArray.HexString (HexString)-import Data.String.Extra (toLowerFirst)---- | The role the node is running as.-data NodeRole = Full- | LightClient- | Authority- | Sentry- deriving (Eq, Generic, Show)--$(deriveJSON defaultOptions ''NodeRole)---- | Type op a chain.-data ChainType = Development- | Local- | Live- | Custom Text- deriving (Eq, Generic, Show)--instance FromJSON ChainType where- parseJSON (String v) = return $ case v of- "Development" -> Development- "Local" -> Local- "Live" -> Live- custom_name -> Custom custom_name- parseJSON _ = fail "ChainType should be a JSON String"--instance ToJSON ChainType where- toJSON (Custom v) = toJSON v- toJSON v = toJSON (show v)---- | System health struct returned by the RPC-data Health = Health- { healthPeers :: Int- -- ^ Number of connected peers.- , healthIsSyncing :: Bool- -- ^ Is the node syncing.- , healthShouldHavePeers :: Bool- -- ^ Should this node have any peers.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 6 }) ''Health)---- | Network Peer information.-data PeerInfo = PeerInfo- { peerInfoPeerId :: Text- -- ^ Peer ID- , peerInfoRoles :: [NodeRole]- -- ^ Roles- , peerInfoProtocolVersion :: Int- -- ^ Protocol version.- , peerInfoBestHash :: Text- -- ^ Peer best block hash- , peerInfoBestNumber :: Int- -- ^ Peer best block number- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 8 }) ''PeerInfo)---- | Executes a call to a contract.-data ContractCall = ContractCall- { callOrigin :: HexString- , callDest :: HexString- , callValue :: Integer- , callGasLimit :: Integer- , callInputData :: HexString- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 4 }) ''ContractCall)---- | A result of execution of a contract.-data ContractExecResult = SuccessExec- { execStatus :: Word8- -- ^ Status code returned by contract.- , execData :: Maybe HexString- -- ^ Output data returned by contract. Can be empty.- }- | ExecResultError- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 4 }) ''ContractExecResult)--type Metadata = Value---- | ReadProof struct returned by RPC.-data ReadProof = ReadProof- { readProofAt :: HexString- -- ^ Block hash used to generate the proof.- , readProofProof :: [HexString]- -- ^ A proof used to prove that storage entries are included in the storage trie.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 9 }) ''ReadProof)---- | Runtime version.--- This should not be thought of as classic Semver (major/minor/tiny).--- This triplet have different semantics and mis-interpretation could cause problems.--- In particular: bug fixes should result in an increment of `spec_version` and possibly `authoring_version`,--- absolutely not `impl_version` since they change the semantics of the runtime.-data RuntimeVersion = RuntimeVersion- { runtimeSpecName :: Text- -- ^ Identifies the different Substrate runtimes.- , runtimeImplName :: Text- -- ^ Name of the implementation of the spec.- , runtimeAuthoringVersion :: Word32- -- ^ `authoring_version` is the version of the authorship interface.- , runtimeSpecVersion :: Word32- -- ^ Version of the runtime specification.- , runtimeImplVersion :: Word32- -- ^ Version of the implementation of the specification.- , runtimeApis :: [(HexString, Word32)]- -- ^ List of supported API "features" along with their versions.- , runtimeTransactionVersion :: Word32- -- ^ All existing dispatches are fully compatible when this number doesn't change.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 7 }) ''RuntimeVersion)---- | Type of supported offchain storages.------ 1: persistent storage is non-revertible and not fork-aware;--- 2: local storage is revertible and fork-aware.-type StorageKind = Word8---- | Storage changes.-data StorageChangeSet = StorageChangeSet- { storageBlock :: HexString- -- ^ Block hash.- , storageChanges :: [(HexString, Maybe HexString)]- -- ^ A list of changes.- }--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 7 }) ''StorageChangeSet)---- | Numeric range of transaction weight.-type Weight = Word64---- | Generalized group of dispatch types.-data DispatchClass = Normal- | Operational- | Mandatory- deriving (Eq, Generic, Show)--$(deriveJSON defaultOptions ''DispatchClass)---- | Some information related to a dispatchable that can be queried from the runtime.-data RuntimeDispatchInfo = RuntimeDispatchInfo- { dispatchWeight :: Weight- -- ^ Weight of this dispatch.- , dispatchClass :: DispatchClass- -- ^ Class of this dispatch.- , dispatchPartialFee :: Integer- -- ^ The partial inclusion fee of this dispatch.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 8 }) ''RuntimeDispatchInfo)---- | Auxiliary data associated with an imported block result.-data ImportedAux = ImportedAux- { auxHeaderOnly :: Bool- -- ^ Only the header has been imported. Block body verification was skipped.- , auxClearJustificationRequests :: Bool- -- ^ Clear all pending justification requests.- , auxNeedsJustification :: Bool- -- ^ Request a justification for the given block.- , auxBadJustification :: Bool- -- ^ Received a bad justification.- , auxNeedsFinalityProof :: Bool- -- ^ Request a finality proof for the given block.- , auxIsNewBest :: Bool- -- ^ Whether the block that was imported is the new best block.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 3 }) ''ImportedAux)--data CreatedBlock = CreatedBlock- { createdBlockHash :: HexString- , createdBlockAux :: ImportedAux- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 12 }) ''CreatedBlock)---- | Abstraction over a block header for a substrate chain.-data Header = Header- { headerParentHash :: HexString- -- ^ The parent hash.- , headerNumber :: Int- -- ^ The block number.- , headerStateRoot :: HexString- -- ^ The state trie merkle root- , headerExtrinsicsRoot :: HexString- -- ^ The merkle root of the extrinsics.- , headerDigest :: HexString- -- ^ A chain-specific digest of data useful for light clients or referencing auxiliary data.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 5 }) ''Header)---- | Abstraction over a substrate block.-data Block = Block- { blockHeader :: Header- -- ^ The block header.- , blockExtrinsics :: [HexString]- -- ^ The accompanying extrinsics.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 5 }) ''Block)---- | Abstraction over a substrate block and justification.-data SignedBlock = SignedBlock- { signedBlock :: Block- -- ^ Full block.- , signedJustification :: Maybe HexString- -- ^ Block justification.- }- deriving (Eq, Generic, Show)--$(deriveJSON (defaultOptions- { fieldLabelModifier = toLowerFirst . drop 6 }) ''SignedBlock)
@@ -1,7 +1,7 @@ -- | -- Module : Network.Web3--- Copyright : Alexander Krupenkin 2016--- License : BSD3+-- Copyright : Aleksandr Krupenkin 2016-2021+-- License : Apache-2.0 -- -- Maintainer : mail@akru.me -- Stability : experimental@@ -15,6 +15,11 @@ -- * Web3 library uses JSON-RPC over WebSocket/HTTP(S) to access node functionality. Web3 , runWeb3+ -- * Re-export popular Web3 platforms.+ , module Network.Ethereum+ , module Network.Polkadot ) where +import Network.Ethereum+import Network.Polkadot import Network.Web3.Provider (Web3, runWeb3)
@@ -1,132 +0,0 @@-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}---- |--- Module : Network.Web3.Provider--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : portable------ Web3 service provider.-----module Network.Web3.Provider where--import Control.Concurrent.Async (Async, async)-import Control.Exception (Exception, try)-import Control.Monad.Catch (MonadThrow)-import Control.Monad.IO.Class (MonadIO (..))-import Control.Monad.State (MonadState (..))-import Control.Monad.Trans.State (StateT, evalStateT, withStateT)-import Data.Default (Default (..))-import Data.Text (Text)-import GHC.Generics (Generic)-import Network.HTTP.Client (Manager)-import qualified Network.Socket as S-import qualified Network.WebSockets as WS (Connection,- defaultConnectionOptions,- newClientConnection,- sendClose)-import qualified Network.WebSockets.Stream as Stream--import Network.JsonRpc.TinyClient (JsonRpc, JsonRpcClient (..),- defaultSettings, jsonRpcManager)---- | Any communication with node wrapped with 'Web3' monad-newtype Web3 a = Web3 { unWeb3 :: StateT JsonRpcClient IO a }- deriving (Functor, Applicative, Monad, MonadIO, MonadThrow, MonadState JsonRpcClient)--instance JsonRpc Web3---- | Some peace of error response-data Web3Error = JsonRpcFail !String- | ParserFail !String- | UserFail !String- deriving (Show, Eq, Generic)--instance Exception Web3Error----TODO: Change to `HttpProvider ServerUri | IpcProvider FilePath` to support IPC--- | Web3 Provider-data Provider = HttpProvider String- | WsProvider String Int- deriving (Show, Eq, Generic)---- | Default Provider URI-instance Default Provider where- def = HttpProvider "http://localhost:8545"---- | 'Web3' monad runner, using the supplied Manager-runWeb3With :: MonadIO m- => Manager- -> Provider- -> Web3 a- -> m (Either Web3Error a)-runWeb3With manager provider f = do- runWeb3' provider Web3 { unWeb3 = withStateT changeManager $ unWeb3 f}- where- changeManager jRpcClient = case jRpcClient of- JsonRpcHttpClient{..} -> jRpcClient { jsonRpcManager = manager }- JsonRpcWsClient{..} -> jRpcClient---- | 'Web3' monad runner-runWeb3' :: MonadIO m- => Provider- -> Web3 a- -> m (Either Web3Error a)-runWeb3' (HttpProvider uri) f = do- cfg <- defaultSettings uri- liftIO . try . flip evalStateT cfg . unWeb3 $ f--runWeb3' (WsProvider host port) f = do- connection <- liftIO $ getConnection host port "/"- let currentClient = JsonRpcWsClient { jsonRpcWsConnection = connection }- response <- liftIO $ try . flip evalStateT currentClient . unWeb3 $ f- liftIO $ WS.sendClose connection ("Bye-" :: Text)- return response---- | 'Web3' runner for default Http provider-runWeb3 :: MonadIO m- => Web3 a- -> m (Either Web3Error a)-{-# INLINE runWeb3 #-}-runWeb3 = runWeb3' def---- | Fork 'Web3' with the same 'Provider' and 'Manager'-forkWeb3 :: Web3 a -> Web3 (Async a)-forkWeb3 f = liftIO . async . evalStateT (unWeb3 f) =<< get---- | Returns a WebSocket Connection Instance-getConnection :: String -- ^ Host- -> Int -- ^ Port- -> String -- ^ Path- -> IO WS.Connection-{-# INLINE getConnection #-}-getConnection host port path = do- -- Create and connect socket- let hints = S.defaultHints- {S.addrSocketType = S.Stream}-- -- Correct host and path.- fullHost = if port == 80 then host else (host ++ ":" ++ show port)- path0 = if null path then "/" else path-- addr:_ <- S.getAddrInfo (Just hints) (Just host) (Just $ show port)- sock <- S.socket (S.addrFamily addr) S.Stream S.defaultProtocol- S.setSocketOption sock S.NoDelay 1-- -- Connect WebSocket and run client-- res <- ( S.connect sock (S.addrAddress addr) >>- Stream.makeSocketStream sock) >>=- (\stream ->- WS.newClientConnection stream fullHost- path0 WS.defaultConnectionOptions [] )- return res
@@ -1,21 +0,0 @@-# Resolver to choose a 'specific' stackage snapshot or a compiler version.-resolver: lts-15.13--# User packages to be built.-packages:-- '.'--# Extra package dependencies-extra-deps:-- relapse-1.0.0.0@sha256:b89ea23189e07f377be4e2a4deccf3d6ba7f547ed8ad77e27b35d78801efd81c-- vinyl-0.12.1@sha256:03f5e246fae2434250987bbfe708015dc6e23f60c20739c34738acde1383b96c--# Dependencies bounds-pvp-bounds: both--# Nix integration-nix:- packages:- - zlib- - haskellPackages.hlint- - haskellPackages.stylish-haskell
@@ -1,151 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NamedFieldPuns #-}-{-# LANGUAGE OverloadedLists #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- Module : Network.Ethereum.Test.ComplexStorageSpec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ ComplexStorage is a Solidity contract which has global variables of--- several different types. The point of this test is to test the encoding--- of a complicated Solidity tuple, consisting of dynamically and statically--- sized components.-----module Network.Ethereum.Test.ComplexStorageSpec where--import Control.Concurrent.Async (async, wait)-import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)-import Control.Monad.IO.Class (liftIO)-import Data.Default (def)--import Network.Ethereum hiding (convert)-import Network.Ethereum.Api.Types (Filter (..))-import Network.Ethereum.Contract (new)-import Network.Ethereum.Contract.TH-import Network.Ethereum.Test.Utils---import Test.Hspec--[abiFrom|test/contracts/ComplexStorage.json|]--deploy :: IO Address-deploy = do- Just address <- web3 $ withAccount () $ withParam id $ new ComplexStorageContract- putStrLn $ "ComplexStorage: " ++ show address- return address--spec :: Spec-spec = deploy `before` complexStorageSpec--complexStorageSpec :: SpecWith Address-complexStorageSpec = do- describe "can interact with a ComplexStorage contract" $ do- -- todo: these should ideally be arbitrary!- let sUint = 1- sInt = -1- sBool = True- sInt224 = 221- sBools = [True, False]- sInts = [1, 1, -3]- sString = "hello"- sBytes16 = "\x12\x34\x56\x78\x12\x34\x56\x78\x12\x34\x56\x78\x12\x34\x56\x78"- sByte2sElem = "\x12\x34"- sByte2sVec = [sByte2sElem, sByte2sElem, sByte2sElem, sByte2sElem]- sByte2s = [sByte2sVec, sByte2sVec]-- it "can set the values of a ComplexStorage and validate them with an event" $ \storage -> do- let fltr = (def :: Filter ValsSet) { filterAddress = Just [storage] }- -- kick off listening for the ValsSet event- vals <- newEmptyMVar- fiber <- async . web3 $- event fltr $ \vs -> do- liftIO $ putMVar vals vs- pure TerminateEvent- -- kick off tx- _ <- contract storage $ setValues- sUint- sInt- sBool- sInt224- sBools- sInts- sString- sBytes16- sByte2s- -- wait for its ValsSet event- wait fiber- (ValsSet vsA vsB vsC vsD vsE vsF vsG vsH vsI) <- takeMVar vals- vsA `shouldBe` sUint- vsB `shouldBe` sInt- vsC `shouldBe` sBool- vsD `shouldBe` sInt224- vsE `shouldBe` sBools- vsF `shouldBe` sInts- vsG `shouldBe` sString- vsH `shouldBe` sBytes16- vsI `shouldBe` sByte2s-- it "can verify that it set the values correctly" $ \storage -> do- -- Write a values- _ <- contract storage $ setValues- sUint- sInt- sBool- sInt224- sBools- sInts- sString- sBytes16- sByte2s- -- Read a couple of values- (uintVal', intVal', boolVal', int224Val', boolsVal, intsVal, stringVal', bytes16Val', bytes2s)- <- contract storage $ (,,,,,,,,)- <$> uintVal- <*> intVal- <*> boolVal- <*> int224Val- <*> boolVectorVal 0- <*> intListVal 0- <*> stringVal- <*> bytes16Val- <*> bytes2VectorListVal 0 0-- uintVal' `shouldBe` sUint- intVal' `shouldBe` sInt- boolVal' `shouldBe` sBool- int224Val' `shouldBe` sInt224- boolsVal `shouldBe` True- intsVal `shouldBe` head sInts- stringVal' `shouldBe` sString- bytes16Val' `shouldBe` sBytes16- bytes2s `shouldBe` sByte2sElem-- it "can decode a complicated value correctly" $ \storage -> do- -- Write a values- _ <- contract storage $ setValues- sUint- sInt- sBool- sInt224- sBools- sInts- sString- sBytes16- sByte2s- -- Read a all values- allVals <- contract storage getVals- allVals `shouldBe` (sUint, sInt, sBool, sInt224, sBools, sInts, sString, sBytes16, sByte2s)
@@ -1,36 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}---- |--- Module : Network.Ethereum.Test.ERC20Spec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable--------module Network.Ethereum.Test.ERC20Spec where--import Test.Hspec--import Network.Ethereum (Account, UIntN)-import Network.Ethereum.Contract.TH (abiFrom)-import Network.JsonRpc.TinyClient (JsonRpc)--[abiFrom|examples/token/ERC20.json|]---- this spec is just to test compilation-spec :: Spec-spec = return ()--getBalance :: (JsonRpc m, Account p t, Functor (t m))- => t m (UIntN 256)-getBalance = balanceOf "0x1234567890123456789011234567890234567890"
@@ -1,193 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE KindSignatures #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NamedFieldPuns #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TypeApplications #-}---- Module : Network.Ethereum.Test.LinearizationSpec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable-----module Network.Ethereum.Test.LinearizationSpec where--import Control.Concurrent (forkIO)-import Control.Concurrent.Async (forConcurrently_)-import Control.Concurrent.MVar-import Control.Concurrent.STM (atomically)-import Control.Concurrent.STM.TQueue (TQueue, flushTQueue,- newTQueueIO, writeTQueue)-import Control.Monad (void)-import Control.Monad.IO.Class (MonadIO (..))-import Control.Monad.Trans.Reader (ReaderT, ask)-import Data.Default-import Data.Either-import Data.List (sort)-import Data.Maybe (fromJust)-import System.Random (randomRIO)-import Test.Hspec--import Network.Ethereum-import qualified Network.Ethereum.Api.Eth as Eth-import Network.Ethereum.Api.Types (Change (..), Filter (..),- TxReceipt, unQuantity)-import Network.Ethereum.Contract (new)-import Network.Ethereum.Contract.Event-import Network.Ethereum.Contract.TH (abiFrom)-import Network.Ethereum.Test.Utils-import Network.Web3--[abiFrom|test/contracts/Linearization.json|]--deploy :: IO Address-deploy = do- Just address <- web3 $ withAccount () $ withParam id $ new LinearizationContract- putStrLn $ "Linearization: " ++ show address- return address--spec :: Spec-spec = do- deploy `before` linearizationSpec- deploy `before` floodSpec--floodCount :: Int-floodCount = 200--linearizationSpec :: SpecWith Address-linearizationSpec =- describe "can bundle and linearize events" $ do- it "can call e12" $ \linearization -> do- var <- monitorE1OrE2 linearization- _ <- contract linearization e12- res <- takeMVar var- res `shouldSatisfy` isLeft-- it "can call e21" $ \linearization -> do- -- wait on the next block- web3 Eth.blockNumber >>= \bn -> awaitBlock (bn + 1)- var <- monitorE1OrE2 linearization- _ <- contract linearization e21- res <- takeMVar var- res `shouldSatisfy` isRight--singleFlood :: forall m. (MonadIO m) => Address -> m TxReceipt-singleFlood linearization = liftIO $ do- rando :: Int <- randomRIO (1, 4)- contract linearization $- case rando of- 1 -> e1- 2 -> e2- 3 -> e3- 4 -> e4- _ -> error "got a number outside of (1,4) after randomR (1,4)"--floodSpec :: SpecWith Address-floodSpec = describe "can correctly demonstrate the difference between `multiEvent` and multiple `event`s" $ do- it "properly linearizes with `multiEvent` when flooded and doesn't with multiple `event`s" $ \linearization -> do- multiQ <- monitorAllFourMulti linearization- parQ <- monitorAllFourPar linearization- -- to let the filter settle so we dont block indefinitely on missing events?- sleepBlocks 10-- -- flood em and wait for all to finish- liftIO . forConcurrently_ [1..floodCount] . const $ singleFlood linearization-- -- to let the event listeners catch up- sleepBlocks 10-- -- wait for all multiEvents to be received and flush em out- multiReceivedEvents <- liftIO . atomically $ flushTQueue multiQ- parReceivedEvents <- liftIO . atomically $ flushTQueue parQ-- -- did we get at least 1/4 of the events? (this is a gotcha when flooding, sometimes nonces get repeated)- length multiReceivedEvents `shouldSatisfy` (>= (floodCount `div` 4))- length parReceivedEvents `shouldSatisfy` (>= (floodCount `div` 4))-- -- did both listeners see the same amount of events?- length multiReceivedEvents `shouldBe` length parReceivedEvents-- -- the events pushed into the multi TQueue should already be sorted if they happened in the right order- sort multiReceivedEvents `shouldBe` multiReceivedEvents- -- the events pushed into the TQueue should not be sorted if they didnt come in in the right order- sort parReceivedEvents `shouldNotBe` parReceivedEvents--monitorE1OrE2 :: Address -> IO (MVar (Either E1 E2))-monitorE1OrE2 addr = do- var <- newEmptyMVar- let fltr1 = (def :: Filter E1) { filterAddress = Just [addr] }- fltr2 = (def :: Filter E2) { filterAddress = Just [addr] }- filters = fltr1 :? fltr2 :? NilFilters- handler1 ev1 = do- liftIO $ putMVar var (Left ev1)- return TerminateEvent- handler2 ev2 = do- liftIO $ putMVar var (Right ev2)- return TerminateEvent- handlers = H handler1 :& H handler2 :& RNil- _ <- web3 $ multiEvent filters handlers- return var--data EventTag = ETE1- | ETE2- | ETE3- | ETE4- deriving (Eq, Read, Show)--instance {-# OVERLAPPING #-} Ord (EventTag, Integer, Integer) where- (_, b1, t1) `compare` (_, b2, t2) =- let bCmp = b1 `compare` b2- in if bCmp == EQ then t1 `compare` t2- else bCmp--monitorAllFourMulti :: Address- -> IO (TQueue (EventTag, Integer, Integer))-monitorAllFourMulti addr = do- q <- newTQueueIO- let f :: forall a. Default (Filter a) => Filter a- f = defFilter addr- h = enqueueingHandler q- filters = f @E1 :? f @E2 :? f @E3 :? f @E4 :? NilFilters- handlers = h ETE1 :& h ETE2 :& h ETE3 :& h ETE4 :& RNil- void . web3 $ multiEvent filters handlers- return q--monitorAllFourPar :: Address- -> IO (TQueue (EventTag, Integer, Integer))-monitorAllFourPar addr = do- q <- newTQueueIO- let f :: forall a. Default (Filter a) => Filter a- f = defFilter addr- h = enqueueingHandler q- unH (H h) = h-- void . forkIO . web3 $ event (f @E1) (unH $ h ETE1)- void . forkIO . web3 $ event (f @E2) (unH $ h ETE2)- void . forkIO . web3 $ event (f @E3) (unH $ h ETE3)- void . forkIO . web3 $ event (f @E4) (unH $ h ETE4)- return q--defFilter :: forall a. Default (Filter a) => Address -> Filter a-defFilter addr = (def :: Filter a) { filterAddress = Just [addr] }--enqueueingHandler :: forall a. TQueue (EventTag, Integer, Integer)- -> EventTag- -> Handler (ReaderT Change Web3 EventAction) a-enqueueingHandler q tag = H . const $ do- Change{..} <- ask- let bn = unQuantity $ fromJust changeBlockNumber- li = unQuantity $ fromJust changeLogIndex- liftIO . atomically $ writeTQueue q (tag, bn, li)- return ContinueEvent
@@ -1,51 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- Module : Network.Ethereum.Test.LocalAccountSpec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Simple local account transaction test.-----module Network.Ethereum.Test.LocalAccountSpec where--import Lens.Micro ((.~))-import Lens.Micro.Mtl ((.=))-import Test.Hspec--import Crypto.Ecdsa.Utils (derivePubKey, importKey)-import Data.ByteArray.HexString (HexString)-import Data.Solidity.Prim.Address (fromPubKey)-import Network.Ethereum.Account (LocalKey (..), send, to, value,- withAccount, withParam)-import Network.Ethereum.Api.Eth (getBalance)-import Network.Ethereum.Api.Types (DefaultBlock (Pending))-import Network.Ethereum.Test.Utils (web3)-import Network.Ethereum.Unit (Ether, toWei)--spec :: Spec-spec = describe "Local account transactions" $ do- it "should send value" $ do- let key = "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20" :: HexString- local = LocalKey (importKey key) 420123- localAddress = fromPubKey (derivePubKey $ importKey key)- dest = "0x0000000000000000000000000000000000000042"-- -- Prepare- web3 $ withAccount () $- withParam (to .~ localAddress) $ do- value .= (1 :: Ether)- send ()-- balance <- web3 $ do- withAccount local $- withParam (to .~ dest) $ do- value .= (0.5 :: Ether)- send ()- getBalance dest Pending-- fromIntegral balance `shouldBe` toWei (0.5 :: Ether)
@@ -1,33 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedLists #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE TemplateHaskell #-}--module Network.Ethereum.Test.RegistrySpec where--import Data.Default (def)-import Test.Hspec (Spec)--import Network.Ethereum (EventAction (TerminateEvent),- event)-import Network.Ethereum.Api.Types (Filter)-import Network.Ethereum.Contract.TH (abiFrom)-import Network.Web3 (Web3)--[abiFrom|test/contracts/Registry.json|]---- this spec is just to test compilation-spec :: Spec-spec = return ()--monitor :: Web3 ()-monitor = do- let fltr1 = def :: Filter A- fltr2 = def :: Filter B- event fltr1 $ \_ -> pure TerminateEvent- event fltr2 $ \_ -> pure TerminateEvent- pure ()
@@ -1,202 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE KindSignatures #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NamedFieldPuns #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-}---- Module : Network.Ethereum.Test.SimpleStorageSpec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ SimpleStorage is a Solidity contract which stores a uint256.--- The point of this test is to test function calls to update and--- read the value, as well as an event monitor.-----module Network.Ethereum.Test.SimpleStorageSpec where--import Control.Concurrent.Async (wait)-import Control.Concurrent.MVar-import Control.Monad.IO.Class (liftIO)-import Control.Monad.Trans.Class (lift)-import Control.Monad.Trans.Reader (ask)-import Data.Default (def)-import Data.List (sort)-import Data.Monoid ((<>))-import Lens.Micro ((.~))-import Test.Hspec--import Network.Ethereum-import qualified Network.Ethereum.Api.Eth as Eth-import Network.Ethereum.Api.Types-import Network.Ethereum.Contract (new)-import Network.Ethereum.Contract.TH-import Network.Web3-import Network.Web3.Provider (forkWeb3)--import Network.Ethereum.Test.Utils--[abiFrom|test/contracts/SimpleStorage.json|]--unEvT_CountSet :: EvT_CountSet -> UIntN 256-unEvT_CountSet (EvT_CountSet n) = n--deploy :: IO Address-deploy = do- Just address <- web3 $ withAccount () $ withParam id $ new SimpleStorageContract- putStrLn $ "SimpleStorage: " ++ show address- return address--spec :: Spec-spec = deploy `before` do- interactions- events--interactions :: SpecWith Address-interactions = describe "can interact with a SimpleStorage contract" $ do- -- todo: this should ideally be arbitrary!- let theValue = 12345-- it "can set the value of a SimpleStorage contract and read the value back" $ \storage -> do- _ <- contract storage $ setCount theValue-- now <- web3 Eth.blockNumber- let later = now + 3- awaitBlock later-- v <- contract storage count- v `shouldBe` theValue-- it "can set transaction gas limit" $ \storage -> do- TxReceipt{..} <- contract storage $ withParam (gasLimit .~ 500000) $ setCount theValue- Just Transaction{..} <- web3 $ Eth.getTransactionByHash receiptTransactionHash- txGas `shouldBe` 500000-- it "can estimate transaction gas limit" $ \storage -> do- TxReceipt{..} <- contract storage $ setCount theValue- Just Transaction{..} <- web3 $ Eth.getTransactionByHash receiptTransactionHash- txGas `shouldBe` 42822--events :: SpecWith Address-events = do- describe "can interact with a SimpleStorage contract across block intervals" $ do- it "can stream events starting and ending in the future, unbounded" $ \storage -> do- var <- newMVar []- let theSets = [1, 2, 3]- putStrLn "Setting up the filter..."- fiber <- web3 $ do- let fltr = (def :: Filter EvT_CountSet) { filterAddress = Just [storage] }- forkWeb3 $ processUntil' var fltr ((3 ==) . length)- putStrLn "Setting the values..."- setValues storage theSets- wait fiber- putStrLn "Filter caught 3 values..."- vals <- takeMVar var- sort (unEvT_CountSet <$> vals) `shouldBe` sort theSets-- it "can stream events starting and ending in the future, bounded" $ \storage -> do- var <- newMVar []- let theSets = [13, 14, 15]- start <- web3 Eth.blockNumber- let later = BlockWithNumber (start + 3)- latest = BlockWithNumber (start + 8)- fltr = (def :: Filter EvT_CountSet) { filterAddress = Just [storage]- , filterFromBlock = later- , filterToBlock = latest- }- putStrLn "Setting up the filter..."- fiber <- web3 $- forkWeb3 $ processUntil' var fltr ((3 ==) . length)- awaitBlock (start + 3)- putStrLn "Setting the values..."- setValues storage theSets- wait fiber- putStrLn "Filter caught 3 values..."- vals <- takeMVar var- sort (unEvT_CountSet <$> vals) `shouldBe` init (sort theSets)-- it "can stream events starting in the past and ending in the future" $ \storage -> do- var <- newMVar []- blockNumberVar <- newEmptyMVar- let theSets1 = [7, 8, 9]- theSets2 = [10, 11, 12]- start <- web3 Eth.blockNumber- let fltr = (def :: Filter EvT_CountSet) { filterAddress = Just [storage] }- fiber <- web3 $ do- forkWeb3 $ processUntil var fltr ((3 ==) . length) (liftIO . putMVar blockNumberVar . changeBlockNumber)- putStrLn "Running first transactions as past transactions..."- setValues storage theSets1- wait fiber- putStrLn "All past transactions succeeded... "- Just end <- takeMVar blockNumberVar- awaitBlock $ end + 1 -- make past transactions definitively in past- var' <- newMVar []- fiber' <- web3 $ do- let fltr' = (def :: Filter EvT_CountSet) { filterAddress = Just [storage]- , filterFromBlock = BlockWithNumber start}- forkWeb3 $ processUntil' var' fltr' ((6 ==) . length)- putStrLn "Setting more values"- setValues storage theSets2- wait fiber'- putStrLn "All new values have ben set"- vals <- takeMVar var'- sort (unEvT_CountSet <$> vals) `shouldBe` sort (theSets1 <> theSets2)-- it "can stream events starting and ending in the past, bounded" $ \storage -> do- var <- newMVar []- let theSets = [4, 5, 6]- start <- web3 Eth.blockNumber- blockNumberVar <- newEmptyMVar- let fltr = (def :: Filter EvT_CountSet) { filterAddress = Just [storage] }- putStrLn "Setting up filter for past transactions..."- fiber <- web3 $ do- forkWeb3 $ processUntil var fltr ((3 ==) . length) (liftIO . putMVar blockNumberVar . changeBlockNumber)- putStrLn "Setting values"- setValues storage theSets- wait fiber- putStrLn "All values have been set"- Just end <- takeMVar blockNumberVar- var' <- newMVar []- let fltr' = fltr { filterFromBlock = BlockWithNumber start- , filterToBlock = BlockWithNumber end- }- awaitBlock $ end + 1 -- make it definitively in the past- web3 $ processUntil' var' fltr' ((3 ==) . length)- vals <- takeMVar var'- sort (unEvT_CountSet <$> vals) `shouldBe` sort theSets--processUntil :: MVar [EvT_CountSet]- -> Filter EvT_CountSet- -> ([EvT_CountSet] -> Bool) -- TODO: make it work for any event- -> (Change -> Web3 ())- -> Web3 ()-processUntil var fltr predicate action = do- event fltr $ \(ev :: EvT_CountSet) -> do- newV <- liftIO $ modifyMVar var $ \v -> return (ev:v, ev:v)- if predicate newV- then do- change <- ask- lift $ action change- return TerminateEvent- else return ContinueEvent--processUntil' :: MVar [EvT_CountSet]- -> Filter EvT_CountSet- -> ([EvT_CountSet] -> Bool)- -> Web3 ()-processUntil' var fltr predicate = processUntil var fltr predicate (const $ return ())--setValues :: Address -> [UIntN 256] -> IO ()-setValues storage = mapM_ (contract storage . setCount)
@@ -1,80 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}--module Network.Ethereum.Test.Utils where--import Control.Concurrent (threadDelay)-import Control.Exception (SomeException, catch)-import Control.Monad.IO.Class (liftIO)-import Data.Maybe (fromMaybe)-import Data.Ratio (numerator)-import Data.Time.Clock.POSIX (getPOSIXTime)-import Lens.Micro ((.~))-import Network.HTTP.Client (Manager, defaultManagerSettings,- managerConnCount,- managerRawConnection,- managerRetryableException,- newManager)-import System.Environment (lookupEnv)-import System.IO.Unsafe (unsafePerformIO)--import Data.Solidity.Prim.Address (Address)-import Network.Ethereum.Account (DefaultAccount, to, withAccount,- withParam)-import Network.Ethereum.Api.Eth (accounts, blockNumber)-import Network.Ethereum.Api.Types (Quantity)-import Network.Web3.Provider (Provider (..), Web3, runWeb3With)---- shared manager used throughout the helpers here to prevent hammering geth from ruining everything--- this also retrys on ALL exceptions, including ConnectionResetByPeer and stuff like that-sharedManager :: Manager-sharedManager = unsafePerformIO $ newManager defaultManagerSettings- { managerConnCount = 5- , managerRetryableException = const False- , managerRawConnection = fixRawConnection retryOpenConnection- }-- where retryOpenConnection = threadDelay 500000 >> managerRawConnection defaultManagerSettings- fixRawConnection f = f `catch` (\(_ :: SomeException) -> fixRawConnection f)-{-# NOINLINE sharedManager #-}--rpcUri :: IO String-rpcUri = liftIO (fromMaybe "http://localhost:8545" <$> lookupEnv "WEB3_PROVIDER")--contract :: Address- -> DefaultAccount Web3 a- -> IO a-contract a = web3 . withAccount () . withParam (to .~ a)--web3 :: Web3 a -> IO a-web3 ma = do- provider <- HttpProvider <$> rpcUri- v <- runWeb3With sharedManager provider ma- case v of- Left e -> print e >> threadDelay 1000000 >> web3 ma- Right v' -> return v'--withAccounts :: ([Address] -> IO a) -> IO a-withAccounts f = web3 accounts >>= f--withPrimaryEthereumAccount :: IO Address-withPrimaryEthereumAccount = withAccounts (pure . head)--sleepSeconds :: Int -> IO ()-sleepSeconds = threadDelay . (* 1000000)--microtime :: IO Integer-microtime = numerator . toRational . (* 1000000) <$> getPOSIXTime--awaitBlock :: Quantity -> IO ()-awaitBlock bn = do- bn' <- web3 blockNumber- -- putStrLn $ "awaiting block " ++ show bn ++ ", currently " ++ show bn'- if bn' >= bn- then return ()- else threadDelay 1000000 >> awaitBlock bn--sleepBlocks :: Int -> IO ()-sleepBlocks n = do- now <- web3 blockNumber- awaitBlock $ now + fromIntegral n
@@ -1,47 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Network.Ipfs.Api.Test.Key--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unknown------ Key IPFS API testing module.-----module Network.Ipfs.Api.Test.Key where--import Control.Exception ()-import Control.Monad.Trans-import Test.Hspec--import qualified Network.Ipfs.Api.Key as Key-import Network.Ipfs.Api.Types (KeyDetailsObj (..), KeyObj (..))-import Network.Ipfs.Client (runIpfs)--main :: IO ()-main = hspec $ do- describe "keyGen" $ do- it "should return the given key name in its response" $ runIpfs $ do- res <- Key.gen "TestA" "rsa"- liftIO $ keyName res `shouldBe` "TestA"-- it "KeyDetailsObj returned by KeyGen should be present in the KeyObj's list returned returned by KeyList" $- runIpfs $ do- resGen <- Key.gen "TestB" "rsa"- resList <- Key.list- liftIO $ keys resList `shouldContain` [resGen]-- describe "keyRm" $ do- it "should return the given key name in its response" $ runIpfs $ do- res <- Key.rm "TestA"- liftIO $ (keyName $ Prelude.head $ keys res) `shouldBe` "TestA"-- it "KeyDetailsObj returned by KeyRm should not be present in the KeyObj's list returned returned by KeyList" $- runIpfs $ do- resRm <- Key.rm "TestB"- resList <- Key.list- liftIO $ keys resList `shouldNotContain` keys resRm
@@ -1,1 +0,0 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
@@ -1,4533 +0,0 @@-{- "contractName": "ComplexStorage",- "abi": [- {- "constant": true,- "inputs": [],- "name": "boolVal",- "outputs": [- {- "name": "",- "type": "bool"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [],- "name": "stringVal",- "outputs": [- {- "name": "",- "type": "string"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [],- "name": "intVal",- "outputs": [- {- "name": "",- "type": "int256"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [- {- "name": "",- "type": "uint256"- }- ],- "name": "intListVal",- "outputs": [- {- "name": "",- "type": "int256"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [],- "name": "uintVal",- "outputs": [- {- "name": "",- "type": "uint256"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [],- "name": "int224Val",- "outputs": [- {- "name": "",- "type": "int224"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [],- "name": "bytes16Val",- "outputs": [- {- "name": "",- "type": "bytes16"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [- {- "name": "",- "type": "uint256"- }- ],- "name": "boolVectorVal",- "outputs": [- {- "name": "",- "type": "bool"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "constant": true,- "inputs": [- {- "name": "",- "type": "uint256"- },- {- "name": "",- "type": "uint256"- }- ],- "name": "bytes2VectorListVal",- "outputs": [- {- "name": "",- "type": "bytes2"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "anonymous": false,- "inputs": [- {- "indexed": false,- "name": "a",- "type": "uint256"- },- {- "indexed": false,- "name": "b",- "type": "int256"- },- {- "indexed": false,- "name": "c",- "type": "bool"- },- {- "indexed": false,- "name": "d",- "type": "int224"- },- {- "indexed": false,- "name": "e",- "type": "bool[2]"- },- {- "indexed": false,- "name": "f",- "type": "int256[]"- },- {- "indexed": false,- "name": "g",- "type": "string"- },- {- "indexed": false,- "name": "h",- "type": "bytes16"- },- {- "indexed": false,- "name": "i",- "type": "bytes2[4][]"- }- ],- "name": "ValsSet",- "type": "event"- },- {- "constant": false,- "inputs": [- {- "name": "_uintVal",- "type": "uint256"- },- {- "name": "_intVal",- "type": "int256"- },- {- "name": "_boolVal",- "type": "bool"- },- {- "name": "_int224Val",- "type": "int224"- },- {- "name": "_boolVectorVal",- "type": "bool[2]"- },- {- "name": "_intListVal",- "type": "int256[]"- },- {- "name": "_stringVal",- "type": "string"- },- {- "name": "_bytes16Val",- "type": "bytes16"- },- {- "name": "_bytes2VectorListVal",- "type": "bytes2[4][]"- }- ],- "name": "setValues",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- },- {- "constant": true,- "inputs": [],- "name": "getVals",- "outputs": [- {- "name": "",- "type": "uint256"- },- {- "name": "",- "type": "int256"- },- {- "name": "",- "type": "bool"- },- {- "name": "",- "type": "int224"- },- {- "name": "",- "type": "bool[2]"- },- {- "name": "",- "type": "int256[]"- },- {- "name": "",- "type": "string"- },- {- "name": "",- "type": "bytes16"- },- {- "name": "",- "type": "bytes2[4][]"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- }- ],- "bytecode": "0x608060405234801561001057600080fd5b506111be806100206000396000f3006080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631aadfbdb146100b45780632316afea14610258578063579c738a14610287578063614ac7911461031757806382a35c77146104dc5780638ba27dca146105075780639a0283ed146105485780639d49a304146105735780639eb7a6b2146105a4578063c84a4100146105f5578063f4f67ad71461063a575b600080fd5b3480156100c057600080fd5b5061025660048036038101908080359060200190929190803590602001909291908035151590602001909291908035601b0b9060200190929190806040019060028060200260405190810160405280929190826002602002808284378201915050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929080356fffffffffffffffffffffffffffffffff1916906020019092919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156102445784848390506080020160048060200260405190810160405280929190826004602002808284378201915050505050815260200190600101906101ff565b505050505091929192905050506106c7565b005b34801561026457600080fd5b5061026d6109b9565b604051808215151515815260200191505060405180910390f35b34801561029357600080fd5b5061029c6109cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102dc5780820151818401526020810190506102c1565b50505050905090810190601f1680156103095780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032357600080fd5b5061032c610a6a565b604051808a81526020018981526020018815151515815260200187601b0b601b0b815260200186600260200280838360005b8381101561037957808201518184015260208101905061035e565b505050509050018060200180602001856fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff1916815260200180602001848103845288818151815260200191508051906020019060200280838360005b838110156103f35780820151818401526020810190506103d8565b50505050905001848103835287818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b508481038252858181518152602001915080516000925b818410156104c157828490602001906020020151600460200280838360005b838110156104b0578082015181840152602081019050610495565b505050509050019260010192610476565b925050509c5050505050505050505050505060405180910390f35b3480156104e857600080fd5b506104f1610d24565b6040518082815260200191505060405180910390f35b34801561051357600080fd5b5061053260048036038101908080359060200190929190505050610d2a565b6040518082815260200191505060405180910390f35b34801561055457600080fd5b5061055d610d4d565b6040518082815260200191505060405180910390f35b34801561057f57600080fd5b50610588610d53565b6040518082601b0b601b0b815260200191505060405180910390f35b3480156105b057600080fd5b506105b9610d66565b60405180826fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b34801561060157600080fd5b5061062060048036038101908080359060200190929190505050610d89565b604051808215151515815260200191505060405180910390f35b34801561064657600080fd5b5061066f6004803603810190808035906020019092919080359060200190929190505050610db2565b60405180827dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b886000819055508760018190555086600260006101000a81548160ff02191690831515021790555085600260016101000a8154817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff0219169083601b0b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff160217905550846003906002610754929190610e16565b50836004908051906020019061076b929190610eaf565b508260059080519060200190610782929190610efc565b5081600660006101000a8154816fffffffffffffffffffffffffffffffff02191690837001000000000000000000000000000000009004021790555080600790805190602001906107d4929190610f7c565b507f88d23351ad32a937b11ca10530404f8297d29803e94709336b48c1f82c15b3cc898989898989898989604051808a81526020018981526020018815151515815260200187601b0b601b0b815260200186600260200280838360005b8381101561084c578082015181840152602081019050610831565b505050509050018060200180602001856fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff1916815260200180602001848103845288818151815260200191508051906020019060200280838360005b838110156108c65780820151818401526020810190506108ab565b50505050905001848103835287818151815260200191508051906020019080838360005b838110156109055780820151818401526020810190506108ea565b50505050905090810190601f1680156109325780820380516001836020036101000a031916815260200191505b508481038252858181518152602001915080516000925b8184101561099457828490602001906020020151600460200280838360005b83811015610983578082015181840152602081019050610968565b505050509050019260010192610949565b925050509c5050505050505050505050505060405180910390a1505050505050505050565b600260009054906101000a900460ff1681565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a625780601f10610a3757610100808354040283529160200191610a62565b820191906000526020600020905b815481529060010190602001808311610a4557829003601f168201915b505050505081565b600080600080610a78610fd7565b60608060006060600054600154600260009054906101000a900460ff16600260019054906101000a9004601b0b600360046005600660009054906101000a900470010000000000000000000000000000000002600784600280602002604051908101604052809291908260028015610b2a576020028201916000905b82829054906101000a900460ff16151581526020019060010190602082600001049283019260010382029150808411610af45790505b5050505050945083805480602002602001604051908101604052809291908181526020018280548015610b7c57602002820191906000526020600020905b815481526020019060010190808311610b68575b50505050509350828054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c185780601f10610bed57610100808354040283529160200191610c18565b820191906000526020600020905b815481529060010190602001808311610bfb57829003601f168201915b5050505050925080805480602002602001604051908101604052809291908181526020016000905b82821015610d0157838290600052602060002001600480602002604051908101604052809291908260048015610ced576020028201916000905b82829054906101000a90047e01000000000000000000000000000000000000000000000000000000000000027dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681526020019060020190602082600101049283019260010382029150808411610c7a5790505b505050505081526020019060010190610c40565b505050509050985098509850985098509850985098509850909192939495969798565b60015481565b600481815481101515610d3957fe5b906000526020600020016000915090505481565b60005481565b600260019054906101000a9004601b0b81565b600660009054906101000a90047001000000000000000000000000000000000281565b600381600281101515610d9857fe5b60209182820401919006915054906101000a900460ff1681565b600782815481101515610dc157fe5b9060005260206000200181600481101515610dd857fe5b60109182820401919006600202915091509054906101000a90047e010000000000000000000000000000000000000000000000000000000000000281565b826002601f01602090048101928215610e9e5791602002820160005b83821115610e6f57835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302610e32565b8015610e9c5782816101000a81549060ff0219169055600101602081600001049283019260010302610e6f565b505b509050610eab9190610ff9565b5090565b828054828255906000526020600020908101928215610eeb579160200282015b82811115610eea578251825591602001919060010190610ecf565b5b509050610ef89190611029565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610f3d57805160ff1916838001178555610f6b565b82800160010185558215610f6b579182015b82811115610f6a578251825591602001919060010190610f4f565b5b509050610f78919061104e565b5090565b828054828255906000526020600020908101928215610fc6579160200282015b82811115610fc557825182906004610fb5929190611073565b5091602001919060010190610f9c565b5b509050610fd3919061112e565b5090565b6040805190810160405280600290602082028038833980820191505090505090565b61102691905b8082111561102257600081816101000a81549060ff021916905550600101610fff565b5090565b90565b61104b91905b8082111561104757600081600090555060010161102f565b5090565b90565b61107091905b8082111561106c576000816000905550600101611054565b5090565b90565b826004600f0160109004810192821561111d5791602002820160005b838211156110ed57835183826101000a81548161ffff02191690837e0100000000000000000000000000000000000000000000000000000000000090040217905550926020019260020160208160010104928301926001030261108f565b801561111b5782816101000a81549061ffff02191690556002016020816001010492830192600103026110ed565b505b50905061112a919061115a565b5090565b61115791905b80821115611153576000818161114a919061118b565b50600101611134565b5090565b90565b61118891905b8082111561118457600081816101000a81549061ffff021916905550600101611160565b5090565b90565b50600090555600a165627a7a7230582011b9a8b2fe6341272836fb36535a5f03b46544a58a14b17b7d49405a8247b7d10029",- "deployedBytecode": "0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631aadfbdb146100b45780632316afea14610258578063579c738a14610287578063614ac7911461031757806382a35c77146104dc5780638ba27dca146105075780639a0283ed146105485780639d49a304146105735780639eb7a6b2146105a4578063c84a4100146105f5578063f4f67ad71461063a575b600080fd5b3480156100c057600080fd5b5061025660048036038101908080359060200190929190803590602001909291908035151590602001909291908035601b0b9060200190929190806040019060028060200260405190810160405280929190826002602002808284378201915050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929080356fffffffffffffffffffffffffffffffff1916906020019092919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156102445784848390506080020160048060200260405190810160405280929190826004602002808284378201915050505050815260200190600101906101ff565b505050505091929192905050506106c7565b005b34801561026457600080fd5b5061026d6109b9565b604051808215151515815260200191505060405180910390f35b34801561029357600080fd5b5061029c6109cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102dc5780820151818401526020810190506102c1565b50505050905090810190601f1680156103095780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032357600080fd5b5061032c610a6a565b604051808a81526020018981526020018815151515815260200187601b0b601b0b815260200186600260200280838360005b8381101561037957808201518184015260208101905061035e565b505050509050018060200180602001856fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff1916815260200180602001848103845288818151815260200191508051906020019060200280838360005b838110156103f35780820151818401526020810190506103d8565b50505050905001848103835287818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b508481038252858181518152602001915080516000925b818410156104c157828490602001906020020151600460200280838360005b838110156104b0578082015181840152602081019050610495565b505050509050019260010192610476565b925050509c5050505050505050505050505060405180910390f35b3480156104e857600080fd5b506104f1610d24565b6040518082815260200191505060405180910390f35b34801561051357600080fd5b5061053260048036038101908080359060200190929190505050610d2a565b6040518082815260200191505060405180910390f35b34801561055457600080fd5b5061055d610d4d565b6040518082815260200191505060405180910390f35b34801561057f57600080fd5b50610588610d53565b6040518082601b0b601b0b815260200191505060405180910390f35b3480156105b057600080fd5b506105b9610d66565b60405180826fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b34801561060157600080fd5b5061062060048036038101908080359060200190929190505050610d89565b604051808215151515815260200191505060405180910390f35b34801561064657600080fd5b5061066f6004803603810190808035906020019092919080359060200190929190505050610db2565b60405180827dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b886000819055508760018190555086600260006101000a81548160ff02191690831515021790555085600260016101000a8154817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff0219169083601b0b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff160217905550846003906002610754929190610e16565b50836004908051906020019061076b929190610eaf565b508260059080519060200190610782929190610efc565b5081600660006101000a8154816fffffffffffffffffffffffffffffffff02191690837001000000000000000000000000000000009004021790555080600790805190602001906107d4929190610f7c565b507f88d23351ad32a937b11ca10530404f8297d29803e94709336b48c1f82c15b3cc898989898989898989604051808a81526020018981526020018815151515815260200187601b0b601b0b815260200186600260200280838360005b8381101561084c578082015181840152602081019050610831565b505050509050018060200180602001856fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff1916815260200180602001848103845288818151815260200191508051906020019060200280838360005b838110156108c65780820151818401526020810190506108ab565b50505050905001848103835287818151815260200191508051906020019080838360005b838110156109055780820151818401526020810190506108ea565b50505050905090810190601f1680156109325780820380516001836020036101000a031916815260200191505b508481038252858181518152602001915080516000925b8184101561099457828490602001906020020151600460200280838360005b83811015610983578082015181840152602081019050610968565b505050509050019260010192610949565b925050509c5050505050505050505050505060405180910390a1505050505050505050565b600260009054906101000a900460ff1681565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a625780601f10610a3757610100808354040283529160200191610a62565b820191906000526020600020905b815481529060010190602001808311610a4557829003601f168201915b505050505081565b600080600080610a78610fd7565b60608060006060600054600154600260009054906101000a900460ff16600260019054906101000a9004601b0b600360046005600660009054906101000a900470010000000000000000000000000000000002600784600280602002604051908101604052809291908260028015610b2a576020028201916000905b82829054906101000a900460ff16151581526020019060010190602082600001049283019260010382029150808411610af45790505b5050505050945083805480602002602001604051908101604052809291908181526020018280548015610b7c57602002820191906000526020600020905b815481526020019060010190808311610b68575b50505050509350828054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c185780601f10610bed57610100808354040283529160200191610c18565b820191906000526020600020905b815481529060010190602001808311610bfb57829003601f168201915b5050505050925080805480602002602001604051908101604052809291908181526020016000905b82821015610d0157838290600052602060002001600480602002604051908101604052809291908260048015610ced576020028201916000905b82829054906101000a90047e01000000000000000000000000000000000000000000000000000000000000027dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681526020019060020190602082600101049283019260010382029150808411610c7a5790505b505050505081526020019060010190610c40565b505050509050985098509850985098509850985098509850909192939495969798565b60015481565b600481815481101515610d3957fe5b906000526020600020016000915090505481565b60005481565b600260019054906101000a9004601b0b81565b600660009054906101000a90047001000000000000000000000000000000000281565b600381600281101515610d9857fe5b60209182820401919006915054906101000a900460ff1681565b600782815481101515610dc157fe5b9060005260206000200181600481101515610dd857fe5b60109182820401919006600202915091509054906101000a90047e010000000000000000000000000000000000000000000000000000000000000281565b826002601f01602090048101928215610e9e5791602002820160005b83821115610e6f57835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302610e32565b8015610e9c5782816101000a81549060ff0219169055600101602081600001049283019260010302610e6f565b505b509050610eab9190610ff9565b5090565b828054828255906000526020600020908101928215610eeb579160200282015b82811115610eea578251825591602001919060010190610ecf565b5b509050610ef89190611029565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610f3d57805160ff1916838001178555610f6b565b82800160010185558215610f6b579182015b82811115610f6a578251825591602001919060010190610f4f565b5b509050610f78919061104e565b5090565b828054828255906000526020600020908101928215610fc6579160200282015b82811115610fc557825182906004610fb5929190611073565b5091602001919060010190610f9c565b5b509050610fd3919061112e565b5090565b6040805190810160405280600290602082028038833980820191505090505090565b61102691905b8082111561102257600081816101000a81549060ff021916905550600101610fff565b5090565b90565b61104b91905b8082111561104757600081600090555060010161102f565b5090565b90565b61107091905b8082111561106c576000816000905550600101611054565b5090565b90565b826004600f0160109004810192821561111d5791602002820160005b838211156110ed57835183826101000a81548161ffff02191690837e0100000000000000000000000000000000000000000000000000000000000090040217905550926020019260020160208160010104928301926001030261108f565b801561111b5782816101000a81549061ffff02191690556002016020816001010492830192600103026110ed565b505b50905061112a919061115a565b5090565b61115791905b80821115611153576000818161114a919061118b565b50600101611134565b5090565b90565b61118891905b8082111561118457600081816101000a81549061ffff021916905550600101611160565b5090565b90565b50600090555600a165627a7a7230582011b9a8b2fe6341272836fb36535a5f03b46544a58a14b17b7d49405a8247b7d10029",- "sourceMap": "26:1413:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;26:1413:0;;;;;;;",- "deployedSourceMap": "26:1413:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;439:742;;8:9:-1;5:2;;;30:1;27;20:12;5:2;439:742:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;104:19;;8:9:-1;5:2;;;30:1;27;20:12;5:2;104:19:0;;;;;;;;;;;;;;;;;;;;;;;;;;;221:23;;8:9:-1;5:2;;;30:1;27;20:12;5:2;221:23:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;221:23:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1187:246;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1187:246:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1187:246:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1187:246:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1187:246:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1187:246:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;81:17;;8:9:-1;5:2;;;30:1;27;20:12;5:2;81:17:0;;;;;;;;;;;;;;;;;;;;;;;192:23;;8:9:-1;5:2;;;30:1;27;20:12;5:2;192:23:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;56:19;;8:9:-1;5:2;;;30:1;27;20:12;5:2;56:19:0;;;;;;;;;;;;;;;;;;;;;;;129:23;;8:9:-1;5:2;;;30:1;27;20:12;5:2;129:23:0;;;;;;;;;;;;;;;;;;;;;;;;;;;250:25;;8:9:-1;5:2;;;30:1;27;20:12;5:2;250:25:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;158:28;;8:9:-1;5:2;;;30:1;27;20:12;5:2;158:28:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;281:38;;8:9:-1;5:2;;;30:1;27;20:12;5:2;281:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;439:742;675:8;655:7;:28;;;;714:7;694:6;:27;;;;752:8;732:7;;:28;;;;;;;;;;;;;;;;;;791:10;771:9;;:30;;;;;;;;;;;;;;;;;;;;832:14;812:13;:34;;;;;;;:::i;:::-;;877:11;857:10;:31;;;;;;;;;;;;:::i;:::-;;919:10;899:9;:30;;;;;;;;;;;;:::i;:::-;;960:11;940:10;;:31;;;;;;;;;;;;;;;;;;;1004:20;982:19;:42;;;;;;;;;;;;:::i;:::-;;1050:124;1058:8;1068:7;1077:8;1087:10;1099:14;1115:11;1128:10;1140:11;1153:20;1050:124;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1050:124:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1050:124:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1050:124:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1050:124:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;439:742;;;;;;;;;:::o;104:19::-;;;;;;;;;;;;;:::o;221:23::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;1187:246::-;1232:4;1238:3;1243:4;1249:6;1257:7;;:::i;:::-;1266:5;1273:6;1281:7;1290:11;1319:7;;1328:6;;1336:7;;;;;;;;;;;1345:9;;;;;;;;;;;1356:13;1371:10;1383:9;1394:10;;;;;;;;;;;1406:19;1311:115;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1187:246;;;;;;;;;:::o;81:17::-;;;;:::o;192:23::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;56:19::-;;;;:::o;129:23::-;;;;;;;;;;;;;:::o;250:25::-;;;;;;;;;;;;;:::o;158:28::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;281:38::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;26:1413::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;26:1413:0;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;:::o",- "source": "pragma solidity ^0.4.13;\n\ncontract ComplexStorage {\n uint public uintVal;\n int public intVal;\n bool public boolVal;\n int224 public int224Val;\n bool[2] public boolVectorVal;\n int[] public intListVal;\n string public stringVal;\n bytes16 public bytes16Val;\n bytes2[4][] public bytes2VectorListVal;\n\n event ValsSet(uint a, int b, bool c, int224 d, bool[2] e, int[] f, string g, bytes16 h, bytes2[4][] i);\n \n function setValues(uint _uintVal, int _intVal, bool _boolVal, int224 _int224Val, bool[2] _boolVectorVal, int[] _intListVal, string _stringVal, bytes16 _bytes16Val, bytes2[4][] _bytes2VectorListVal) public {\n uintVal = _uintVal;\n intVal = _intVal;\n boolVal = _boolVal;\n int224Val = _int224Val;\n boolVectorVal = _boolVectorVal;\n intListVal = _intListVal;\n stringVal = _stringVal;\n bytes16Val = _bytes16Val;\n bytes2VectorListVal = _bytes2VectorListVal;\n \n emit ValsSet(_uintVal, _intVal, _boolVal, _int224Val, _boolVectorVal, _intListVal, _stringVal, _bytes16Val, _bytes2VectorListVal);\n }\n\n function getVals () constant public returns (uint, int, bool, int224, bool[2], int[], string, bytes16, bytes2[4][]) {\n return (uintVal, intVal, boolVal, int224Val, boolVectorVal, intListVal, stringVal, bytes16Val, bytes2VectorListVal);\n }\n \n}\n",- "sourcePath": "/home/akru/hsweb3test/contracts/ComplexStorage.sol",- "ast": {- "absolutePath": "/home/akru/hsweb3test/contracts/ComplexStorage.sol",- "exportedSymbols": {- "ComplexStorage": [- 167- ]- },- "id": 168,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 1,- "literals": [- "solidity",- "^",- "0.4",- ".13"- ],- "nodeType": "PragmaDirective",- "src": "0:24:0"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 167,- "linearizedBaseContracts": [- 167- ],- "name": "ComplexStorage",- "nodeType": "ContractDefinition",- "nodes": [- {- "constant": false,- "id": 3,- "name": "uintVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "56:19:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 2,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "56:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 5,- "name": "intVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "81:17:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 4,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "81:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 7,- "name": "boolVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "104:19:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 6,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "104:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 9,- "name": "int224Val",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "129:23:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 8,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "129:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 13,- "name": "boolVectorVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "158:28:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 10,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "158:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 12,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 11,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "163:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "158:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 16,- "name": "intListVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "192:23:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 14,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "192:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 15,- "length": null,- "nodeType": "ArrayTypeName",- "src": "192:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 18,- "name": "stringVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "221:23:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string"- },- "typeName": {- "id": 17,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "221:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 20,- "name": "bytes16Val",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "250:25:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 19,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "250:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 25,- "name": "bytes2VectorListVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "281:38:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 21,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "281:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 23,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 22,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "288:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "281:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 24,- "length": null,- "nodeType": "ArrayTypeName",- "src": "281:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "public"- },- {- "anonymous": false,- "documentation": null,- "id": 51,- "name": "ValsSet",- "nodeType": "EventDefinition",- "parameters": {- "id": 50,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 27,- "indexed": false,- "name": "a",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "340:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 26,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "340:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 29,- "indexed": false,- "name": "b",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "348:5:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 28,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "348:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 31,- "indexed": false,- "name": "c",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "355:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 30,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "355:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 33,- "indexed": false,- "name": "d",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "363:8:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 32,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "363:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 37,- "indexed": false,- "name": "e",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "373:9:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 34,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "373:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 36,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 35,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "378:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "373:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 40,- "indexed": false,- "name": "f",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "384:7:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 38,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "384:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 39,- "length": null,- "nodeType": "ArrayTypeName",- "src": "384:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 42,- "indexed": false,- "name": "g",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "393:8:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 41,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "393:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 44,- "indexed": false,- "name": "h",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "403:9:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 43,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "403:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 49,- "indexed": false,- "name": "i",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "414:13:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 45,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "414:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 47,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 46,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "421:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "414:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 48,- "length": null,- "nodeType": "ArrayTypeName",- "src": "414:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "339:89:0"- },- "src": "326:103:0"- },- {- "body": {- "id": 126,- "nodeType": "Block",- "src": "644:537:0",- "statements": [- {- "expression": {- "argumentTypes": null,- "id": 80,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 78,- "name": "uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 3,- "src": "655:7:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 79,- "name": "_uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 53,- "src": "675:8:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "src": "655:28:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "id": 81,- "nodeType": "ExpressionStatement",- "src": "655:28:0"- },- {- "expression": {- "argumentTypes": null,- "id": 84,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 82,- "name": "intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 5,- "src": "694:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 83,- "name": "_intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 55,- "src": "714:7:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "src": "694:27:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 85,- "nodeType": "ExpressionStatement",- "src": "694:27:0"- },- {- "expression": {- "argumentTypes": null,- "id": 88,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 86,- "name": "boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 7,- "src": "732:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 87,- "name": "_boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 57,- "src": "752:8:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "src": "732:28:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 89,- "nodeType": "ExpressionStatement",- "src": "732:28:0"- },- {- "expression": {- "argumentTypes": null,- "id": 92,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 90,- "name": "int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 9,- "src": "771:9:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 91,- "name": "_int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 59,- "src": "791:10:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "src": "771:30:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "id": 93,- "nodeType": "ExpressionStatement",- "src": "771:30:0"- },- {- "expression": {- "argumentTypes": null,- "id": 96,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 94,- "name": "boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 13,- "src": "812:13:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2] storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 95,- "name": "_boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 63,- "src": "832:14:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2] memory"- }- },- "src": "812:34:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2] storage ref"- }- },- "id": 97,- "nodeType": "ExpressionStatement",- "src": "812:34:0"- },- {- "expression": {- "argumentTypes": null,- "id": 100,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 98,- "name": "intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 16,- "src": "857:10:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[] storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 99,- "name": "_intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 66,- "src": "877:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[] memory"- }- },- "src": "857:31:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[] storage ref"- }- },- "id": 101,- "nodeType": "ExpressionStatement",- "src": "857:31:0"- },- {- "expression": {- "argumentTypes": null,- "id": 104,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 102,- "name": "stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 18,- "src": "899:9:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 103,- "name": "_stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 68,- "src": "919:10:0",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string memory"- }- },- "src": "899:30:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string storage ref"- }- },- "id": 105,- "nodeType": "ExpressionStatement",- "src": "899:30:0"- },- {- "expression": {- "argumentTypes": null,- "id": 108,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 106,- "name": "bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 20,- "src": "940:10:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 107,- "name": "_bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 70,- "src": "960:11:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "src": "940:31:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "id": 109,- "nodeType": "ExpressionStatement",- "src": "940:31:0"- },- {- "expression": {- "argumentTypes": null,- "id": 112,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 110,- "name": "bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 25,- "src": "982:19:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4] storage ref[] storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 111,- "name": "_bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 75,- "src": "1004:20:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4] memory[] memory"- }- },- "src": "982:42:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4] storage ref[] storage ref"- }- },- "id": 113,- "nodeType": "ExpressionStatement",- "src": "982:42:0"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "id": 115,- "name": "_uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 53,- "src": "1058:8:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- {- "argumentTypes": null,- "id": 116,- "name": "_intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 55,- "src": "1068:7:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- {- "argumentTypes": null,- "id": 117,- "name": "_boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 57,- "src": "1077:8:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- {- "argumentTypes": null,- "id": 118,- "name": "_int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 59,- "src": "1087:10:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- {- "argumentTypes": null,- "id": 119,- "name": "_boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 63,- "src": "1099:14:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2] memory"- }- },- {- "argumentTypes": null,- "id": 120,- "name": "_intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 66,- "src": "1115:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[] memory"- }- },- {- "argumentTypes": null,- "id": 121,- "name": "_stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 68,- "src": "1128:10:0",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string memory"- }- },- {- "argumentTypes": null,- "id": 122,- "name": "_bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 70,- "src": "1140:11:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- {- "argumentTypes": null,- "id": 123,- "name": "_bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 75,- "src": "1153:20:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4] memory[] memory"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2] memory"- },- {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[] memory"- },- {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string memory"- },- {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4] memory[] memory"- }- ],- "id": 114,- "name": "ValsSet",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 51,- "src": "1050:7:0",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_int256_$_t_bool_$_t_int224_$_t_array$_t_bool_$2_memory_ptr_$_t_array$_t_int256_$dyn_memory_ptr_$_t_string_memory_ptr_$_t_bytes16_$_t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr_$returns$__$",- "typeString": "function (uint256,int256,bool,int224,bool[2] memory,int256[] memory,string memory,bytes16,bytes2[4] memory[] memory)"- }- },- "id": 124,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "1050:124:0",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 125,- "nodeType": "EmitStatement",- "src": "1045:129:0"- }- ]- },- "documentation": null,- "id": 127,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "setValues",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 76,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 53,- "name": "_uintVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "458:13:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 52,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "458:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 55,- "name": "_intVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "473:11:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 54,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "473:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 57,- "name": "_boolVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "486:13:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 56,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "486:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 59,- "name": "_int224Val",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "501:17:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 58,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "501:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 63,- "name": "_boolVectorVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "520:22:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 60,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "520:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 62,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 61,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "525:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "520:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 66,- "name": "_intListVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "544:17:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 64,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "544:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 65,- "length": null,- "nodeType": "ArrayTypeName",- "src": "544:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 68,- "name": "_stringVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "563:17:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 67,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "563:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 70,- "name": "_bytes16Val",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "582:19:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 69,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "582:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 75,- "name": "_bytes2VectorListVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "603:32:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 71,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "603:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 73,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 72,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "610:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "603:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 74,- "length": null,- "nodeType": "ArrayTypeName",- "src": "603:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "457:179:0"- },- "payable": false,- "returnParameters": {- "id": 77,- "nodeType": "ParameterList",- "parameters": [],- "src": "644:0:0"- },- "scope": 167,- "src": "439:742:0",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 165,- "nodeType": "Block",- "src": "1303:130:0",- "statements": [- {- "expression": {- "argumentTypes": null,- "components": [- {- "argumentTypes": null,- "id": 154,- "name": "uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 3,- "src": "1319:7:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- {- "argumentTypes": null,- "id": 155,- "name": "intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 5,- "src": "1328:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- {- "argumentTypes": null,- "id": 156,- "name": "boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 7,- "src": "1336:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- {- "argumentTypes": null,- "id": 157,- "name": "int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 9,- "src": "1345:9:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- {- "argumentTypes": null,- "id": 158,- "name": "boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 13,- "src": "1356:13:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2] storage ref"- }- },- {- "argumentTypes": null,- "id": 159,- "name": "intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 16,- "src": "1371:10:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[] storage ref"- }- },- {- "argumentTypes": null,- "id": 160,- "name": "stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 18,- "src": "1383:9:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string storage ref"- }- },- {- "argumentTypes": null,- "id": 161,- "name": "bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 20,- "src": "1394:10:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- {- "argumentTypes": null,- "id": 162,- "name": "bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 25,- "src": "1406:19:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4] storage ref[] storage ref"- }- }- ],- "id": 163,- "isConstant": false,- "isInlineArray": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "nodeType": "TupleExpression",- "src": "1318:108:0",- "typeDescriptions": {- "typeIdentifier": "t_tuple$_t_uint256_$_t_int256_$_t_bool_$_t_int224_$_t_array$_t_bool_$2_storage_$_t_array$_t_int256_$dyn_storage_$_t_string_storage_$_t_bytes16_$_t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_$",- "typeString": "tuple(uint256,int256,bool,int224,bool[2] storage ref,int256[] storage ref,string storage ref,bytes16,bytes2[4] storage ref[] storage ref)"- }- },- "functionReturnParameters": 153,- "id": 164,- "nodeType": "Return",- "src": "1311:115:0"- }- ]- },- "documentation": null,- "id": 166,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": true,- "modifiers": [],- "name": "getVals",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 128,- "nodeType": "ParameterList",- "parameters": [],- "src": "1204:2:0"- },- "payable": false,- "returnParameters": {- "id": 153,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 130,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1232:4:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 129,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "1232:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 132,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1238:3:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 131,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "1238:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 134,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1243:4:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 133,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "1243:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 136,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1249:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 135,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "1249:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 140,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1257:7:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 137,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "1257:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 139,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 138,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "1262:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "1257:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 143,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1266:5:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 141,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "1266:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 142,- "length": null,- "nodeType": "ArrayTypeName",- "src": "1266:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 145,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1273:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 144,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "1273:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 147,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1281:7:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 146,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "1281:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 152,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1290:11:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 148,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "1290:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 150,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 149,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "1297:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "1290:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 151,- "length": null,- "nodeType": "ArrayTypeName",- "src": "1290:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "1231:71:0"- },- "scope": 167,- "src": "1187:246:0",- "stateMutability": "view",- "superFunction": null,- "visibility": "public"- }- ],- "scope": 168,- "src": "26:1413:0"- }- ],- "src": "0:1440:0"- },- "legacyAST": {- "absolutePath": "/home/akru/hsweb3test/contracts/ComplexStorage.sol",- "exportedSymbols": {- "ComplexStorage": [- 167- ]- },- "id": 168,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 1,- "literals": [- "solidity",- "^",- "0.4",- ".13"- ],- "nodeType": "PragmaDirective",- "src": "0:24:0"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 167,- "linearizedBaseContracts": [- 167- ],- "name": "ComplexStorage",- "nodeType": "ContractDefinition",- "nodes": [- {- "constant": false,- "id": 3,- "name": "uintVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "56:19:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 2,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "56:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 5,- "name": "intVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "81:17:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 4,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "81:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 7,- "name": "boolVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "104:19:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 6,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "104:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 9,- "name": "int224Val",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "129:23:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 8,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "129:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 13,- "name": "boolVectorVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "158:28:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 10,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "158:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 12,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 11,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "163:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "158:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 16,- "name": "intListVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "192:23:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 14,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "192:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 15,- "length": null,- "nodeType": "ArrayTypeName",- "src": "192:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 18,- "name": "stringVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "221:23:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string"- },- "typeName": {- "id": 17,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "221:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 20,- "name": "bytes16Val",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "250:25:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 19,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "250:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "public"- },- {- "constant": false,- "id": 25,- "name": "bytes2VectorListVal",- "nodeType": "VariableDeclaration",- "scope": 167,- "src": "281:38:0",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 21,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "281:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 23,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 22,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "288:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "281:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 24,- "length": null,- "nodeType": "ArrayTypeName",- "src": "281:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "public"- },- {- "anonymous": false,- "documentation": null,- "id": 51,- "name": "ValsSet",- "nodeType": "EventDefinition",- "parameters": {- "id": 50,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 27,- "indexed": false,- "name": "a",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "340:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 26,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "340:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 29,- "indexed": false,- "name": "b",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "348:5:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 28,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "348:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 31,- "indexed": false,- "name": "c",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "355:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 30,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "355:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 33,- "indexed": false,- "name": "d",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "363:8:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 32,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "363:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 37,- "indexed": false,- "name": "e",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "373:9:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 34,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "373:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 36,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 35,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "378:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "373:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 40,- "indexed": false,- "name": "f",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "384:7:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 38,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "384:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 39,- "length": null,- "nodeType": "ArrayTypeName",- "src": "384:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 42,- "indexed": false,- "name": "g",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "393:8:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 41,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "393:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 44,- "indexed": false,- "name": "h",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "403:9:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 43,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "403:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 49,- "indexed": false,- "name": "i",- "nodeType": "VariableDeclaration",- "scope": 51,- "src": "414:13:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 45,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "414:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 47,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 46,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "421:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "414:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 48,- "length": null,- "nodeType": "ArrayTypeName",- "src": "414:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "339:89:0"- },- "src": "326:103:0"- },- {- "body": {- "id": 126,- "nodeType": "Block",- "src": "644:537:0",- "statements": [- {- "expression": {- "argumentTypes": null,- "id": 80,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 78,- "name": "uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 3,- "src": "655:7:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 79,- "name": "_uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 53,- "src": "675:8:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "src": "655:28:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "id": 81,- "nodeType": "ExpressionStatement",- "src": "655:28:0"- },- {- "expression": {- "argumentTypes": null,- "id": 84,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 82,- "name": "intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 5,- "src": "694:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 83,- "name": "_intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 55,- "src": "714:7:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "src": "694:27:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 85,- "nodeType": "ExpressionStatement",- "src": "694:27:0"- },- {- "expression": {- "argumentTypes": null,- "id": 88,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 86,- "name": "boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 7,- "src": "732:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 87,- "name": "_boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 57,- "src": "752:8:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "src": "732:28:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 89,- "nodeType": "ExpressionStatement",- "src": "732:28:0"- },- {- "expression": {- "argumentTypes": null,- "id": 92,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 90,- "name": "int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 9,- "src": "771:9:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 91,- "name": "_int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 59,- "src": "791:10:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "src": "771:30:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "id": 93,- "nodeType": "ExpressionStatement",- "src": "771:30:0"- },- {- "expression": {- "argumentTypes": null,- "id": 96,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 94,- "name": "boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 13,- "src": "812:13:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2] storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 95,- "name": "_boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 63,- "src": "832:14:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2] memory"- }- },- "src": "812:34:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2] storage ref"- }- },- "id": 97,- "nodeType": "ExpressionStatement",- "src": "812:34:0"- },- {- "expression": {- "argumentTypes": null,- "id": 100,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 98,- "name": "intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 16,- "src": "857:10:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[] storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 99,- "name": "_intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 66,- "src": "877:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[] memory"- }- },- "src": "857:31:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[] storage ref"- }- },- "id": 101,- "nodeType": "ExpressionStatement",- "src": "857:31:0"- },- {- "expression": {- "argumentTypes": null,- "id": 104,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 102,- "name": "stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 18,- "src": "899:9:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 103,- "name": "_stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 68,- "src": "919:10:0",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string memory"- }- },- "src": "899:30:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string storage ref"- }- },- "id": 105,- "nodeType": "ExpressionStatement",- "src": "899:30:0"- },- {- "expression": {- "argumentTypes": null,- "id": 108,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 106,- "name": "bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 20,- "src": "940:10:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 107,- "name": "_bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 70,- "src": "960:11:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "src": "940:31:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "id": 109,- "nodeType": "ExpressionStatement",- "src": "940:31:0"- },- {- "expression": {- "argumentTypes": null,- "id": 112,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 110,- "name": "bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 25,- "src": "982:19:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4] storage ref[] storage ref"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 111,- "name": "_bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 75,- "src": "1004:20:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4] memory[] memory"- }- },- "src": "982:42:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4] storage ref[] storage ref"- }- },- "id": 113,- "nodeType": "ExpressionStatement",- "src": "982:42:0"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "id": 115,- "name": "_uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 53,- "src": "1058:8:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- {- "argumentTypes": null,- "id": 116,- "name": "_intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 55,- "src": "1068:7:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- {- "argumentTypes": null,- "id": 117,- "name": "_boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 57,- "src": "1077:8:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- {- "argumentTypes": null,- "id": 118,- "name": "_int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 59,- "src": "1087:10:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- {- "argumentTypes": null,- "id": 119,- "name": "_boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 63,- "src": "1099:14:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2] memory"- }- },- {- "argumentTypes": null,- "id": 120,- "name": "_intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 66,- "src": "1115:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[] memory"- }- },- {- "argumentTypes": null,- "id": 121,- "name": "_stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 68,- "src": "1128:10:0",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string memory"- }- },- {- "argumentTypes": null,- "id": 122,- "name": "_bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 70,- "src": "1140:11:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- {- "argumentTypes": null,- "id": 123,- "name": "_bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 75,- "src": "1153:20:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4] memory[] memory"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2] memory"- },- {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[] memory"- },- {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string memory"- },- {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4] memory[] memory"- }- ],- "id": 114,- "name": "ValsSet",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 51,- "src": "1050:7:0",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_int256_$_t_bool_$_t_int224_$_t_array$_t_bool_$2_memory_ptr_$_t_array$_t_int256_$dyn_memory_ptr_$_t_string_memory_ptr_$_t_bytes16_$_t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr_$returns$__$",- "typeString": "function (uint256,int256,bool,int224,bool[2] memory,int256[] memory,string memory,bytes16,bytes2[4] memory[] memory)"- }- },- "id": 124,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "1050:124:0",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 125,- "nodeType": "EmitStatement",- "src": "1045:129:0"- }- ]- },- "documentation": null,- "id": 127,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "setValues",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 76,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 53,- "name": "_uintVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "458:13:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 52,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "458:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 55,- "name": "_intVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "473:11:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 54,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "473:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 57,- "name": "_boolVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "486:13:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 56,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "486:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 59,- "name": "_int224Val",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "501:17:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 58,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "501:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 63,- "name": "_boolVectorVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "520:22:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 60,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "520:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 62,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 61,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "525:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "520:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 66,- "name": "_intListVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "544:17:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 64,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "544:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 65,- "length": null,- "nodeType": "ArrayTypeName",- "src": "544:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 68,- "name": "_stringVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "563:17:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 67,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "563:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 70,- "name": "_bytes16Val",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "582:19:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 69,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "582:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 75,- "name": "_bytes2VectorListVal",- "nodeType": "VariableDeclaration",- "scope": 127,- "src": "603:32:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 71,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "603:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 73,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 72,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "610:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "603:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 74,- "length": null,- "nodeType": "ArrayTypeName",- "src": "603:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "457:179:0"- },- "payable": false,- "returnParameters": {- "id": 77,- "nodeType": "ParameterList",- "parameters": [],- "src": "644:0:0"- },- "scope": 167,- "src": "439:742:0",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 165,- "nodeType": "Block",- "src": "1303:130:0",- "statements": [- {- "expression": {- "argumentTypes": null,- "components": [- {- "argumentTypes": null,- "id": 154,- "name": "uintVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 3,- "src": "1319:7:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- {- "argumentTypes": null,- "id": 155,- "name": "intVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 5,- "src": "1328:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- {- "argumentTypes": null,- "id": 156,- "name": "boolVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 7,- "src": "1336:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- {- "argumentTypes": null,- "id": 157,- "name": "int224Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 9,- "src": "1345:9:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- {- "argumentTypes": null,- "id": 158,- "name": "boolVectorVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 13,- "src": "1356:13:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage",- "typeString": "bool[2] storage ref"- }- },- {- "argumentTypes": null,- "id": 159,- "name": "intListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 16,- "src": "1371:10:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage",- "typeString": "int256[] storage ref"- }- },- {- "argumentTypes": null,- "id": 160,- "name": "stringVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 18,- "src": "1383:9:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage",- "typeString": "string storage ref"- }- },- {- "argumentTypes": null,- "id": 161,- "name": "bytes16Val",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 20,- "src": "1394:10:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- {- "argumentTypes": null,- "id": 162,- "name": "bytes2VectorListVal",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 25,- "src": "1406:19:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage",- "typeString": "bytes2[4] storage ref[] storage ref"- }- }- ],- "id": 163,- "isConstant": false,- "isInlineArray": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "nodeType": "TupleExpression",- "src": "1318:108:0",- "typeDescriptions": {- "typeIdentifier": "t_tuple$_t_uint256_$_t_int256_$_t_bool_$_t_int224_$_t_array$_t_bool_$2_storage_$_t_array$_t_int256_$dyn_storage_$_t_string_storage_$_t_bytes16_$_t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_$",- "typeString": "tuple(uint256,int256,bool,int224,bool[2] storage ref,int256[] storage ref,string storage ref,bytes16,bytes2[4] storage ref[] storage ref)"- }- },- "functionReturnParameters": 153,- "id": 164,- "nodeType": "Return",- "src": "1311:115:0"- }- ]- },- "documentation": null,- "id": 166,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": true,- "modifiers": [],- "name": "getVals",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 128,- "nodeType": "ParameterList",- "parameters": [],- "src": "1204:2:0"- },- "payable": false,- "returnParameters": {- "id": 153,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 130,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1232:4:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 129,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "1232:4:0",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 132,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1238:3:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- },- "typeName": {- "id": 131,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "1238:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 134,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1243:4:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- },- "typeName": {- "id": 133,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "1243:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 136,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1249:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- },- "typeName": {- "id": 135,- "name": "int224",- "nodeType": "ElementaryTypeName",- "src": "1249:6:0",- "typeDescriptions": {- "typeIdentifier": "t_int224",- "typeString": "int224"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 140,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1257:7:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_memory_ptr",- "typeString": "bool[2]"- },- "typeName": {- "baseType": {- "id": 137,- "name": "bool",- "nodeType": "ElementaryTypeName",- "src": "1257:4:0",- "typeDescriptions": {- "typeIdentifier": "t_bool",- "typeString": "bool"- }- },- "id": 139,- "length": {- "argumentTypes": null,- "hexValue": "32",- "id": 138,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "1262:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "2"- },- "nodeType": "ArrayTypeName",- "src": "1257:7:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bool_$2_storage_ptr",- "typeString": "bool[2]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 143,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1266:5:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",- "typeString": "int256[]"- },- "typeName": {- "baseType": {- "id": 141,- "name": "int",- "nodeType": "ElementaryTypeName",- "src": "1266:3:0",- "typeDescriptions": {- "typeIdentifier": "t_int256",- "typeString": "int256"- }- },- "id": 142,- "length": null,- "nodeType": "ArrayTypeName",- "src": "1266:5:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",- "typeString": "int256[]"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 145,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1273:6:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 144,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "1273:6:0",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 147,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1281:7:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- },- "typeName": {- "id": 146,- "name": "bytes16",- "nodeType": "ElementaryTypeName",- "src": "1281:7:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes16",- "typeString": "bytes16"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 152,- "name": "",- "nodeType": "VariableDeclaration",- "scope": 166,- "src": "1290:11:0",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_memory_$dyn_memory_ptr",- "typeString": "bytes2[4][]"- },- "typeName": {- "baseType": {- "baseType": {- "id": 148,- "name": "bytes2",- "nodeType": "ElementaryTypeName",- "src": "1290:6:0",- "typeDescriptions": {- "typeIdentifier": "t_bytes2",- "typeString": "bytes2"- }- },- "id": 150,- "length": {- "argumentTypes": null,- "hexValue": "34",- "id": 149,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "1297:1:0",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": null,- "typeString": null- },- "value": "4"- },- "nodeType": "ArrayTypeName",- "src": "1290:9:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_bytes2_$4_storage_ptr",- "typeString": "bytes2[4]"- }- },- "id": 151,- "length": null,- "nodeType": "ArrayTypeName",- "src": "1290:11:0",- "typeDescriptions": {- "typeIdentifier": "t_array$_t_array$_t_bytes2_$4_storage_$dyn_storage_ptr",- "typeString": "bytes2[4][]"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "1231:71:0"- },- "scope": 167,- "src": "1187:246:0",- "stateMutability": "view",- "superFunction": null,- "visibility": "public"- }- ],- "scope": 168,- "src": "26:1413:0"- }- ],- "src": "0:1440:0"- },- "compiler": {- "name": "solc",- "version": "0.4.24+commit.e67f0147.Emscripten.clang"- },- "networks": {},- "schemaVersion": "2.0.1",- "updatedAt": "2018-10-17T08:28:45.994Z"-}
@@ -1,2716 +0,0 @@-{- "contractName": "Linearization",- "abi": [- {- "anonymous": false,- "inputs": [- {- "indexed": false,- "name": "sender",- "type": "address"- },- {- "indexed": false,- "name": "amount",- "type": "uint256"- }- ],- "name": "E1",- "type": "event"- },- {- "anonymous": false,- "inputs": [- {- "indexed": false,- "name": "tag",- "type": "string"- },- {- "indexed": false,- "name": "uuid",- "type": "bytes4"- }- ],- "name": "E2",- "type": "event"- },- {- "anonymous": false,- "inputs": [- {- "indexed": false,- "name": "txOrigin",- "type": "address"- },- {- "indexed": false,- "name": "blockNumber",- "type": "uint256"- }- ],- "name": "E3",- "type": "event"- },- {- "anonymous": false,- "inputs": [- {- "indexed": false,- "name": "sig",- "type": "bytes4"- },- {- "indexed": false,- "name": "blockHash",- "type": "bytes32"- }- ],- "name": "E4",- "type": "event"- },- {- "constant": false,- "inputs": [],- "name": "e12",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- },- {- "constant": false,- "inputs": [],- "name": "e21",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- },- {- "constant": false,- "inputs": [],- "name": "e1",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- },- {- "constant": false,- "inputs": [],- "name": "e2",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- },- {- "constant": false,- "inputs": [],- "name": "e3",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- },- {- "constant": false,- "inputs": [],- "name": "e4",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- }- ],- "bytecode": "0x608060405234801561001057600080fd5b506105ad806100206000396000f300608060405260043610610077576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062def0b21461007c57806356800b521461009357806379e5f054146100aa5780639b31f9e8146100c1578063a0f29798146100d8578063a2c2d666146100ef575b600080fd5b34801561008857600080fd5b50610091610106565b005b34801561009f57600080fd5b506100a8610226565b005b3480156100b657600080fd5b506100bf610293565b005b3480156100cd57600080fd5b506100d661033f565b005b3480156100e457600080fd5b506100ed6103f3565b005b3480156100fb57600080fd5b50610104610513565b005b7f39be10caf08413c53cba369135da2b641931c99ac27b0d821e26f3ec4e0c63d2336000604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a17fa7070e1659496fddc8e134f7c9c487aba246b54d9a23918210a30bfa32af9e4563deadbeef6040518080602001837c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001828103825260058152602001807f68656c6c6f0000000000000000000000000000000000000000000000000000008152506020019250505060405180910390a1565b7fe86793c401899b62baf9c8e9b8a8803ece6ace1021d056fe8634d1f59a0410c13243604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1565b7fd8f3042e770b7de0dc534d3accbe98fba747e05ada6febe1a03d1e098521edc26000357fffffffff0000000000000000000000000000000000000000000000000000000016434060405180837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200182600019166000191681526020019250505060405180910390a1565b7fa7070e1659496fddc8e134f7c9c487aba246b54d9a23918210a30bfa32af9e4563deadbeef6040518080602001837c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001828103825260058152602001807f68656c6c6f0000000000000000000000000000000000000000000000000000008152506020019250505060405180910390a1565b7fa7070e1659496fddc8e134f7c9c487aba246b54d9a23918210a30bfa32af9e4563deadbeef6040518080602001837c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001828103825260058152602001807f68656c6c6f0000000000000000000000000000000000000000000000000000008152506020019250505060405180910390a17f39be10caf08413c53cba369135da2b641931c99ac27b0d821e26f3ec4e0c63d2336000604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1565b7f39be10caf08413c53cba369135da2b641931c99ac27b0d821e26f3ec4e0c63d2336000604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15600a165627a7a72305820be9afa4ce385da787f13197a249b8d9d1c557381e3c46f9bbada45913eee79870029",- "deployedBytecode": "0x608060405260043610610077576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062def0b21461007c57806356800b521461009357806379e5f054146100aa5780639b31f9e8146100c1578063a0f29798146100d8578063a2c2d666146100ef575b600080fd5b34801561008857600080fd5b50610091610106565b005b34801561009f57600080fd5b506100a8610226565b005b3480156100b657600080fd5b506100bf610293565b005b3480156100cd57600080fd5b506100d661033f565b005b3480156100e457600080fd5b506100ed6103f3565b005b3480156100fb57600080fd5b50610104610513565b005b7f39be10caf08413c53cba369135da2b641931c99ac27b0d821e26f3ec4e0c63d2336000604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a17fa7070e1659496fddc8e134f7c9c487aba246b54d9a23918210a30bfa32af9e4563deadbeef6040518080602001837c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001828103825260058152602001807f68656c6c6f0000000000000000000000000000000000000000000000000000008152506020019250505060405180910390a1565b7fe86793c401899b62baf9c8e9b8a8803ece6ace1021d056fe8634d1f59a0410c13243604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1565b7fd8f3042e770b7de0dc534d3accbe98fba747e05ada6febe1a03d1e098521edc26000357fffffffff0000000000000000000000000000000000000000000000000000000016434060405180837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200182600019166000191681526020019250505060405180910390a1565b7fa7070e1659496fddc8e134f7c9c487aba246b54d9a23918210a30bfa32af9e4563deadbeef6040518080602001837c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001828103825260058152602001807f68656c6c6f0000000000000000000000000000000000000000000000000000008152506020019250505060405180910390a1565b7fa7070e1659496fddc8e134f7c9c487aba246b54d9a23918210a30bfa32af9e4563deadbeef6040518080602001837c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001828103825260058152602001807f68656c6c6f0000000000000000000000000000000000000000000000000000008152506020019250505060405180910390a17f39be10caf08413c53cba369135da2b641931c99ac27b0d821e26f3ec4e0c63d2336000604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1565b7f39be10caf08413c53cba369135da2b641931c99ac27b0d821e26f3ec4e0c63d2336000604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15600a165627a7a72305820be9afa4ce385da787f13197a249b8d9d1c557381e3c46f9bbada45913eee79870029",- "sourceMap": "26:649:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;26:649:1;;;;;;;",- "deployedSourceMap": "26:649:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;224:89;;8:9:-1;5:2;;;30:1;27;20:12;5:2;224:89:1;;;;;;532:64;;8:9:-1;5:2;;;30:1;27;20:12;5:2;532:64:1;;;;;;600:73;;8:9:-1;5:2;;;30:1;27;20:12;5:2;600:73:1;;;;;;468:60;;8:9:-1;5:2;;;30:1;27;20:12;5:2;468:60:1;;;;;;317:89;;8:9:-1;5:2;;;30:1;27;20:12;5:2;317:89:1;;;;;;410:54;;8:9:-1;5:2;;;30:1;27;20:12;5:2;410:54:1;;;;;;224:89;257:17;260:10;272:1;257:17;;;;;;;;;;;;;;;;;;;;;;;;;;;;285:23;297:10;285:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;224:89::o;532:64::-;564:27;567:9;578:12;564:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;532:64::o;600:73::-;632:36;635:7;;;;654:12;644:23;632:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;600:73::o;468:60::-;500:23;512:10;500:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;468:60::o;317:89::-;350:23;362:10;350:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;384:17;387:10;399:1;384:17;;;;;;;;;;;;;;;;;;;;;;;;;;;;317:89::o;410:54::-;442:17;445:10;457:1;442:17;;;;;;;;;;;;;;;;;;;;;;;;;;;;410:54::o",- "source": "pragma solidity ^0.4.22;\n\ncontract Linearization {\n\n event E1(address sender, uint amount);\n event E2(string tag, bytes4 uuid);\n event E3(address txOrigin, uint blockNumber);\n event E4(bytes4 sig, bytes32 blockHash);\n\n function e12() public {\n emit E1(msg.sender, 0);\n emit E2(\"hello\", 0xdeadbeef);\n }\n\n function e21() public {\n emit E2(\"hello\", 0xdeadbeef);\n emit E1(msg.sender, 0);\n }\n\n function e1() public {\n emit E1(msg.sender, 0);\n }\n\n function e2() public {\n emit E2(\"hello\", 0xdeadbeef);\n }\n\n function e3() public {\n emit E3(tx.origin, block.number);\n }\n\n function e4() public {\n emit E4(msg.sig, blockhash(block.number));\n }\n}",- "sourcePath": "/home/akru/hsweb3test/contracts/Linearization.sol",- "ast": {- "absolutePath": "/home/akru/hsweb3test/contracts/Linearization.sol",- "exportedSymbols": {- "Linearization": [- 267- ]- },- "id": 268,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 169,- "literals": [- "solidity",- "^",- "0.4",- ".22"- ],- "nodeType": "PragmaDirective",- "src": "0:24:1"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 267,- "linearizedBaseContracts": [- 267- ],- "name": "Linearization",- "nodeType": "ContractDefinition",- "nodes": [- {- "anonymous": false,- "documentation": null,- "id": 175,- "name": "E1",- "nodeType": "EventDefinition",- "parameters": {- "id": 174,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 171,- "indexed": false,- "name": "sender",- "nodeType": "VariableDeclaration",- "scope": 175,- "src": "63:14:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 170,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "63:7:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 173,- "indexed": false,- "name": "amount",- "nodeType": "VariableDeclaration",- "scope": 175,- "src": "79:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 172,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "79:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "62:29:1"- },- "src": "54:38:1"- },- {- "anonymous": false,- "documentation": null,- "id": 181,- "name": "E2",- "nodeType": "EventDefinition",- "parameters": {- "id": 180,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 177,- "indexed": false,- "name": "tag",- "nodeType": "VariableDeclaration",- "scope": 181,- "src": "104:10:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 176,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "104:6:1",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 179,- "indexed": false,- "name": "uuid",- "nodeType": "VariableDeclaration",- "scope": 181,- "src": "116:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- },- "typeName": {- "id": 178,- "name": "bytes4",- "nodeType": "ElementaryTypeName",- "src": "116:6:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "103:25:1"- },- "src": "95:34:1"- },- {- "anonymous": false,- "documentation": null,- "id": 187,- "name": "E3",- "nodeType": "EventDefinition",- "parameters": {- "id": 186,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 183,- "indexed": false,- "name": "txOrigin",- "nodeType": "VariableDeclaration",- "scope": 187,- "src": "141:16:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 182,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "141:7:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 185,- "indexed": false,- "name": "blockNumber",- "nodeType": "VariableDeclaration",- "scope": 187,- "src": "159:16:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 184,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "159:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "140:36:1"- },- "src": "132:45:1"- },- {- "anonymous": false,- "documentation": null,- "id": 193,- "name": "E4",- "nodeType": "EventDefinition",- "parameters": {- "id": 192,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 189,- "indexed": false,- "name": "sig",- "nodeType": "VariableDeclaration",- "scope": 193,- "src": "189:10:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- },- "typeName": {- "id": 188,- "name": "bytes4",- "nodeType": "ElementaryTypeName",- "src": "189:6:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 191,- "indexed": false,- "name": "blockHash",- "nodeType": "VariableDeclaration",- "scope": 193,- "src": "201:17:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 190,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "201:7:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "188:31:1"- },- "src": "180:40:1"- },- {- "body": {- "id": 207,- "nodeType": "Block",- "src": "246:67:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 197,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "260:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 198,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sender",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "260:10:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "hexValue": "30",- "id": 199,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "272:1:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- },- "value": "0"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- }- ],- "id": 196,- "name": "E1",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "257:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 200,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "257:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 201,- "nodeType": "EmitStatement",- "src": "252:22:1"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "hexValue": "68656c6c6f",- "id": 203,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "string",- "lValueRequested": false,- "nodeType": "Literal",- "src": "288:7:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- "value": "hello"- },- {- "argumentTypes": null,- "hexValue": "30786465616462656566",- "id": 204,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "297:10:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- },- "value": "0xdeadbeef"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- }- ],- "id": 202,- "name": "E2",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 181,- "src": "285:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_string_memory_ptr_$_t_bytes4_$returns$__$",- "typeString": "function (string memory,bytes4)"- }- },- "id": 205,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "285:23:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 206,- "nodeType": "EmitStatement",- "src": "280:28:1"- }- ]- },- "documentation": null,- "id": 208,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e12",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 194,- "nodeType": "ParameterList",- "parameters": [],- "src": "236:2:1"- },- "payable": false,- "returnParameters": {- "id": 195,- "nodeType": "ParameterList",- "parameters": [],- "src": "246:0:1"- },- "scope": 267,- "src": "224:89:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 222,- "nodeType": "Block",- "src": "339:67:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "hexValue": "68656c6c6f",- "id": 212,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "string",- "lValueRequested": false,- "nodeType": "Literal",- "src": "353:7:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- "value": "hello"- },- {- "argumentTypes": null,- "hexValue": "30786465616462656566",- "id": 213,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "362:10:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- },- "value": "0xdeadbeef"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- }- ],- "id": 211,- "name": "E2",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 181,- "src": "350:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_string_memory_ptr_$_t_bytes4_$returns$__$",- "typeString": "function (string memory,bytes4)"- }- },- "id": 214,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "350:23:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 215,- "nodeType": "EmitStatement",- "src": "345:28:1"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 217,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "387:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 218,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sender",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "387:10:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "hexValue": "30",- "id": 219,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "399:1:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- },- "value": "0"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- }- ],- "id": 216,- "name": "E1",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "384:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 220,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "384:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 221,- "nodeType": "EmitStatement",- "src": "379:22:1"- }- ]- },- "documentation": null,- "id": 223,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e21",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 209,- "nodeType": "ParameterList",- "parameters": [],- "src": "329:2:1"- },- "payable": false,- "returnParameters": {- "id": 210,- "nodeType": "ParameterList",- "parameters": [],- "src": "339:0:1"- },- "scope": 267,- "src": "317:89:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 232,- "nodeType": "Block",- "src": "431:33:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 227,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "445:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 228,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sender",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "445:10:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "hexValue": "30",- "id": 229,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "457:1:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- },- "value": "0"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- }- ],- "id": 226,- "name": "E1",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "442:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 230,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "442:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 231,- "nodeType": "EmitStatement",- "src": "437:22:1"- }- ]- },- "documentation": null,- "id": 233,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e1",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 224,- "nodeType": "ParameterList",- "parameters": [],- "src": "421:2:1"- },- "payable": false,- "returnParameters": {- "id": 225,- "nodeType": "ParameterList",- "parameters": [],- "src": "431:0:1"- },- "scope": 267,- "src": "410:54:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 241,- "nodeType": "Block",- "src": "489:39:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "hexValue": "68656c6c6f",- "id": 237,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "string",- "lValueRequested": false,- "nodeType": "Literal",- "src": "503:7:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- "value": "hello"- },- {- "argumentTypes": null,- "hexValue": "30786465616462656566",- "id": 238,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "512:10:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- },- "value": "0xdeadbeef"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- }- ],- "id": 236,- "name": "E2",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 181,- "src": "500:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_string_memory_ptr_$_t_bytes4_$returns$__$",- "typeString": "function (string memory,bytes4)"- }- },- "id": 239,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "500:23:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 240,- "nodeType": "EmitStatement",- "src": "495:28:1"- }- ]- },- "documentation": null,- "id": 242,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e2",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 234,- "nodeType": "ParameterList",- "parameters": [],- "src": "479:2:1"- },- "payable": false,- "returnParameters": {- "id": 235,- "nodeType": "ParameterList",- "parameters": [],- "src": "489:0:1"- },- "scope": 267,- "src": "468:60:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 252,- "nodeType": "Block",- "src": "553:43:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 246,- "name": "tx",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 393,- "src": "567:2:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_transaction",- "typeString": "tx"- }- },- "id": 247,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "origin",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "567:9:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 248,- "name": "block",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 371,- "src": "578:5:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_block",- "typeString": "block"- }- },- "id": 249,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "number",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "578:12:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- ],- "id": 245,- "name": "E3",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 187,- "src": "564:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 250,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "564:27:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 251,- "nodeType": "EmitStatement",- "src": "559:32:1"- }- ]- },- "documentation": null,- "id": 253,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e3",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 243,- "nodeType": "ParameterList",- "parameters": [],- "src": "543:2:1"- },- "payable": false,- "returnParameters": {- "id": 244,- "nodeType": "ParameterList",- "parameters": [],- "src": "553:0:1"- },- "scope": 267,- "src": "532:64:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 265,- "nodeType": "Block",- "src": "621:52:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 257,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "635:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 258,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sig",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "635:7:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- }- },- {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 260,- "name": "block",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 371,- "src": "654:5:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_block",- "typeString": "block"- }- },- "id": 261,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "number",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "654:12:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- ],- "id": 259,- "name": "blockhash",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 372,- "src": "644:9:1",- "typeDescriptions": {- "typeIdentifier": "t_function_blockhash_view$_t_uint256_$returns$_t_bytes32_$",- "typeString": "function (uint256) view returns (bytes32)"- }- },- "id": 262,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "644:23:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- },- {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- ],- "id": 256,- "name": "E4",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 193,- "src": "632:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_bytes4_$_t_bytes32_$returns$__$",- "typeString": "function (bytes4,bytes32)"- }- },- "id": 263,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "632:36:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 264,- "nodeType": "EmitStatement",- "src": "627:41:1"- }- ]- },- "documentation": null,- "id": 266,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e4",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 254,- "nodeType": "ParameterList",- "parameters": [],- "src": "611:2:1"- },- "payable": false,- "returnParameters": {- "id": 255,- "nodeType": "ParameterList",- "parameters": [],- "src": "621:0:1"- },- "scope": 267,- "src": "600:73:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- }- ],- "scope": 268,- "src": "26:649:1"- }- ],- "src": "0:675:1"- },- "legacyAST": {- "absolutePath": "/home/akru/hsweb3test/contracts/Linearization.sol",- "exportedSymbols": {- "Linearization": [- 267- ]- },- "id": 268,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 169,- "literals": [- "solidity",- "^",- "0.4",- ".22"- ],- "nodeType": "PragmaDirective",- "src": "0:24:1"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 267,- "linearizedBaseContracts": [- 267- ],- "name": "Linearization",- "nodeType": "ContractDefinition",- "nodes": [- {- "anonymous": false,- "documentation": null,- "id": 175,- "name": "E1",- "nodeType": "EventDefinition",- "parameters": {- "id": 174,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 171,- "indexed": false,- "name": "sender",- "nodeType": "VariableDeclaration",- "scope": 175,- "src": "63:14:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 170,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "63:7:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 173,- "indexed": false,- "name": "amount",- "nodeType": "VariableDeclaration",- "scope": 175,- "src": "79:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 172,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "79:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "62:29:1"- },- "src": "54:38:1"- },- {- "anonymous": false,- "documentation": null,- "id": 181,- "name": "E2",- "nodeType": "EventDefinition",- "parameters": {- "id": 180,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 177,- "indexed": false,- "name": "tag",- "nodeType": "VariableDeclaration",- "scope": 181,- "src": "104:10:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_string_memory_ptr",- "typeString": "string"- },- "typeName": {- "id": 176,- "name": "string",- "nodeType": "ElementaryTypeName",- "src": "104:6:1",- "typeDescriptions": {- "typeIdentifier": "t_string_storage_ptr",- "typeString": "string"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 179,- "indexed": false,- "name": "uuid",- "nodeType": "VariableDeclaration",- "scope": 181,- "src": "116:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- },- "typeName": {- "id": 178,- "name": "bytes4",- "nodeType": "ElementaryTypeName",- "src": "116:6:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "103:25:1"- },- "src": "95:34:1"- },- {- "anonymous": false,- "documentation": null,- "id": 187,- "name": "E3",- "nodeType": "EventDefinition",- "parameters": {- "id": 186,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 183,- "indexed": false,- "name": "txOrigin",- "nodeType": "VariableDeclaration",- "scope": 187,- "src": "141:16:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 182,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "141:7:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 185,- "indexed": false,- "name": "blockNumber",- "nodeType": "VariableDeclaration",- "scope": 187,- "src": "159:16:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 184,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "159:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "140:36:1"- },- "src": "132:45:1"- },- {- "anonymous": false,- "documentation": null,- "id": 193,- "name": "E4",- "nodeType": "EventDefinition",- "parameters": {- "id": 192,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 189,- "indexed": false,- "name": "sig",- "nodeType": "VariableDeclaration",- "scope": 193,- "src": "189:10:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- },- "typeName": {- "id": 188,- "name": "bytes4",- "nodeType": "ElementaryTypeName",- "src": "189:6:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 191,- "indexed": false,- "name": "blockHash",- "nodeType": "VariableDeclaration",- "scope": 193,- "src": "201:17:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 190,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "201:7:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "188:31:1"- },- "src": "180:40:1"- },- {- "body": {- "id": 207,- "nodeType": "Block",- "src": "246:67:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 197,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "260:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 198,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sender",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "260:10:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "hexValue": "30",- "id": 199,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "272:1:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- },- "value": "0"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- }- ],- "id": 196,- "name": "E1",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "257:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 200,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "257:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 201,- "nodeType": "EmitStatement",- "src": "252:22:1"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "hexValue": "68656c6c6f",- "id": 203,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "string",- "lValueRequested": false,- "nodeType": "Literal",- "src": "288:7:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- "value": "hello"- },- {- "argumentTypes": null,- "hexValue": "30786465616462656566",- "id": 204,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "297:10:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- },- "value": "0xdeadbeef"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- }- ],- "id": 202,- "name": "E2",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 181,- "src": "285:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_string_memory_ptr_$_t_bytes4_$returns$__$",- "typeString": "function (string memory,bytes4)"- }- },- "id": 205,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "285:23:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 206,- "nodeType": "EmitStatement",- "src": "280:28:1"- }- ]- },- "documentation": null,- "id": 208,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e12",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 194,- "nodeType": "ParameterList",- "parameters": [],- "src": "236:2:1"- },- "payable": false,- "returnParameters": {- "id": 195,- "nodeType": "ParameterList",- "parameters": [],- "src": "246:0:1"- },- "scope": 267,- "src": "224:89:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 222,- "nodeType": "Block",- "src": "339:67:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "hexValue": "68656c6c6f",- "id": 212,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "string",- "lValueRequested": false,- "nodeType": "Literal",- "src": "353:7:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- "value": "hello"- },- {- "argumentTypes": null,- "hexValue": "30786465616462656566",- "id": 213,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "362:10:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- },- "value": "0xdeadbeef"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- }- ],- "id": 211,- "name": "E2",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 181,- "src": "350:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_string_memory_ptr_$_t_bytes4_$returns$__$",- "typeString": "function (string memory,bytes4)"- }- },- "id": 214,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "350:23:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 215,- "nodeType": "EmitStatement",- "src": "345:28:1"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 217,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "387:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 218,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sender",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "387:10:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "hexValue": "30",- "id": 219,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "399:1:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- },- "value": "0"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- }- ],- "id": 216,- "name": "E1",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "384:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 220,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "384:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 221,- "nodeType": "EmitStatement",- "src": "379:22:1"- }- ]- },- "documentation": null,- "id": 223,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e21",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 209,- "nodeType": "ParameterList",- "parameters": [],- "src": "329:2:1"- },- "payable": false,- "returnParameters": {- "id": 210,- "nodeType": "ParameterList",- "parameters": [],- "src": "339:0:1"- },- "scope": 267,- "src": "317:89:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 232,- "nodeType": "Block",- "src": "431:33:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 227,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "445:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 228,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sender",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "445:10:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "hexValue": "30",- "id": 229,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "457:1:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- },- "value": "0"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_rational_0_by_1",- "typeString": "int_const 0"- }- ],- "id": 226,- "name": "E1",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "442:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 230,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "442:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 231,- "nodeType": "EmitStatement",- "src": "437:22:1"- }- ]- },- "documentation": null,- "id": 233,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e1",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 224,- "nodeType": "ParameterList",- "parameters": [],- "src": "421:2:1"- },- "payable": false,- "returnParameters": {- "id": 225,- "nodeType": "ParameterList",- "parameters": [],- "src": "431:0:1"- },- "scope": 267,- "src": "410:54:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 241,- "nodeType": "Block",- "src": "489:39:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "hexValue": "68656c6c6f",- "id": 237,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "string",- "lValueRequested": false,- "nodeType": "Literal",- "src": "503:7:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- "value": "hello"- },- {- "argumentTypes": null,- "hexValue": "30786465616462656566",- "id": 238,- "isConstant": false,- "isLValue": false,- "isPure": true,- "kind": "number",- "lValueRequested": false,- "nodeType": "Literal",- "src": "512:10:1",- "subdenomination": null,- "typeDescriptions": {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- },- "value": "0xdeadbeef"- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_stringliteral_1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8",- "typeString": "literal_string \"hello\""- },- {- "typeIdentifier": "t_rational_3735928559_by_1",- "typeString": "int_const 3735928559"- }- ],- "id": 236,- "name": "E2",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 181,- "src": "500:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_string_memory_ptr_$_t_bytes4_$returns$__$",- "typeString": "function (string memory,bytes4)"- }- },- "id": 239,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "500:23:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 240,- "nodeType": "EmitStatement",- "src": "495:28:1"- }- ]- },- "documentation": null,- "id": 242,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e2",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 234,- "nodeType": "ParameterList",- "parameters": [],- "src": "479:2:1"- },- "payable": false,- "returnParameters": {- "id": 235,- "nodeType": "ParameterList",- "parameters": [],- "src": "489:0:1"- },- "scope": 267,- "src": "468:60:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 252,- "nodeType": "Block",- "src": "553:43:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 246,- "name": "tx",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 393,- "src": "567:2:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_transaction",- "typeString": "tx"- }- },- "id": 247,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "origin",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "567:9:1",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 248,- "name": "block",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 371,- "src": "578:5:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_block",- "typeString": "block"- }- },- "id": 249,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "number",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "578:12:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_address",- "typeString": "address"- },- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- ],- "id": 245,- "name": "E3",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 187,- "src": "564:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$",- "typeString": "function (address,uint256)"- }- },- "id": 250,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "564:27:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 251,- "nodeType": "EmitStatement",- "src": "559:32:1"- }- ]- },- "documentation": null,- "id": 253,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e3",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 243,- "nodeType": "ParameterList",- "parameters": [],- "src": "543:2:1"- },- "payable": false,- "returnParameters": {- "id": 244,- "nodeType": "ParameterList",- "parameters": [],- "src": "553:0:1"- },- "scope": 267,- "src": "532:64:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- },- {- "body": {- "id": 265,- "nodeType": "Block",- "src": "621:52:1",- "statements": [- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 257,- "name": "msg",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 381,- "src": "635:3:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_message",- "typeString": "msg"- }- },- "id": 258,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "sig",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "635:7:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- }- },- {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "expression": {- "argumentTypes": null,- "id": 260,- "name": "block",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 371,- "src": "654:5:1",- "typeDescriptions": {- "typeIdentifier": "t_magic_block",- "typeString": "block"- }- },- "id": 261,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "memberName": "number",- "nodeType": "MemberAccess",- "referencedDeclaration": null,- "src": "654:12:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- ],- "id": 259,- "name": "blockhash",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 372,- "src": "644:9:1",- "typeDescriptions": {- "typeIdentifier": "t_function_blockhash_view$_t_uint256_$returns$_t_bytes32_$",- "typeString": "function (uint256) view returns (bytes32)"- }- },- "id": 262,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "644:23:1",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_bytes4",- "typeString": "bytes4"- },- {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- ],- "id": 256,- "name": "E4",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 193,- "src": "632:2:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_bytes4_$_t_bytes32_$returns$__$",- "typeString": "function (bytes4,bytes32)"- }- },- "id": 263,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "632:36:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 264,- "nodeType": "EmitStatement",- "src": "627:41:1"- }- ]- },- "documentation": null,- "id": 266,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "e4",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 254,- "nodeType": "ParameterList",- "parameters": [],- "src": "611:2:1"- },- "payable": false,- "returnParameters": {- "id": 255,- "nodeType": "ParameterList",- "parameters": [],- "src": "621:0:1"- },- "scope": 267,- "src": "600:73:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "public"- }- ],- "scope": 268,- "src": "26:649:1"- }- ],- "src": "0:675:1"- },- "compiler": {- "name": "solc",- "version": "0.4.24+commit.e67f0147.Emscripten.clang"- },- "networks": {},- "schemaVersion": "2.0.1",- "updatedAt": "2018-10-17T08:27:57.791Z"-}
@@ -1,506 +0,0 @@-{- "contractName": "Registry",- "abi": [- {- "anonymous": false,- "inputs": [- {- "indexed": true,- "name": "listingHash",- "type": "bytes32"- }- ],- "name": "A",- "type": "event"- },- {- "anonymous": false,- "inputs": [- {- "indexed": true,- "name": "sender",- "type": "address"- },- {- "indexed": false,- "name": "listingHash",- "type": "bytes32"- }- ],- "name": "B",- "type": "event"- },- {- "anonymous": false,- "inputs": [- {- "indexed": false,- "name": "dog",- "type": "address"- },- {- "indexed": false,- "name": "cat",- "type": "bytes32"- }- ],- "name": "C",- "type": "event"- }- ],- "bytecode": "0x6080604052348015600f57600080fd5b50603580601d6000396000f3006080604052600080fd00a165627a7a7230582033480aa8fef567c80a4f8afd205add18d07c6a0f6991c2a4b0c2c20b8220f89b0029",- "deployedBytecode": "0x6080604052600080fd00a165627a7a7230582033480aa8fef567c80a4f8afd205add18d07c6a0f6991c2a4b0c2c20b8220f89b0029",- "sourceMap": "26:163:3:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;26:163:3;;;;;;;",- "deployedSourceMap": "26:163:3:-;;;;;",- "source": "pragma solidity ^0.4.22;\n\ncontract Registry {\n\n\n event A(bytes32 indexed listingHash);\n event B(address indexed sender, bytes32 listingHash);\n event C(address dog, bytes32 cat);\n\n}\n",- "sourcePath": "/home/akru/hsweb3test/contracts/Registry.sol",- "ast": {- "absolutePath": "/home/akru/hsweb3test/contracts/Registry.sol",- "exportedSymbols": {- "Registry": [- 343- ]- },- "id": 344,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 326,- "literals": [- "solidity",- "^",- "0.4",- ".22"- ],- "nodeType": "PragmaDirective",- "src": "0:24:3"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 343,- "linearizedBaseContracts": [- 343- ],- "name": "Registry",- "nodeType": "ContractDefinition",- "nodes": [- {- "anonymous": false,- "documentation": null,- "id": 330,- "name": "A",- "nodeType": "EventDefinition",- "parameters": {- "id": 329,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 328,- "indexed": true,- "name": "listingHash",- "nodeType": "VariableDeclaration",- "scope": 330,- "src": "60:27:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 327,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "60:7:3",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "59:29:3"- },- "src": "52:37:3"- },- {- "anonymous": false,- "documentation": null,- "id": 336,- "name": "B",- "nodeType": "EventDefinition",- "parameters": {- "id": 335,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 332,- "indexed": true,- "name": "sender",- "nodeType": "VariableDeclaration",- "scope": 336,- "src": "102:22:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 331,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "102:7:3",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 334,- "indexed": false,- "name": "listingHash",- "nodeType": "VariableDeclaration",- "scope": 336,- "src": "126:19:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 333,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "126:7:3",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "101:45:3"- },- "src": "94:53:3"- },- {- "anonymous": false,- "documentation": null,- "id": 342,- "name": "C",- "nodeType": "EventDefinition",- "parameters": {- "id": 341,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 338,- "indexed": false,- "name": "dog",- "nodeType": "VariableDeclaration",- "scope": 342,- "src": "160:11:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 337,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "160:7:3",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 340,- "indexed": false,- "name": "cat",- "nodeType": "VariableDeclaration",- "scope": 342,- "src": "173:11:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 339,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "173:7:3",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "159:26:3"- },- "src": "152:34:3"- }- ],- "scope": 344,- "src": "26:163:3"- }- ],- "src": "0:190:3"- },- "legacyAST": {- "absolutePath": "/home/akru/hsweb3test/contracts/Registry.sol",- "exportedSymbols": {- "Registry": [- 343- ]- },- "id": 344,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 326,- "literals": [- "solidity",- "^",- "0.4",- ".22"- ],- "nodeType": "PragmaDirective",- "src": "0:24:3"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 343,- "linearizedBaseContracts": [- 343- ],- "name": "Registry",- "nodeType": "ContractDefinition",- "nodes": [- {- "anonymous": false,- "documentation": null,- "id": 330,- "name": "A",- "nodeType": "EventDefinition",- "parameters": {- "id": 329,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 328,- "indexed": true,- "name": "listingHash",- "nodeType": "VariableDeclaration",- "scope": 330,- "src": "60:27:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 327,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "60:7:3",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "59:29:3"- },- "src": "52:37:3"- },- {- "anonymous": false,- "documentation": null,- "id": 336,- "name": "B",- "nodeType": "EventDefinition",- "parameters": {- "id": 335,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 332,- "indexed": true,- "name": "sender",- "nodeType": "VariableDeclaration",- "scope": 336,- "src": "102:22:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 331,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "102:7:3",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 334,- "indexed": false,- "name": "listingHash",- "nodeType": "VariableDeclaration",- "scope": 336,- "src": "126:19:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 333,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "126:7:3",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "101:45:3"- },- "src": "94:53:3"- },- {- "anonymous": false,- "documentation": null,- "id": 342,- "name": "C",- "nodeType": "EventDefinition",- "parameters": {- "id": 341,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 338,- "indexed": false,- "name": "dog",- "nodeType": "VariableDeclaration",- "scope": 342,- "src": "160:11:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- },- "typeName": {- "id": 337,- "name": "address",- "nodeType": "ElementaryTypeName",- "src": "160:7:3",- "typeDescriptions": {- "typeIdentifier": "t_address",- "typeString": "address"- }- },- "value": null,- "visibility": "internal"- },- {- "constant": false,- "id": 340,- "indexed": false,- "name": "cat",- "nodeType": "VariableDeclaration",- "scope": 342,- "src": "173:11:3",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- },- "typeName": {- "id": 339,- "name": "bytes32",- "nodeType": "ElementaryTypeName",- "src": "173:7:3",- "typeDescriptions": {- "typeIdentifier": "t_bytes32",- "typeString": "bytes32"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "159:26:3"- },- "src": "152:34:3"- }- ],- "scope": 344,- "src": "26:163:3"- }- ],- "src": "0:190:3"- },- "compiler": {- "name": "solc",- "version": "0.4.24+commit.e67f0147.Emscripten.clang"- },- "networks": {},- "schemaVersion": "2.0.1",- "updatedAt": "2018-10-17T08:27:57.792Z"-}
@@ -1,600 +0,0 @@-{- "contractName": "SimpleStorage",- "abi": [- {- "constant": true,- "inputs": [],- "name": "count",- "outputs": [- {- "name": "",- "type": "uint256"- }- ],- "payable": false,- "stateMutability": "view",- "type": "function"- },- {- "anonymous": false,- "inputs": [- {- "indexed": false,- "name": "_count",- "type": "uint256"- }- ],- "name": "_CountSet",- "type": "event"- },- {- "constant": false,- "inputs": [- {- "name": "_count",- "type": "uint256"- }- ],- "name": "setCount",- "outputs": [],- "payable": false,- "stateMutability": "nonpayable",- "type": "function"- }- ],- "bytecode": "0x608060405234801561001057600080fd5b50610113806100206000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306661abd14604e578063d14e62b8146076575b600080fd5b348015605957600080fd5b50606060a0565b6040518082815260200191505060405180910390f35b348015608157600080fd5b50609e6004803603810190808035906020019092919050505060a6565b005b60005481565b806000819055507f23420683cdbc4b73b0779e0325c497f5b72b3e8a92f3882a5a754c1b9eb734ec816040518082815260200191505060405180910390a1505600a165627a7a72305820a2e06ca2fff9366521c668d197df2b9e7164abd3974f3b0d54e6690ca00798400029",- "deployedBytecode": "0x6080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306661abd14604e578063d14e62b8146076575b600080fd5b348015605957600080fd5b50606060a0565b6040518082815260200191505060405180910390f35b348015608157600080fd5b50609e6004803603810190808035906020019092919050505060a6565b005b60005481565b806000819055507f23420683cdbc4b73b0779e0325c497f5b72b3e8a92f3882a5a754c1b9eb734ec816040518082815260200191505060405180910390a1505600a165627a7a72305820a2e06ca2fff9366521c668d197df2b9e7164abd3974f3b0d54e6690ca00798400029",- "sourceMap": "26:201:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;26:201:1;;;;;;;",- "deployedSourceMap": "26:201:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;55:17;;8:9:-1;5:2;;;30:1;27;20:12;5:2;55:17:1;;;;;;;;;;;;;;;;;;;;;;;122:103;;8:9:-1;5:2;;;30:1;27;20:12;5:2;122:103:1;;;;;;;;;;;;;;;;;;;;;;;;;;55:17;;;;:::o;122:103::-;180:6;172:5;:14;;;;201:17;211:6;201:17;;;;;;;;;;;;;;;;;;122:103;:::o",- "source": "pragma solidity ^0.4.15;\n\ncontract SimpleStorage {\n uint public count;\n \n event _CountSet(uint _count);\n \n function setCount(uint _count) external {\n count = _count;\n emit _CountSet(_count);\n }\n}\n",- "sourcePath": "/home/akru/hsweb3test/contracts/SimpleStorage.sol",- "ast": {- "absolutePath": "/home/akru/hsweb3test/contracts/SimpleStorage.sol",- "exportedSymbols": {- "SimpleStorage": [- 190- ]- },- "id": 191,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 169,- "literals": [- "solidity",- "^",- "0.4",- ".15"- ],- "nodeType": "PragmaDirective",- "src": "0:24:1"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 190,- "linearizedBaseContracts": [- 190- ],- "name": "SimpleStorage",- "nodeType": "ContractDefinition",- "nodes": [- {- "constant": false,- "id": 171,- "name": "count",- "nodeType": "VariableDeclaration",- "scope": 190,- "src": "55:17:1",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 170,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "55:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "public"- },- {- "anonymous": false,- "documentation": null,- "id": 175,- "name": "_CountSet",- "nodeType": "EventDefinition",- "parameters": {- "id": 174,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 173,- "indexed": false,- "name": "_count",- "nodeType": "VariableDeclaration",- "scope": 175,- "src": "99:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 172,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "99:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "98:13:1"- },- "src": "83:29:1"- },- {- "body": {- "id": 188,- "nodeType": "Block",- "src": "162:63:1",- "statements": [- {- "expression": {- "argumentTypes": null,- "id": 182,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 180,- "name": "count",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 171,- "src": "172:5:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 181,- "name": "_count",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 177,- "src": "180:6:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "src": "172:14:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "id": 183,- "nodeType": "ExpressionStatement",- "src": "172:14:1"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "id": 185,- "name": "_count",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 177,- "src": "211:6:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- ],- "id": 184,- "name": "_CountSet",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "201:9:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$",- "typeString": "function (uint256)"- }- },- "id": 186,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "201:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 187,- "nodeType": "EmitStatement",- "src": "196:22:1"- }- ]- },- "documentation": null,- "id": 189,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "setCount",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 178,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 177,- "name": "_count",- "nodeType": "VariableDeclaration",- "scope": 189,- "src": "140:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 176,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "140:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "139:13:1"- },- "payable": false,- "returnParameters": {- "id": 179,- "nodeType": "ParameterList",- "parameters": [],- "src": "162:0:1"- },- "scope": 190,- "src": "122:103:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "external"- }- ],- "scope": 191,- "src": "26:201:1"- }- ],- "src": "0:228:1"- },- "legacyAST": {- "absolutePath": "/home/akru/hsweb3test/contracts/SimpleStorage.sol",- "exportedSymbols": {- "SimpleStorage": [- 190- ]- },- "id": 191,- "nodeType": "SourceUnit",- "nodes": [- {- "id": 169,- "literals": [- "solidity",- "^",- "0.4",- ".15"- ],- "nodeType": "PragmaDirective",- "src": "0:24:1"- },- {- "baseContracts": [],- "contractDependencies": [],- "contractKind": "contract",- "documentation": null,- "fullyImplemented": true,- "id": 190,- "linearizedBaseContracts": [- 190- ],- "name": "SimpleStorage",- "nodeType": "ContractDefinition",- "nodes": [- {- "constant": false,- "id": 171,- "name": "count",- "nodeType": "VariableDeclaration",- "scope": 190,- "src": "55:17:1",- "stateVariable": true,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 170,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "55:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "public"- },- {- "anonymous": false,- "documentation": null,- "id": 175,- "name": "_CountSet",- "nodeType": "EventDefinition",- "parameters": {- "id": 174,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 173,- "indexed": false,- "name": "_count",- "nodeType": "VariableDeclaration",- "scope": 175,- "src": "99:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 172,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "99:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "98:13:1"- },- "src": "83:29:1"- },- {- "body": {- "id": 188,- "nodeType": "Block",- "src": "162:63:1",- "statements": [- {- "expression": {- "argumentTypes": null,- "id": 182,- "isConstant": false,- "isLValue": false,- "isPure": false,- "lValueRequested": false,- "leftHandSide": {- "argumentTypes": null,- "id": 180,- "name": "count",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 171,- "src": "172:5:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "nodeType": "Assignment",- "operator": "=",- "rightHandSide": {- "argumentTypes": null,- "id": 181,- "name": "_count",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 177,- "src": "180:6:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "src": "172:14:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "id": 183,- "nodeType": "ExpressionStatement",- "src": "172:14:1"- },- {- "eventCall": {- "argumentTypes": null,- "arguments": [- {- "argumentTypes": null,- "id": 185,- "name": "_count",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 177,- "src": "211:6:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- }- ],- "expression": {- "argumentTypes": [- {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- ],- "id": 184,- "name": "_CountSet",- "nodeType": "Identifier",- "overloadedDeclarations": [],- "referencedDeclaration": 175,- "src": "201:9:1",- "typeDescriptions": {- "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$",- "typeString": "function (uint256)"- }- },- "id": 186,- "isConstant": false,- "isLValue": false,- "isPure": false,- "kind": "functionCall",- "lValueRequested": false,- "names": [],- "nodeType": "FunctionCall",- "src": "201:17:1",- "typeDescriptions": {- "typeIdentifier": "t_tuple$__$",- "typeString": "tuple()"- }- },- "id": 187,- "nodeType": "EmitStatement",- "src": "196:22:1"- }- ]- },- "documentation": null,- "id": 189,- "implemented": true,- "isConstructor": false,- "isDeclaredConst": false,- "modifiers": [],- "name": "setCount",- "nodeType": "FunctionDefinition",- "parameters": {- "id": 178,- "nodeType": "ParameterList",- "parameters": [- {- "constant": false,- "id": 177,- "name": "_count",- "nodeType": "VariableDeclaration",- "scope": 189,- "src": "140:11:1",- "stateVariable": false,- "storageLocation": "default",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- },- "typeName": {- "id": 176,- "name": "uint",- "nodeType": "ElementaryTypeName",- "src": "140:4:1",- "typeDescriptions": {- "typeIdentifier": "t_uint256",- "typeString": "uint256"- }- },- "value": null,- "visibility": "internal"- }- ],- "src": "139:13:1"- },- "payable": false,- "returnParameters": {- "id": 179,- "nodeType": "ParameterList",- "parameters": [],- "src": "162:0:1"- },- "scope": 190,- "src": "122:103:1",- "stateMutability": "nonpayable",- "superFunction": null,- "visibility": "external"- }- ],- "scope": 191,- "src": "26:201:1"- }- ],- "src": "0:228:1"- },- "compiler": {- "name": "solc",- "version": "0.4.24+commit.e67f0147.Emscripten.clang"- },- "networks": {},- "schemaVersion": "2.0.1",- "updatedAt": "2018-10-17T08:28:45.992Z"-}
@@ -1,254 +0,0 @@-{-# LANGUAGE DeriveAnyClass #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}---- |--- Module : Codec.Scale.Test.CoreSpec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ported to Haskell rust test spec:--- https://github.com/paritytech/parity-scale-codec/blob/master/tests/single_field_struct_encoding.rs-----module Codec.Scale.Test.CoreSpec where--import Control.Monad (forM_)-import Data.Bit (castFromWords8)-import Data.Bits (bit)-import Data.ByteString (ByteString)-import qualified Data.ByteString as BS (length, unpack)-import Data.Int (Int16, Int32, Int64, Int8)-import Data.Vector.Unboxed (Vector)-import qualified Data.Vector.Unboxed as V (fromList)-import Data.Word (Word16, Word32, Word64, Word8)-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)-import Test.Hspec-import Test.Hspec.QuickCheck--import Codec.Scale--data Unit = Unit- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--data Indexed = Indexed Word32 Word64- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--data Struct a b c = Struct- { _a :: a- , _b :: b- , _c :: c- }- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--data StructWithPhantom a = StructWithPhantom- { a1 :: Word32- , b1 :: Word64- }- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--type TestType = Struct Word32 Word64 (Vector Word8);--data EnumType = A- | B Word32 Word64- | C- { a2 :: Word32- , b2 :: Word64- }- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--data TestHasCompact a = TestHasCompact- { bar1 :: Compact a- }- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--data TestHasCompactEnum a = Unnamed (Compact a)- | Named- { bar2 :: Compact a- }- | UnnamedCompact (Compact a)- | NamedCompact- { bar3 :: Compact a- }- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--data TestGenericEnum = UnnamedGenericEnum (Compact Integer) (Vector Word16)- | NamedGenericEnum- { bar5 :: Compact Word64- , bar6 :: Word32- }- deriving (Eq, Show, GHC.Generic, Generic)--data RecursiveVariant1 a = RecursiveVariant1- { payload1 :: a- , other1 :: [RecursiveVariant1 a]- }- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--data RecursiveVariant2 a b n = RecursiveVariant2- { payload2 :: n- , other2 :: [Struct a b (RecursiveVariant1 n)]- }- deriving (Eq, Show, GHC.Generic, Generic, Encode, Decode)--spec :: Spec-spec = parallel $ do- describe "Regular types" $ do- prop "Bool" $ \(v :: Bool) -> decode (encode v :: ByteString) == Right v-- prop "Option<Bool>" $ \(v :: Maybe Bool) -> decode (encode v :: ByteString) == Right v-- prop "Result<Bool, Vector<u8>>" $ \v vec -> do- let success = Right v :: Either (Vector Word8) Bool- failure = Left (V.fromList vec) :: Either (Vector Word8) Bool- decode (encode success :: ByteString) == Right success- && decode (encode failure :: ByteString) == Right failure-- prop "u64" $ \(v :: Word64) -> decode (encode v :: ByteString) == Right v- prop "u32" $ \(v :: Word32) -> decode (encode v :: ByteString) == Right v- prop "u16" $ \(v :: Word16) -> decode (encode v :: ByteString) == Right v- prop "u8" $ \(v :: Word8) -> decode (encode v :: ByteString) == Right v-- prop "i64" $ \(v :: Int64) -> decode (encode v :: ByteString) == Right v- prop "i32" $ \(v :: Int32) -> decode (encode v :: ByteString) == Right v- prop "i16" $ \(v :: Int16) -> decode (encode v :: ByteString) == Right v- prop "i8" $ \(v :: Int8) -> decode (encode v :: ByteString) == Right v-- prop "Compact<integer>" $ \(v :: Integer) -> decode (encode (Compact $ abs v) :: ByteString) == Right (Compact $ abs v)- prop "Compact<u64>" $ \(v :: Word64) -> decode (encode (Compact v) :: ByteString) == Right (Compact v)- prop "Compact<u32>" $ \(v :: Word32) -> decode (encode (Compact v) :: ByteString) == Right (Compact v)- prop "Compact<u16>" $ \(v :: Word16) -> decode (encode (Compact v) :: ByteString) == Right (Compact v)- prop "Compact<u8>" $ \(v :: Word8) -> decode (encode (Compact v) :: ByteString) == Right (Compact v)-- prop "Vector<u64>" $ \(v :: [Word64]) -> decode (encode (V.fromList v) :: ByteString) == Right v- prop "Vector<u32>" $ \(v :: [Word32]) -> decode (encode (V.fromList v) :: ByteString) == Right v- prop "Vector<u16>" $ \(v :: [Word16]) -> decode (encode (V.fromList v) :: ByteString) == Right v- prop "Vector<u8>" $ \(v :: [Word8]) -> decode (encode (V.fromList v) :: ByteString) == Right v-- prop "BitVec" $ \(v :: [Word8]) -> decode (encode $ castFromWords8 $ V.fromList v :: ByteString) == Right v-- prop "List<u64>" $ \(v :: [Word64]) -> decode (encode v :: ByteString) == Right v- prop "List<u32>" $ \(v :: [Word32]) -> decode (encode v :: ByteString) == Right v- prop "List<u16>" $ \(v :: [Word16]) -> decode (encode v :: ByteString) == Right v- prop "List<u8>" $ \(v :: [Word8]) -> decode (encode v :: ByteString) == Right v-- describe "Generic types" $ do- prop "unamed_enum" $ \v vec ->- let e = UnnamedGenericEnum (Compact $ abs v) (V.fromList vec)- in decode' (encode' e :: ByteString) == Right e- prop "named_struct_enum" $ \a b ->- let e = NamedGenericEnum (Compact a) b- in decode' (encode' e :: ByteString) == Right e-- describe "Recursive types" $ do- prop "variant_1" $ \(n :: Word32) ->- let v = RecursiveVariant1 n [RecursiveVariant1 (n+1) []]- in decode (encode v :: ByteString) == Right v-- prop "variant_2" $ \(a :: Word8) (b :: Word16) (n :: Word32) ->- let v = RecursiveVariant2 n [Struct a b (RecursiveVariant1 (n+1) [])]- in decode (encode v :: ByteString) == Right v-- describe "SCALE Rust core tests" $ do- it "option_excheption_works" $ do- encode (Nothing :: Maybe Bool) `shouldBe` ("\0" :: ByteString)- encode (Just False) `shouldBe` ("\x01" :: ByteString)- encode (Just True) `shouldBe` ("\x02" :: ByteString)-- it "should_work_for_simple_enum" $ do- -- Index modificator isn't support yet, skip codec test for A- let sb = B 1 2- sc = C 1 2- encoded_b = "\x01\x01\0\0\0\x02\0\0\0\0\0\0\0" :: ByteString- encoded_c = "\x02\x01\0\0\0\x02\0\0\0\0\0\0\0" :: ByteString-- encode sc `shouldBe` encoded_c- encode sb `shouldBe` encoded_b-- decode encoded_b `shouldBe` Right sb- decode encoded_c `shouldBe` Right sc- decode ("\x0a" :: ByteString) `shouldBe` (Left "Failed reading: wrong prefix during enum decoding\nEmpty call stack\n" :: Either String EnumType)-- it "should_derive_encode" $ do- let v :: TestType- v = Struct 15 9 (V.fromList $ BS.unpack "Hello world")- v_encoded :: ByteString- v_encoded = "\x0f\0\0\0\x09\0\0\0\0\0\0\0\x2cHello world"- encode v `shouldBe` v_encoded- Right v `shouldBe` decode v_encoded-- it "should_work_for_unit" $ do- encode Unit `shouldBe` ("" :: ByteString)- decode ("" :: ByteString) `shouldBe` Right Unit-- it "should_work_for_indexed" $ do- let v = Indexed 1 2- v_encoded :: ByteString- v_encoded = "\x01\0\0\0\x02\0\0\0\0\0\0\0"- encode v `shouldBe` v_encoded- Right v `shouldBe` decode v_encoded-- it "correct_error_for_indexed_0" $ do- let wrong = "\x08" :: ByteString- decode wrong `shouldBe` (Left "too few bytes\nFrom:\tdemandInput\n\n" :: Either String Indexed)-- it "correct_error_for_indexed_1" $ do- let wrong = "\0\0\0\0\x01" :: ByteString- decode wrong `shouldBe` (Left "too few bytes\nFrom:\tdemandInput\n\n" :: Either String Indexed)-- it "correct_error_for_enumtype" $ do- let wrong = "\x01" :: ByteString- decode wrong `shouldBe` (Left "too few bytes\nFrom:\tdemandInput\n\n" :: Either String EnumType)-- it "correct_error_for_named_struct_1" $ do- let wrong = "\x01" :: ByteString- decode wrong `shouldBe` (Left "too few bytes\nFrom:\tdemandInput\n\n" :: Either String TestType)-- it "correct_error_for_named_struct_2" $ do- let wrong = "\0\0\0\0\x01" :: ByteString- decode wrong `shouldBe` (Left "too few bytes\nFrom:\tdemandInput\n\n" :: Either String TestType)-- let u64_TEST_COMPACT_VALUES :: [(Word64, Int)]- u64_TEST_COMPACT_VALUES =- [ (0, 1), (63, 1), (64, 2), (16383, 2)- , (16384, 4), (1073741823, 4), (1073741824, 5)- , (bit 32 - 1, 5), (bit 32, 6), (bit 40, 7)- , (bit 48, 8), (bit 56 - 1, 8), (bit 56, 9)- , (maxBound, 9)- ]-- it "compact_works" $ forM_ u64_TEST_COMPACT_VALUES $ \(n, l) -> do- let encoded = encode (TestHasCompact $ Compact n)- BS.length encoded `shouldBe` l- decode encoded `shouldBe` Right (Compact n)-- let u64_TEST_COMPACT_VALUES_FOR_ENUM :: [(Word64, Int)]- u64_TEST_COMPACT_VALUES_FOR_ENUM =- [ (0, 2), (63, 2), (64, 3), (16383, 3), (16384, 5)- , (1073741823, 5), (1073741824, 6), (bit 32 - 1, 6)- , (bit 32, 7), (bit 40, 8), (bit 48, 9), (bit 56 - 1, 9)- , (bit 56, 10), (maxBound, 10)- ]-- it "enum_compact_works" $ forM_ u64_TEST_COMPACT_VALUES_FOR_ENUM $ \(x, l) -> do- let u = encode $ Unnamed (Compact x)- BS.length u `shouldBe` l- decode u `shouldBe` Right (Unnamed $ Compact x)-- let n = encode $ Named (Compact x)- BS.length n `shouldBe` l- decode n `shouldBe` Right (Named $ Compact x)-- let uc = encode $ UnnamedCompact (Compact x)- BS.length uc `shouldBe` l- decode uc `shouldBe` Right (UnnamedCompact $ Compact x)-- let nc = encode $ NamedCompact (Compact x)- BS.length nc `shouldBe` l- decode nc `shouldBe` Right (NamedCompact $ Compact x)
@@ -1,106 +0,0 @@-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Codec.Scale.Test.SingleFieldStructSpec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ported to Haskell rust test spec:--- https://github.com/paritytech/parity-scale-codec/blob/master/tests/single_field_struct_encoding.rs-----module Codec.Scale.Test.SingleFieldStructSpec where--import Data.ByteString as BS (pack)-import Data.Default (def)-import Data.Word (Word32, Word64)-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)-import Test.Hspec--import Codec.Scale-import Codec.Scale.Skip--newtype S = S { x1 :: Word32 }- deriving (Eq, Ord, Show, Encode, Decode)--data SSkip = SSkip- { s1 :: Skip Word32- , x2 :: Word32- , s2 :: Skip Word32- }- deriving (Eq, Ord, Show, GHC.Generic)--instance Generic SSkip-instance Encode SSkip-instance Decode SSkip--newtype Sc = Sc { x3 :: Compact Word32 }- deriving (Eq, Ord, Show, Encode, Decode)--newtype U = U Word32- deriving (Eq, Ord, Show, Enum, Num, Real, Integral, Encode, Decode)--newtype U2 = U2 { a :: Word64 }- deriving (Eq, Ord, Show, Encode, Decode)--data USkip = USkip (Skip Word32) Word32 (Skip Word32)- deriving (Eq, Ord, Show, GHC.Generic)--instance Generic USkip-instance Encode USkip-instance Decode USkip--newtype Uc = Uc (Compact Word32)- deriving (Eq, Ord, Show, Encode, Decode)--newtype Ucas = Ucas (Compact U)- deriving (Eq, Ord, Show, Encode, Decode)--spec :: Spec-spec = parallel $ do- describe "Single field struct encoding" $ do- let x = 3- s = S x- s_skip = SSkip def x def- sc = Sc (Compact x)- u = U x- u_skip = USkip def x def- uc = Uc (Compact x)- ucom = Compact u- ucas = Ucas (Compact u)-- s_encoded = BS.pack [3, 0, 0, 0]- s_skip_encoded = BS.pack [3, 0, 0, 0]- sc_encoded = BS.pack [12]- u_encoded = BS.pack [3, 0, 0, 0]- u_skip_encoded = BS.pack [3, 0, 0, 0]- uc_encoded = BS.pack [12]- ucom_encoded = BS.pack [12]- ucas_encoded = BS.pack [12]-- it "encoding" $ do- encode s `shouldBe` s_encoded- encode s_skip `shouldBe` s_skip_encoded- encode sc `shouldBe` sc_encoded- encode u `shouldBe` u_encoded- encode u_skip `shouldBe` u_skip_encoded- encode uc `shouldBe` uc_encoded- encode ucom `shouldBe` ucom_encoded- encode ucas `shouldBe` ucas_encoded-- it "decoding" $ do- Right s `shouldBe` decode s_encoded- Right s_skip `shouldBe` decode s_skip_encoded- Right sc `shouldBe` decode sc_encoded- Right u `shouldBe` decode u_encoded- Right u_skip `shouldBe` decode u_skip_encoded- Right uc `shouldBe` decode uc_encoded- Right ucom `shouldBe` decode ucom_encoded- Right ucas `shouldBe` decode ucas_encoded
@@ -1,81 +0,0 @@-{-# LANGUAGE DeriveAnyClass #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Codec.Scale.Test.SkipSpec--- Copyright : Alexander Krupenkin 2016--- License : BSD3------ Maintainer : mail@akru.me--- Stability : experimental--- Portability : unportable------ Ported to Haskell rust test spec:--- https://github.com/paritytech/parity-scale-codec/blob/master/tests/skip.rs-----module Codec.Scale.Test.SkipSpec where--import Data.Default (Default)-import Data.Word (Word32)-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)-import Test.Hspec--import Codec.Scale-import Codec.Scale.SingletonEnum-import Codec.Scale.Skip-import Data.ByteArray.HexString--data UncodecType = UncodecType- deriving (Eq, Ord, Show, GHC.Generic, Default)---- Implementing A constructor is impossible-data EnumType = B- { _b1 :: Skip UncodecType- , b2 :: Word32- }- | C (Skip UncodecType) Word32- deriving (Eq, Ord, Show, GHC.Generic, Generic, Encode, Decode)---data StructNamed = StructNamed- { a :: Skip UncodecType- , b :: Word32- }- deriving (Eq, Ord, Show, GHC.Generic, Generic, Encode, Decode)--data StructUnnamed = StructUnnamed (Skip UncodecType) Word32- deriving (Eq, Ord, Show, GHC.Generic, Generic, Encode, Decode)--data NamedStruct = NamedStruct- { some_named :: Word32- , ignore :: Skip (Maybe Word32)- }- deriving (Eq, Ord, Show, GHC.Generic, Generic, Encode, Decode)--spec :: Spec-spec = parallel $ do- describe "Type encoding modificators" $ do- it "enum_struct_test" $ do- let eb = B { _b1 = Skip UncodecType, b2 = 1 }- ec = C (Skip UncodecType) 1- sn = StructNamed { a = Skip UncodecType, b = 1 }- su = StructUnnamed (Skip UncodecType) 1-- let eb_encoded = encode eb :: HexString- let ec_encoded = encode ec :: HexString- let sn_encoded = encode sn :: HexString- let su_encoded = encode su :: HexString-- decode eb_encoded `shouldBe` Right eb- decode ec_encoded `shouldBe` Right ec- decode sn_encoded `shouldBe` Right sn- decode su_encoded `shouldBe` Right su-- it "skip_enum_struct_inner_variant" $ do- let struct = NamedStruct { some_named = 1, ignore = Skip (Just 1) }- single = SingletonEnum struct- encoded = "0x0001000000" :: HexString- encode single `shouldBe` encoded
@@ -1,99 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Crypto.Ethereum.Test.KeyfileSpec where--import Data.Aeson (eitherDecode)-import Data.ByteString (ByteString)-import qualified Data.ByteString.Lazy as L (ByteString)-import Data.UUID.Types (UUID)-import Test.Hspec--import Crypto.Ethereum.Keyfile-import Data.ByteArray.HexString (HexString)--pbkdf2_test_keyfile :: L.ByteString-pbkdf2_test_keyfile = "\-\{\-\ \"crypto\" : {\-\ \"cipher\" : \"aes-128-ctr\",\-\ \"cipherparams\" : {\-\ \"iv\" : \"6087dab2f9fdbbfaddc31a909735c1e6\"\-\ },\-\ \"ciphertext\" : \"5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46\",\-\ \"kdf\" : \"pbkdf2\",\-\ \"kdfparams\" : {\-\ \"c\" : 262144,\-\ \"dklen\" : 32,\-\ \"prf\" : \"hmac-sha256\",\-\ \"salt\" : \"ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd\"\-\ },\-\ \"mac\" : \"517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2\"\-\ },\-\ \"id\" : \"3198bc9c-6672-5ab3-d995-4942343ae5b6\",\-\ \"version\" : 3\-\}"--scrypt_test_keyfile :: L.ByteString-scrypt_test_keyfile = "\-\{\-\ \"crypto\" : {\-\ \"cipher\" : \"aes-128-ctr\",\-\ \"cipherparams\" : {\-\ \"iv\" : \"83dbcc02d8ccb40e466191a123791e0e\"\-\ },\-\ \"ciphertext\" : \"d172bf743a674da9cdad04534d56926ef8358534d458fffccd4e6ad2fbde479c\",\-\ \"kdf\" : \"scrypt\",\-\ \"kdfparams\" : {\-\ \"dklen\" : 32,\-\ \"n\" : 262144,\-\ \"r\" : 1,\-\ \"p\" : 8,\-\ \"salt\" : \"ab0c7876052600dd703518d6fc3fe8984592145b591fc8fb5c6d43190334ba19\"\-\ },\-\ \"mac\" : \"2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097\"\-\ },\-\ \"id\" : \"3198bc9c-6672-5ab3-d995-4942343ae5b6\",\-\ \"version\" : 3\-\}"--test_uuid :: UUID-test_uuid = read "3198bc9c-6672-5ab3-d995-4942343ae5b6"--test_pbkdf2_mac :: HexString-test_pbkdf2_mac = "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2"--test_scrypt_mac :: HexString-test_scrypt_mac = "2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097"--test_password :: ByteString-test_password = "testpassword"--test_private :: HexString-test_private = "7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d"--spec :: Spec-spec = do- describe "AES-128-CTR and PBKDF2-SHA-256" $ do- it "can decode keyfile" $- case eitherDecode pbkdf2_test_keyfile of- Left e -> error e- Right ekey -> do- encryptedKeyId ekey `shouldBe` test_uuid- encryptedKeyMac ekey `shouldBe` test_pbkdf2_mac-- it "can decrypt keyfile" $ do- case eitherDecode pbkdf2_test_keyfile of- Left e -> error e- Right ekey -> decrypt ekey test_password `shouldBe` Just test_private-- describe "AES-128-CTR and Scrypt" $ do- it "can decode keyfile" $- case eitherDecode scrypt_test_keyfile of- Left e -> error e- Right ekey -> do- encryptedKeyId ekey `shouldBe` test_uuid- encryptedKeyMac ekey `shouldBe` test_scrypt_mac-- it "can decrypt keyfile" $- case eitherDecode scrypt_test_keyfile of- Left e -> error e- Right ekey -> decrypt ekey test_password `shouldBe` Just test_private
@@ -1,65 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Crypto.Ethereum.Test.SignatureSpec where--import Data.ByteArray (convert)-import Data.Foldable (for_)-import Test.Hspec-import Test.Hspec.QuickCheck--import Crypto.Ecdsa.Utils (importKey)-import Crypto.Ethereum.Signature (hashMessage, signMessage,- signTransaction)-import Data.ByteArray.HexString (HexString)-import Data.Solidity.Prim.Address (fromPubKey)-import Network.Ethereum.Api.Types (Call (..))-import Network.Ethereum.Transaction (encodeTransaction)--test_vector :: [(HexString, HexString, HexString)]-test_vector = [- ("0xa8510b592963f52d2d8b3413ab5822111c68d45370f6104a869fe6e72c58952fe6b420115a9dfadaae2956ad761db2f113", "0x5cc3704a552b40515909a220d3cb91e850d4d6c6c0180424e433d00400612ed6", "0x3477bfac3621680c30cf3ad59da9288bc53e46773af4911592c6f3b2ba9029861fac19b0fa0cc543731133346eb817cd7f3aa4cabac5e613919567bc9704af861c"),- ("0x5680f1d195bbe2b0f1601a039ad23a6ad488c1f0949a68e84bffe398ad", "0xcaf03f0aa6862758e526dd76782a4afa7ad48533f00f8f9e8731d4a6b1656d9f", "0x659263cb4d54c653e5ef41550f959e15a71b01f19bce88750c8c3cad8ab293d12138db412f471df6c67575d49e9c25b6973a3405396a3e6985a3f391efee74751c"),- ("0x487f9a", "0xa13bf6fdb2e2a5790f4a80d822180c7851b227d16c1893de2359dc98b1e27756", "0x143da940f9e144218979074cfde306d0697b3ddaec4c5e464a5aa093733f957776ba158ec4492a6cdc9951c6e0c1b10040916cb503ad240ed3b76677f9ac4ad41c"),- ("0x958c2c5bafc5eb97004774f4c9b56aaecd37c06befac0042a93c67", "0x496b49cc02b63f927f2669a32dece10876e1a33dc0bd684f7643f849ecbe7c73", "0x34e768e959b89d305f16f796d0ff2da4e5923d6a6f33ba66b29471953e10be1a183743fb764f806ca8d97ad29dad94115d0368f374d5e085348267cc1c5bce411b"),- ("0x02e2", "0x0425c9ac326acac4b93ff871f22c1dfe69c05038c2ac5b9eadb7e09743baa603", "0xbf52108b598a02aeeea1f9ee84947300985953edcfd07351f038bfe0de4c62df5cf467caaa7a33c3c4ebdf4aeaf05b1f4674f6b82b27e87fbf8d2a0980e68f1d1b"),- ("0x74391586ff29f0638d7f7971640cefac3bfa3865ec5310e15a", "0x104432a31597e399f3f0f34e70b52a062feeb65aa3ad5383d2d7b90b0ab50126", "0x78c81fff1acdd1773badea5f35b0149e14b3dffe8de0e554b0edd80526acd55f1fc315b96afe5964df24f28b756f5651a6a52b2b9e0ffc87cda2a4a8f448a8951c"),- ("0xd3ba712ef9dd8f8b37d805a9d1c2b5ee92db66dda0fd8582d55cec1b2519d18dfff2333e29081e80544af7244f2f22", "0x330ee59f080c59252218d1245029d8689b48b021dcf2c438938264bbc61d05af", "0xcf96a0f05e40d05ebcedbff0af522a68e6c846e63b44245a1208592ddf03cc12136ad522656f08fd838c55ff78e093d387d23b30b88a57e467636e63c786e04e1c"),- ("0x1e99da3e7bb02e1f239bbf0b2ea113848673dd52da24c87f2f40", "0x52c58101fe861f9292fb6ad3df74551b5fb3feca9983b108645a5a9354bfbe99", "0x8eebcef599eb67e9379e7d6b074123628c1a65f1b754647704eb003fa61aff0a0e5c79fb022970fea80409e20a12bd4b8e1a79a787394a547fbc93c2d3c1e2dc1c"),- ("0x1e973d1b5b158acc7d710099700c793e702b215a1fa534317d5c44406000fc727c", "0x1280413acfcd88a97b759e72e60069a1dc4f0a595e815aad9a1a83fa73f81af2", "0x7a77a37f2f4378dab5a0ba7f55b858a2a116f885f2eeab30dcd0b6d1f7286fbb7cbdccbd52721ce68fbcf2448a2f450a6bc6bc7f0027906259821bb3800133181b"),- ("0x95da865540bd1336402a325a0435a920768f47d4b1ec0d89e0063f811872d1cb6423b5f4a4b931c9f41b216def", "0x0d537e54120ea923621225e3114b91a568a1abe7b7315b642017cad28cfad40b", "0xe04196529154ab89ceb598654f7d1ae178ecdcf73395aa8e8abb9200b504c39c58a93a6e502aaaddc2cbd712b436e9c9fb1010323927835ac54a7a77f11957f91c")- ]--test_key :: HexString-test_key = "29461542faa1acbc968bcb332115e0537c023f8df416317602ca5d15ca12d02d"--spec :: Spec-spec = do- describe "Ethereum ECDSA" $ do- it "can hash Ethereum prefixed message" $ for_ test_vector $ \(msg, msgHash, _) ->- convert (hashMessage msg) `shouldBe` msgHash-- it "can sign Ethereum prefixed message" $ for_ test_vector $ \(msg, _, msgSig) ->- signMessage (importKey test_key) msg `shouldBe` msgSig-- it "can create valid raw transaction" $ do- -- using same example as in this blog post:- -- https://medium.com/@codetractio/walkthrough-of-an-ethereum-improvement-proposal-eip-6fda3966d171- let testCall = Call Nothing- (Just "0x3535353535353535353535353535353535353535")- (Just 21000)- (Just 20000000000)- (Just 1000000000000000000)- Nothing- (Just 9)- key = "4646464646464646464646464646464646464646464646464646464646464646" :: HexString- correctSignedTx = "f86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83"- signTransaction (encodeTransaction testCall 1) (importKey key) `shouldBe` (correctSignedTx :: HexString)--{-- it "verify message by Ethereum public key" $ do- ecrecover sign' message `shouldBe` Just address-- prop "round robin sign/verify for random message" $ \chars ->- let msg = pack chars- in ecrecover (ecsign key msg) msg `shouldBe` Just address--}-
@@ -1,24 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}--- Inspired by https://github.com/indutny/hmac-drbg-module Crypto.Random.Test.HmacDrbgSpec where--import Crypto.Hash.Algorithms (SHA256)-import Crypto.Random (randomBytesGenerate)-import Data.ByteString (ByteString)-import Test.Hspec--import Crypto.Random.HmacDrbg-import Data.ByteArray.HexString (HexString)--spec :: Spec-spec = do- describe "HMAC-DRBG-SHA256" $ do- it "indutny/hmac-drbg test vectors" $ do- let doDrbg :: ByteString -> HexString- doDrbg seed = fst (randomBytesGenerate 32 (initialize seed) :: (HexString, HmacDrbg SHA256))-- doDrbg "totally random0123456789secret noncemy drbg"- `shouldBe` "018ec5f8e08c41e5ac974eb129ac297c5388ee1864324fa13d9b15cf98d9a157"-- doDrbg "totally random0123456789secret nonce"- `shouldBe` "ed5d61ecf0ef38258e62f03bbb49f19f2cd07ba5145a840d83b134d5963b3633"
@@ -1,63 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Data.Solidity.Test.AddressSpec where--import Data.ByteString (ByteString)-import Data.ByteString.Char8 (unpack)-import Data.Foldable (for_)-import Data.Monoid ((<>))-import Test.Hspec--import Crypto.Ecdsa.Utils (derivePubKey, importKey)-import Data.ByteArray.HexString (HexString)-import Data.Solidity.Prim.Address--spec :: Spec-spec = do- describe "EIP55 Test Vectors" $ for_ checksummedAddrs $ \addr ->- it (unpack addr <> " should be checksummed") $ verifyChecksum addr `shouldBe` True-- describe "EIP55 Test Vectors Tampered" $ for_ unchecksummedAddrs $ \addr ->- it (unpack addr <> " should not be checksummed") $ verifyChecksum addr `shouldBe` False-- describe "Conversion from/to hex string" $ do- it "should convert from/to on valid hex" $ do- fromHexString "0x6370eF2f4Db3611D657b90667De398a2Cc2a370C"- `shouldBe` Right "0x6370eF2f4Db3611D657b90667De398a2Cc2a370C"-- toHexString "0x6370eF2f4Db3611D657b90667De398a2Cc2a370C"- `shouldBe` "0x6370eF2f4Db3611D657b90667De398a2Cc2a370C"-- it "should fail on broken hex" $ do- fromHexString "0x42"- `shouldBe` Left "Incorrect address length: 1"--- describe "Conversion from ECC keys" $ do- it "can derive address from public key" $ do- let key = "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20" :: HexString- fromPubKey (derivePubKey $ importKey key)- `shouldBe` "0x6370eF2f4Db3611D657b90667De398a2Cc2a370C"--checksummedAddrs :: [ByteString]-checksummedAddrs =- [ "0x52908400098527886E0F7030069857D2E4169EE7"- , "0x8617E340B3D01FA5F11F306F4090FD50E238070D"- , "0xde709f2102306220921060314715629080e2fb77"- , "0x27b1fdb04752bbc536007a920d24acb045561c26"- , "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"- , "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"- , "0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB"- , "0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb"- ]--unchecksummedAddrs :: [ByteString]-unchecksummedAddrs =- [ "0x52908400098527886E0F7030069857D2E4169Ee7"- , "0x8617E340B3D01FA5F11F306F4090FD50E238070d"- , "0xde709f2102306220921060314715629080e2fB77"- , "0x27b1fdb04752bbc536007a920d24acb045561C26"- , "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAeD"- , "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5D359"- , "0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6Fb"- , "0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDB"- ]
@@ -1,265 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedLists #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeFamilies #-}--module Data.Solidity.Test.EncodingSpec where--import Control.Exception (evaluate)-import Data.Monoid ((<>))-import Data.Text (Text)-import Data.Tuple.OneTuple (OneTuple (..))-import Generics.SOP (Generic, Rep)-import Test.Hspec--import Data.Solidity.Abi (AbiGet, AbiPut, GenericAbiGet,- GenericAbiPut)-import Data.Solidity.Abi.Codec (decode, decode', encode, encode')-import Data.Solidity.Prim (Address, Bytes, BytesN, IntN,- ListN, UIntN)-import Data.Solidity.Prim.Address (fromHexString, toHexString)--spec :: Spec-spec = do- intNTest- bytesTest- bytesNTest- vectorTest- dynamicArraysTest- tuplesTest- addressTest--intNTest :: Spec-intNTest =- describe "uint tests" $ do-- it "can encode int16" $- let decoded = (-1) :: IntN 16- encoded = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- in roundTrip decoded encoded-- it "can encode larger uint256" $- let decoded = (2 ^ 255) - 1 :: UIntN 256- encoded = "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- in roundTrip decoded encoded--bytesTest :: Spec-bytesTest = do- describe "bytes tests" $ do-- it "can encode empty bytes" $ do- let decoded :: Bytes- decoded = "0x"- encoded = "0x0000000000000000000000000000000000000000000000000000000000000000"- in roundTrip decoded encoded-- it "can encode short bytes" $ do- let decoded :: Bytes- decoded = "0xc3a40000c3a4"- encoded = "0x0000000000000000000000000000000000000000000000000000000000000006"- <> "0xc3a40000c3a40000000000000000000000000000000000000000000000000000"- in roundTrip decoded encoded-- it "can encode long bytes" $ do- let decoded :: Bytes- decoded = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1"- encoded = "0x000000000000000000000000000000000000000000000000000000000000009f"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff100"- in roundTrip decoded encoded--bytesNTest :: Spec-bytesNTest =- describe "sized bytes tests" $ do-- it "can encode Bytes1" $ do- let decoded = "0xcf" :: BytesN 1- encoded = "0xcf00000000000000000000000000000000000000000000000000000000000000"- roundTrip decoded encoded-- it "can encode Bytes12" $ do- let decoded = "0x6761766f66796f726b000000" :: BytesN 12- encoded = "0x6761766f66796f726b0000000000000000000000000000000000000000000000"- roundTrip decoded encoded-- it "can pad shorter hex-literals" $ do- let literal = "0xc3a4" :: BytesN 4- expected = "0xc3a40000" :: BytesN 4- literal `shouldBe` expected-- it "can pad shorter string-literals" $ do- let literal = "hello" :: BytesN 8- expected = "0x68656c6c6f000000" :: BytesN 8- literal `shouldBe` expected-- it "fails on too long literals" $ do- let literal = "hello" :: BytesN 4- evaluate literal `shouldThrow` errorCall "Invalid Size"--vectorTest :: Spec-vectorTest =- describe "statically sized array tests" $ do-- it "can encode statically sized vectors of addresses" $ do- let decoded = [False, True] :: ListN 2 Bool- encoded = "0x0000000000000000000000000000000000000000000000000000000000000000"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- in roundTrip decoded encoded-- it "can encode statically sized vectors of statically sized bytes"$ do- let elem1 = "0xcf"- elem2 = "0x68"- elem3 = "0x4d"- elem4 = "0xfb"- decoded = [elem1, elem2, elem3, elem4] :: ListN 4 (BytesN 1)- encoded = "0xcf00000000000000000000000000000000000000000000000000000000000000"- <> "0x6800000000000000000000000000000000000000000000000000000000000000"- <> "0x4d00000000000000000000000000000000000000000000000000000000000000"- <> "0xfb00000000000000000000000000000000000000000000000000000000000000"- in roundTrip decoded encoded--dynamicArraysTest :: Spec-dynamicArraysTest = do- describe "dynamically sized array tests" $ do-- it "can encode dynamically sized lists of bools" $ do- let decoded = [True, True, False] :: [Bool]- encoded = "0x0000000000000000000000000000000000000000000000000000000000000003"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x0000000000000000000000000000000000000000000000000000000000000000"- in roundTrip decoded encoded--tuplesTest :: Spec-tuplesTest =- describe "tuples test" $ do-- it "can encode 2-tuples with both static args" $ do- let decoded = (True, False)- encoded = "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x0000000000000000000000000000000000000000000000000000000000000000"- in roundTripGeneric decoded encoded-- it "can encode 1-tuples with dynamic arg" $ do- let decoded = OneTuple ([True, False] :: [Bool])- encoded = "0x0000000000000000000000000000000000000000000000000000000000000020"- <> "0x0000000000000000000000000000000000000000000000000000000000000002"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x0000000000000000000000000000000000000000000000000000000000000000"- in roundTripGeneric decoded encoded-- it "can encode 4-tuples with a mix of args - (UInt32, String, Boolean, Array Int256)" $ do- let decoded = (1 :: IntN 32, "dave" :: Text, True, [1, 2, 3] :: [IntN 256])- encoded = "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x0000000000000000000000000000000000000000000000000000000000000080"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x00000000000000000000000000000000000000000000000000000000000000c0"- <> "0x0000000000000000000000000000000000000000000000000000000000000004"- <> "0x6461766500000000000000000000000000000000000000000000000000000000"- <> "0x0000000000000000000000000000000000000000000000000000000000000003"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x0000000000000000000000000000000000000000000000000000000000000002"- <> "0x0000000000000000000000000000000000000000000000000000000000000003"- in roundTripGeneric decoded encoded-- it "can do something really complicated" $ do- let uint = 1 :: UIntN 256- int = (-1) :: IntN 256- bool = True- int224 = 221 :: IntN 224- bools = [True, False] :: ListN 2 Bool- ints = [1, -1, 3] :: [IntN 32]- string = "hello" :: Text- bytes16 = "0x12345678123456781234567812345678" :: BytesN 16- elem1 = "0x1234" :: BytesN 2- bytes2s = [ [elem1, elem1, elem1, elem1]- , [elem1, elem1, elem1, elem1]- ] :: [ListN 4 (BytesN 2)]-- decoded = (uint, int, bool, int224, bools, ints, string, bytes16, bytes2s)-- encoded = "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x00000000000000000000000000000000000000000000000000000000000000dd"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0x0000000000000000000000000000000000000000000000000000000000000000"- <> "0x0000000000000000000000000000000000000000000000000000000000000140"- <> "0x00000000000000000000000000000000000000000000000000000000000001c0"- <> "0x1234567812345678123456781234567800000000000000000000000000000000"- <> "0x0000000000000000000000000000000000000000000000000000000000000200"- <> "0x0000000000000000000000000000000000000000000000000000000000000003"- <> "0x0000000000000000000000000000000000000000000000000000000000000001"- <> "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"- <> "0x0000000000000000000000000000000000000000000000000000000000000003"- <> "0x0000000000000000000000000000000000000000000000000000000000000005"- <> "0x68656c6c6f000000000000000000000000000000000000000000000000000000"- <> "0x0000000000000000000000000000000000000000000000000000000000000002"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"- <> "0x1234000000000000000000000000000000000000000000000000000000000000"-- in roundTripGeneric decoded encoded--addressTest :: Spec-addressTest =- describe "address test" $ do- it "can abi encode address" $ do- let decoded = "0x4af013AfBAdb22D8A88c92D68Fc96B033b9Ebb8a" :: Address- encoded = "0x0000000000000000000000004af013AfBAdb22D8A88c92D68Fc96B033b9Ebb8a"- in roundTrip decoded encoded-- it "can decode address from/to bytestring" $ do- fromHexString "0x4af013AfBAdb22D8A88c92D68Fc96B033b9Ebb8a"- `shouldBe` Right ("0x4af013AfBAdb22D8A88c92D68Fc96B033b9Ebb8a" :: Address)-- toHexString "0x4af013AfBAdb22D8A88c92D68Fc96B033b9Ebb8a"- `shouldBe` "0x4af013afbadb22d8a88c92d68fc96b033b9ebb8a"-- it "fails for invalid address length" $ do- evaluate (fromHexString "0x0")- `shouldThrow` errorCall "base16: input: invalid length"-- fromHexString "0x4af013AfBAdb22D8A88c92D68Fc96B033b9Ebb8a00"- `shouldBe` Left "Incorrect address length: 21"---- | Run encoded/decoded comaration-roundTrip :: ( Show a- , Eq a- , AbiPut a- , AbiGet a- )- => a- -> Bytes- -> IO ()-roundTrip decoded encoded = do- encoded `shouldBe` encode decoded- decode encoded `shouldBe` Right decoded---- | Run generic encoded/decoded comaration-roundTripGeneric :: ( Show a- , Eq a- , Generic a- , Rep a ~ rep- , GenericAbiPut rep- , GenericAbiGet rep- )- => a- -> Bytes- -> IO ()-roundTripGeneric decoded encoded = do- encoded `shouldBe` encode' decoded- decode' encoded `shouldBe` Right decoded
@@ -1,33 +0,0 @@-{-# LANGUAGE DataKinds #-}-module Data.Solidity.Test.IntSpec where--import Test.Hspec--import Data.Solidity.Prim.Int--spec :: Spec-spec = do- describe "Unsigned integer overflow" $ do- it "UIntN 256" $ do- (negate 1 :: UIntN 256) `shouldBe` 115792089237316195423570985008687907853269984665640564039457584007913129639935- (maxBound + 1 :: UIntN 256) `shouldBe` 0-- it "UIntN 128" $ do- (negate 1 :: UIntN 128) `shouldBe` 340282366920938463463374607431768211455- (maxBound + 1 :: UIntN 128) `shouldBe` 0-- it "UIntN 64" $ do- (negate 1 :: UIntN 64) `shouldBe` 18446744073709551615- (maxBound + 1 :: UIntN 64) `shouldBe` 0-- it "UIntN 32" $ do- (negate 1 :: UIntN 32) `shouldBe` 4294967295- (maxBound + 1 :: UIntN 32) `shouldBe` 0-- it "UIntN 16" $ do- (negate 1 :: UIntN 16) `shouldBe` 65535- (maxBound + 1 :: UIntN 16) `shouldBe` 0-- it "UIntN 8" $ do- (negate 1 :: UIntN 8) `shouldBe` 255- (maxBound + 1 :: UIntN 8) `shouldBe` 0
@@ -1,63 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Language.Solidity.Test.AbiSpec where---import Test.Hspec-import Data.Either (isLeft)-import Language.Solidity.Abi---spec :: Spec-spec = do- describe "parseSolidityType" $ - describe "tuple type" $ do- it "can parses a FunctionArg with tuple type" $ do- let maa = FunctionArg "makerAssetAmount" "uint256" Nothing- ma = FunctionArg "makeAddress" "address" Nothing- tupleFA = FunctionArg "order" "tuple" (Just [maa, ma])- eRes = parseSolidityFunctionArgType tupleFA- eRes `shouldBe` Right (SolidityTuple 2 [SolidityUint 256, SolidityAddress])- it "fails to parse a FunctionArg with invalid tuple" $ do- let tupleFA = FunctionArg "order" "tuple" Nothing- eRes = parseSolidityFunctionArgType tupleFA- isLeft eRes `shouldBe` True - describe "signature" $ - it "can generate signature for fillOrder" $ do- let fillOrderDec = buildFillOrderDec- expected = "fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)"- sig = signature fillOrderDec- sig `shouldBe` expected- describe "methodId" $ - it "can generate methodId for fillOrder" $ do- let fillOrderDec = buildFillOrderDec- expected = "0xb4be83d5"- mId = methodId fillOrderDec- mId `shouldBe` expected--buildFillOrderDec :: Declaration-buildFillOrderDec = DFunction "fillOrder" False funInputs' funOutputs'- where- funInputs' = - [ makeTupleFuncArg ("order", "tuple") tupleComponents- , makeBasicFuncArg ("takerAssetFillAmount", "uint256")- , makeBasicFuncArg ("signature", "bytes")- ]- tupleComponents = - [ ("makerAddress", "address") - , ("takerAddress", "address") - , ("feeRecipientAddress", "address") - , ("senderAddress", "address") - , ("makerAssetAmount", "uint256") - , ("takerAssetAmount", "uint256") - , ("makerFee", "uint256") - , ("takerFee", "uint256") - , ("expirationTimeSeconds", "uint256")- , ("salt", "uint256") - , ("makerAssetData", "bytes")- , ("takerAssetData", "bytes")- ]- funOutputs' = Nothing- makeBasicFuncArg (n,t) = - FunctionArg n t Nothing- makeTupleFuncArg (n,t) cmps = - FunctionArg n t (Just $ map makeBasicFuncArg cmps)
@@ -1,32 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE OverloadedLists #-}-{-# LANGUAGE OverloadedStrings #-}--module Language.Solidity.Test.CompilerSpec where--import Test.Hspec--#ifdef SOLIDITY_COMPILER--import Language.Solidity.Compiler--spec :: Spec-spec = describe "solidity compiler" $ do- it "can compile empty contract" $ do- compile (Sources [("A", "contract A {}")] [] True)- `shouldBe` Right [("A", ("[]\n", "6080604052348015600f57600080fd5b50603580601d6000396000f3fe6080604052600080fdfea165627a7a7230582055975a3cf5eb9a652c2154ede405cdb2137a09e47088fb89162c336da0b415c40029"))]-- it "can handle broken contract" $ do- compile (Sources [("Fail", "contract Fail {")] [] True)- `shouldBe` Left "Fail:1:16: Error: Function, variable, struct or modifier declaration expected.\ncontract Fail {\n ^\n"-- it "can compile simple contract" $ do- compile (Sources [("SimpleStorage", "contract SimpleStorage { uint256 public a; function set(uint256 _a) public { a = _a; } }")] [] True)- `shouldBe` Right [("SimpleStorage", ("[\n\t{\n\t\t\"constant\" : true,\n\t\t\"inputs\" : [],\n\t\t\"name\" : \"a\",\n\t\t\"outputs\" : \n\t\t[\n\t\t\t{\n\t\t\t\t\"name\" : \"\",\n\t\t\t\t\"type\" : \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"payable\" : false,\n\t\t\"stateMutability\" : \"view\",\n\t\t\"type\" : \"function\"\n\t},\n\t{\n\t\t\"constant\" : false,\n\t\t\"inputs\" : \n\t\t[\n\t\t\t{\n\t\t\t\t\"name\" : \"_a\",\n\t\t\t\t\"type\" : \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"name\" : \"set\",\n\t\t\"outputs\" : [],\n\t\t\"payable\" : false,\n\t\t\"stateMutability\" : \"nonpayable\",\n\t\t\"type\" : \"function\"\n\t}\n]\n", "608060405234801561001057600080fd5b5060e38061001f6000396000f3fe6080604052600436106043576000357c0100000000000000000000000000000000000000000000000000000000900480630dbe671f14604857806360fe47b1146070575b600080fd5b348015605357600080fd5b50605a60a7565b6040518082815260200191505060405180910390f35b348015607b57600080fd5b5060a560048036036020811015609057600080fd5b810190808035906020019092919050505060ad565b005b60005481565b806000819055505056fea165627a7a7230582077f3d0f8c042c028ca18fb49065c0091b05c6b70dd5aee2b8a4388f7ecaa308f0029"))]--#else--spec :: Spec-spec = describe "solidity compiler is not enabled" $ return ()--#endif
@@ -1,20 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-module Network.Ethereum.Contract.Test.THSpec where--import Network.Ethereum.Contract.TH-import Test.Hspec---- 0x Exchange Contract that includes Tuples taken from:--- https://raw.githubusercontent.com/0xProject/0x-monorepo/%400x/website%400.0.89/packages/contract-artifacts/artifacts/Exchange.json-[abiFrom|test/contracts/Exchange.json|]--spec :: Spec-spec =- describe "quasi-quoter" $- it "can compile contract with tuples" $- True `shouldBe` True
@@ -1,91 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}--module Network.Ethereum.Web3.Test.EventSpec where--import Data.Tagged (Tagged)-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)-import Test.Hspec (Spec, describe, it, shouldBe)--import Data.Solidity.Abi (AbiGet, AbiType (..))-import Data.Solidity.Event (IndexedEvent (..), decodeEvent)-import Data.Solidity.Prim (Address, UIntN)-import Network.Ethereum.Api.Types (Change (..))---spec :: Spec-spec = eventTest--eventTest :: Spec-eventTest =- describe "event tests" $ do-- it "can decode simple storage" $- let change = Change { changeLogIndex = Just "0x2"- , changeTransactionIndex = Just "0x2"- , changeTransactionHash = Just "0xe8cac6af0ceb3cecbcb2a5639361fc9811b1aa753672cf7c7e8b528df53e0e94"- , changeBlockHash = Just "0x0c7e1701858232ac210e3bcc8ab3b33cc6b08025692b22abb39059dc41f6a76e"- , changeBlockNumber = Just 0- , changeAddress = "0x617e5941507aab5d2d8bcb56cb8c6ce2eeb16b21"- , changeData = "0x000000000000000000000000000000000000000000000000000000000000000a"- , changeTopics = ["0xa32bc18230dd172221ac5c4821a5f1f1a831f27b1396d244cdd891c58f132435"]- }- in decodeEvent change `shouldBe` Right (NewCount 10)-- it "can decode erc20" $- let ercchange = Change { changeLogIndex = Just "0x2"- , changeTransactionIndex = Just "0x2"- , changeTransactionHash = Just "0xe8cac6af0ceb3cecbcb2a5639361fc9811b1aa753672cf7c7e8b528df53e0e94"- , changeBlockHash = Just "0x0c7e1701858232ac210e3bcc8ab3b33cc6b08025692b22abb39059dc41f6a76e"- , changeBlockNumber = Just 0- , changeAddress = "0x617e5941507aab5d2d8bcb56cb8c6ce2eeb16b21"- , changeData = "0x000000000000000000000000000000000000000000000000000000000000000a"- , changeTopics = [ "0xb32bc18230dd172221ac5c4821a5f1f1a831f27b1396d244cdd891c58f132435"- , "0x0000000000000000000000000000000000000000000000000000000000000001"- , "0x0000000000000000000000000000000000000000000000000000000000000002"- ]- }- in decodeEvent ercchange `shouldBe` Right (Transfer "0x0000000000000000000000000000000000000001" 10 "0x0000000000000000000000000000000000000002")---- SimpleStorage Event Types--data NewCount = NewCount (UIntN 256) deriving (Eq, Show, GHC.Generic)-instance Generic NewCount---data NewCountIndexed = NewCountIndexed deriving (Eq, Show, GHC.Generic)-instance Generic NewCountIndexed-instance AbiType NewCountIndexed where- isDynamic = const False-instance AbiGet NewCountIndexed--data NewCountNonIndexed = NewCountNonIndexed (Tagged 1 (UIntN 256)) deriving (Eq, Show, GHC.Generic)-instance Generic NewCountNonIndexed-instance AbiType NewCountNonIndexed where- isDynamic = const False-instance AbiGet NewCountNonIndexed--instance IndexedEvent NewCountIndexed NewCountNonIndexed NewCount where- isAnonymous = const False---- WeirdERC20 Event Types (Transfer type wrong order for testing purposes)-data Transfer = Transfer Address (UIntN 256) Address deriving (Eq, Show, GHC.Generic)-instance Generic Transfer--data TransferIndexed = TransferIndexed (Tagged 1 Address) (Tagged 3 Address) deriving (Eq, Show, GHC.Generic)-instance Generic TransferIndexed-instance AbiType TransferIndexed where- isDynamic = const False-instance AbiGet TransferIndexed--data TransferNonIndexed = TransferNonIndexed (Tagged 2 (UIntN 256)) deriving (Eq, Show, GHC.Generic)-instance Generic TransferNonIndexed-instance AbiType TransferNonIndexed where- isDynamic = const False-instance AbiGet TransferNonIndexed--instance IndexedEvent TransferIndexed TransferNonIndexed Transfer where- isAnonymous = const False
@@ -1,13 +0,0 @@-{-# LANGUAGE QuasiQuotes #-}--module Network.Ethereum.Web3.Test.MethodDumpSpec where--import Network.Ethereum.Contract.TH-import Test.Hspec---spec :: Spec-spec = describe "methodDump" $- it "can dump an ABI" $ do- let theApiDump = [abiFrom|examples/token/ERC20.json|]- in theApiDump `shouldNotBe` ""
@@ -1,1 +0,0 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
@@ -1,156 +1,26 @@-cabal-version: 2.2-name: web3-version: 0.9.1.0-license: BSD-3-Clause-license-file: LICENSE-copyright: (c) Alexander Krupenkin 2016-maintainer: mail@akru.me-author: Alexander Krupenkin-homepage: https://github.com/airalab/hs-web3#readme-bug-reports: https://github.com/airalab/hs-web3/issues-synopsis: Web3 API for Haskell.-description: Client library for Third Generation of Web.-category: Network-build-type: Simple-extra-source-files:- README.md- CHANGELOG.md- stack.yaml- examples/token/ERC20.hs- examples/token/ERC20.json- examples/token/Main.hs- examples/token/stack.yaml- examples/token/package.yaml- examples/polkadot/Main.hs- examples/polkadot/stack.yaml- examples/polkadot/package.yaml- examples/scale/Main.hs- examples/scale/stack.yaml- examples/scale/package.yaml- test/contracts/Registry.json- test/contracts/SimpleStorage.json- test/contracts/ComplexStorage.json- test/contracts/Linearization.json+cabal-version: 1.12+name: web3+version: 1.0.0.0+license: Apache-2.0+license-file: LICENSE+copyright: (c) Aleksandr Krupenkin 2016-2021+maintainer: mail@akru.me+author: Aleksandr Krupenkin+homepage: https://github.com/airalab/hs-web3#readme+bug-reports: https://github.com/airalab/hs-web3/issues+synopsis: Haskell Web3 library.+description: Client library for Third Generation of Web.+category: Network+build-type: Simple source-repository head type: git location: https://github.com/airalab/hs-web3 -flag compiler- description: Enable Solidity compiler- default: False- manual: True--flag debug- description: Enable debug compiler options- default: False- manual: True- library- exposed-modules:- Codec.Scale- Codec.Scale.Class- Codec.Scale.Compact- Codec.Scale.Core- Codec.Scale.Generic- Codec.Scale.SingletonEnum- Codec.Scale.Skip- Codec.Scale.TH- Crypto.Ecdsa.Signature- Crypto.Ecdsa.Utils- Crypto.Ethereum- Crypto.Ethereum.Keyfile- Crypto.Ethereum.Signature- Crypto.Ethereum.Utils- Crypto.Random.HmacDrbg- Data.ByteArray.HexString- Data.Solidity.Abi- Data.Solidity.Abi.Codec- Data.Solidity.Abi.Generic- Data.Solidity.Event- Data.Solidity.Event.Internal- Data.Solidity.Prim- Data.Solidity.Prim.Address- Data.Solidity.Prim.Bool- Data.Solidity.Prim.Bytes- Data.Solidity.Prim.Int- Data.Solidity.Prim.List- Data.Solidity.Prim.String- Data.Solidity.Prim.Tagged- Data.Solidity.Prim.Tuple- Data.Solidity.Prim.Tuple.TH- Data.String.Extra- Language.Solidity.Abi- Network.Ethereum- Network.Ethereum.Account- Network.Ethereum.Account.Class- Network.Ethereum.Account.Default- Network.Ethereum.Account.Internal- Network.Ethereum.Account.LocalKey- Network.Ethereum.Account.Personal- Network.Ethereum.Account.Safe- Network.Ethereum.Api.Eth- Network.Ethereum.Api.Net- Network.Ethereum.Api.Personal- Network.Ethereum.Api.Types- Network.Ethereum.Api.Web3- Network.Ethereum.Chain- Network.Ethereum.Contract- Network.Ethereum.Contract.Event- Network.Ethereum.Contract.Event.Common- Network.Ethereum.Contract.Event.MultiFilter- Network.Ethereum.Contract.Event.SingleFilter- Network.Ethereum.Contract.Method- Network.Ethereum.Contract.TH- Network.Ethereum.Ens- Network.Ethereum.Ens.PublicResolver- Network.Ethereum.Ens.Registry- Network.Ethereum.Transaction- Network.Ethereum.Unit- Network.Ipfs.Api.Bitswap- Network.Ipfs.Api.Block- Network.Ipfs.Api.Bootstrap- Network.Ipfs.Api.Cid- Network.Ipfs.Api.Config- Network.Ipfs.Api.Core- Network.Ipfs.Api.Dag- Network.Ipfs.Api.Dht- Network.Ipfs.Api.Files- Network.Ipfs.Api.Internal- Network.Ipfs.Api.Internal.Call- Network.Ipfs.Api.Internal.Stream- Network.Ipfs.Api.Key- Network.Ipfs.Api.Log- Network.Ipfs.Api.Object- Network.Ipfs.Api.Pin- Network.Ipfs.Api.Pubsub- Network.Ipfs.Api.Repo- Network.Ipfs.Api.Stats- Network.Ipfs.Api.Swarm- Network.Ipfs.Api.Types- Network.Ipfs.Api.Types.Stream- Network.Ipfs.Client- Network.JsonRpc.TinyClient- Network.Polkadot.Api.Account- Network.Polkadot.Api.Author- Network.Polkadot.Api.Babe- Network.Polkadot.Api.Chain- Network.Polkadot.Api.Childstate- Network.Polkadot.Api.Contracts- Network.Polkadot.Api.Engine- Network.Polkadot.Api.Grandpa- Network.Polkadot.Api.Offchain- Network.Polkadot.Api.Payment- Network.Polkadot.Api.Rpc- Network.Polkadot.Api.State- Network.Polkadot.Api.System- Network.Polkadot.Api.Types- Network.Web3- Network.Web3.Provider-+ exposed-modules: Network.Web3 hs-source-dirs: src other-modules: Paths_web3- autogen-modules: Paths_web3 default-language: Haskell2010 ghc-options: -funbox-strict-fields -Wduplicate-exports -Whi-shadowing@@ -163,446 +33,7 @@ -Wunused-imports -Wunused-matches -Wunused-foralls -Wtabs build-depends:- OneTuple >=0.2.1 && <0.3,- aeson >=1.2.2.0 && <1.5,- async >=2.1.1.1 && <2.3,- attoparsec >=0.13.2.1 && <0.14,- base >4.11 && <4.14,- base58string >=0.10.0 && <0.11,- basement >=0.0.4 && <0.1,- bitvec >=1.0.0 && <2.0,- bytestring >=0.10.8.1 && <0.11,- cereal >=0.5.4.0 && <0.6,- cryptonite >=0.23 && <0.27,- data-default >=0.7.1.1 && <0.8,- errors >=2.2 && <2.4,- exceptions >=0.8.3 && <0.11,- generics-sop >=0.3.1.0 && <0.6,- hspec >=2.4 && <2.8,- http-client >=0.5.7.1 && <0.7,- http-client-tls >=0.3.5.1 && <0.4,- http-media >=0.7 && <0.8.1,- http-types >=0.12 && <0.14,- machines >=0.6.3 && <0.8,- memory >=0.14.11 && <0.16,- microlens >=0.4.8.1 && <0.5,- microlens-aeson >=2.2.0.2 && <2.4,- microlens-mtl >=0.1.11.0 && <0.3,- microlens-th >=0.4.1.1 && <0.5,- mtl >=2.2.1 && <2.3,- network >=2.6 && <3.2,- parsec >=3.1.11 && <3.2,- relapse >=1.0.0.0 && <2.0,- servant >=0.13 && <0.17,- servant-client >=0.13 && <0.17,- tagged >=0.8.5 && <0.9,- tar ==0.5.*,- template-haskell >=2.12 && <2.16,- text >=1.2.2.2 && <1.3,- transformers >=0.5.2.0 && <0.6,- unordered-containers ==0.2.*,- uuid-types >=1.0.3 && <1.1,- vector ==0.12.*,- vinyl >=0.5.3 && <0.13,- websockets >=0.11 && <0.13-- if flag(debug)- ghc-options: -ddump-splices-- if flag(compiler)- cpp-options: -DSOLIDITY_COMPILER- c-sources: ./compiler/cbits/solidity_lite.cpp- hs-source-dirs: compiler- other-modules:- Language.Solidity.Compiler- Language.Solidity.Compiler.Foreign-- extra-libraries: solidity- include-dirs: ./compiler/cbits- build-depends: containers >=0.6.2.1 && <0.7--test-suite live- type: exitcode-stdio-1.0- main-is: Spec.hs- hs-source-dirs: test src- other-modules:- Network.Ethereum.Test.ComplexStorageSpec- Network.Ethereum.Test.ERC20Spec- Network.Ethereum.Test.LinearizationSpec- Network.Ethereum.Test.LocalAccountSpec- Network.Ethereum.Test.RegistrySpec- Network.Ethereum.Test.SimpleStorageSpec- Network.Ethereum.Test.Utils- Network.Ipfs.Api.Test.Key- Codec.Scale- Codec.Scale.Class- Codec.Scale.Compact- Codec.Scale.Core- Codec.Scale.Generic- Codec.Scale.SingletonEnum- Codec.Scale.Skip- Codec.Scale.TH- Crypto.Ecdsa.Signature- Crypto.Ecdsa.Utils- Crypto.Ethereum- Crypto.Ethereum.Keyfile- Crypto.Ethereum.Signature- Crypto.Ethereum.Utils- Crypto.Random.HmacDrbg- Data.ByteArray.HexString- Data.Solidity.Abi- Data.Solidity.Abi.Codec- Data.Solidity.Abi.Generic- Data.Solidity.Event- Data.Solidity.Event.Internal- Data.Solidity.Prim- Data.Solidity.Prim.Address- Data.Solidity.Prim.Bool- Data.Solidity.Prim.Bytes- Data.Solidity.Prim.Int- Data.Solidity.Prim.List- Data.Solidity.Prim.String- Data.Solidity.Prim.Tagged- Data.Solidity.Prim.Tuple- Data.Solidity.Prim.Tuple.TH- Data.String.Extra- Language.Solidity.Abi- Network.Ethereum- Network.Ethereum.Account- Network.Ethereum.Account.Class- Network.Ethereum.Account.Default- Network.Ethereum.Account.Internal- Network.Ethereum.Account.LocalKey- Network.Ethereum.Account.Personal- Network.Ethereum.Account.Safe- Network.Ethereum.Api.Eth- Network.Ethereum.Api.Net- Network.Ethereum.Api.Personal- Network.Ethereum.Api.Types- Network.Ethereum.Api.Web3- Network.Ethereum.Chain- Network.Ethereum.Contract- Network.Ethereum.Contract.Event- Network.Ethereum.Contract.Event.Common- Network.Ethereum.Contract.Event.MultiFilter- Network.Ethereum.Contract.Event.SingleFilter- Network.Ethereum.Contract.Method- Network.Ethereum.Contract.TH- Network.Ethereum.Ens- Network.Ethereum.Ens.PublicResolver- Network.Ethereum.Ens.Registry- Network.Ethereum.Transaction- Network.Ethereum.Unit- Network.Ipfs.Api.Bitswap- Network.Ipfs.Api.Block- Network.Ipfs.Api.Bootstrap- Network.Ipfs.Api.Cid- Network.Ipfs.Api.Config- Network.Ipfs.Api.Core- Network.Ipfs.Api.Dag- Network.Ipfs.Api.Dht- Network.Ipfs.Api.Files- Network.Ipfs.Api.Internal- Network.Ipfs.Api.Internal.Call- Network.Ipfs.Api.Internal.Stream- Network.Ipfs.Api.Key- Network.Ipfs.Api.Log- Network.Ipfs.Api.Object- Network.Ipfs.Api.Pin- Network.Ipfs.Api.Pubsub- Network.Ipfs.Api.Repo- Network.Ipfs.Api.Stats- Network.Ipfs.Api.Swarm- Network.Ipfs.Api.Types- Network.Ipfs.Api.Types.Stream- Network.Ipfs.Client- Network.JsonRpc.TinyClient- Network.Polkadot.Api.Account- Network.Polkadot.Api.Author- Network.Polkadot.Api.Babe- Network.Polkadot.Api.Chain- Network.Polkadot.Api.Childstate- Network.Polkadot.Api.Contracts- Network.Polkadot.Api.Engine- Network.Polkadot.Api.Grandpa- Network.Polkadot.Api.Offchain- Network.Polkadot.Api.Payment- Network.Polkadot.Api.Rpc- Network.Polkadot.Api.State- Network.Polkadot.Api.System- Network.Polkadot.Api.Types- Network.Web3- Network.Web3.Provider- Paths_web3-- default-language: Haskell2010- ghc-options:- -funbox-strict-fields -Wduplicate-exports -Whi-shadowing- -Widentities -Woverlapping-patterns -Wpartial-type-signatures- -Wunrecognised-pragmas -Wtyped-holes -Wincomplete-patterns- -Wincomplete-uni-patterns -Wmissing-fields -Wmissing-methods- -Wmissing-exported-signatures -Wmissing-monadfail-instances- -Wmissing-signatures -Wname-shadowing -Wunused-binds- -Wunused-top-binds -Wunused-local-binds -Wunused-pattern-binds- -Wunused-imports -Wunused-matches -Wunused-foralls -Wtabs -threaded- -rtsopts -with-rtsopts=-N-- build-depends:- OneTuple >=0.2.1 && <0.3,- aeson >=1.2.2.0 && <1.5,- async >=2.1.1.1 && <2.3,- attoparsec >=0.13.2.1 && <0.14,- base >4.11 && <4.14,- base58string >=0.10.0 && <0.11,- basement >=0.0.4 && <0.1,- bitvec >=1.0.0 && <2.0,- bytestring >=0.10.8.1 && <0.11,- cereal >=0.5.4.0 && <0.6,- cryptonite >=0.23 && <0.27,- data-default >=0.7.1.1 && <0.8,- errors >=2.2 && <2.4,- exceptions >=0.8.3 && <0.11,- generics-sop >=0.3.1.0 && <0.6,- hspec >=2.4.4 && <2.8,- hspec-contrib >=0.4.0 && <0.6,- hspec-discover >=2.4.4 && <2.8,- hspec-expectations >=0.8.2 && <0.9,- http-client >=0.5.7.1 && <0.7,- http-client-tls >=0.3.5.1 && <0.4,- http-media >=0.7 && <0.8.1,- http-types >=0.12 && <0.14,- machines >=0.6.3 && <0.8,- memory >=0.14.11 && <0.16,- microlens >=0.4.8.1 && <0.5,- microlens-aeson >=2.2.0.2 && <2.4,- microlens-mtl >=0.1.11.0 && <0.3,- microlens-th >=0.4.1.1 && <0.5,- mtl >=2.2.1 && <2.3,- network >=2.6 && <3.2,- parsec >=3.1.11 && <3.2,- random ==1.1.*,- relapse >=1.0.0.0 && <2.0,- servant >=0.13 && <0.17,- servant-client >=0.13 && <0.17,- split >=0.2.3 && <0.3,- stm >=2.4.4 && <2.6,- tagged >=0.8.5 && <0.9,- tar ==0.5.*,- template-haskell >=2.12 && <2.16,- text >=1.2.2.2 && <1.3,- time >=1.6.0 && <1.11,- transformers >=0.5.2.0 && <0.6,- unordered-containers ==0.2.*,- uuid-types >=1.0.3 && <1.1,- vector ==0.12.*,- vinyl >=0.5.3 && <0.13,- websockets >=0.11 && <0.13-- if flag(debug)- ghc-options: -ddump-splices-- if flag(compiler)- cpp-options: -DSOLIDITY_COMPILER- c-sources: ./compiler/cbits/solidity_lite.cpp- hs-source-dirs: compiler- other-modules:- Language.Solidity.Compiler- Language.Solidity.Compiler.Foreign-- extra-libraries: solidity- include-dirs: ./compiler/cbits- build-depends: containers >=0.6.2.1 && <0.7--test-suite unit- type: exitcode-stdio-1.0- main-is: Spec.hs- hs-source-dirs: unit src- other-modules:- Codec.Scale.Test.CoreSpec- Codec.Scale.Test.SingleFieldStructSpec- Codec.Scale.Test.SkipSpec- Crypto.Ethereum.Test.KeyfileSpec- Crypto.Ethereum.Test.SignatureSpec- Crypto.Random.Test.HmacDrbgSpec- Data.Solidity.Test.AddressSpec- Data.Solidity.Test.EncodingSpec- Data.Solidity.Test.IntSpec- Language.Solidity.Test.AbiSpec- Language.Solidity.Test.CompilerSpec- Network.Ethereum.Contract.Test.THSpec- Network.Ethereum.Web3.Test.EventSpec- Network.Ethereum.Web3.Test.MethodDumpSpec- Codec.Scale- Codec.Scale.Class- Codec.Scale.Compact- Codec.Scale.Core- Codec.Scale.Generic- Codec.Scale.SingletonEnum- Codec.Scale.Skip- Codec.Scale.TH- Crypto.Ecdsa.Signature- Crypto.Ecdsa.Utils- Crypto.Ethereum- Crypto.Ethereum.Keyfile- Crypto.Ethereum.Signature- Crypto.Ethereum.Utils- Crypto.Random.HmacDrbg- Data.ByteArray.HexString- Data.Solidity.Abi- Data.Solidity.Abi.Codec- Data.Solidity.Abi.Generic- Data.Solidity.Event- Data.Solidity.Event.Internal- Data.Solidity.Prim- Data.Solidity.Prim.Address- Data.Solidity.Prim.Bool- Data.Solidity.Prim.Bytes- Data.Solidity.Prim.Int- Data.Solidity.Prim.List- Data.Solidity.Prim.String- Data.Solidity.Prim.Tagged- Data.Solidity.Prim.Tuple- Data.Solidity.Prim.Tuple.TH- Data.String.Extra- Language.Solidity.Abi- Network.Ethereum- Network.Ethereum.Account- Network.Ethereum.Account.Class- Network.Ethereum.Account.Default- Network.Ethereum.Account.Internal- Network.Ethereum.Account.LocalKey- Network.Ethereum.Account.Personal- Network.Ethereum.Account.Safe- Network.Ethereum.Api.Eth- Network.Ethereum.Api.Net- Network.Ethereum.Api.Personal- Network.Ethereum.Api.Types- Network.Ethereum.Api.Web3- Network.Ethereum.Chain- Network.Ethereum.Contract- Network.Ethereum.Contract.Event- Network.Ethereum.Contract.Event.Common- Network.Ethereum.Contract.Event.MultiFilter- Network.Ethereum.Contract.Event.SingleFilter- Network.Ethereum.Contract.Method- Network.Ethereum.Contract.TH- Network.Ethereum.Ens- Network.Ethereum.Ens.PublicResolver- Network.Ethereum.Ens.Registry- Network.Ethereum.Transaction- Network.Ethereum.Unit- Network.Ipfs.Api.Bitswap- Network.Ipfs.Api.Block- Network.Ipfs.Api.Bootstrap- Network.Ipfs.Api.Cid- Network.Ipfs.Api.Config- Network.Ipfs.Api.Core- Network.Ipfs.Api.Dag- Network.Ipfs.Api.Dht- Network.Ipfs.Api.Files- Network.Ipfs.Api.Internal- Network.Ipfs.Api.Internal.Call- Network.Ipfs.Api.Internal.Stream- Network.Ipfs.Api.Key- Network.Ipfs.Api.Log- Network.Ipfs.Api.Object- Network.Ipfs.Api.Pin- Network.Ipfs.Api.Pubsub- Network.Ipfs.Api.Repo- Network.Ipfs.Api.Stats- Network.Ipfs.Api.Swarm- Network.Ipfs.Api.Types- Network.Ipfs.Api.Types.Stream- Network.Ipfs.Client- Network.JsonRpc.TinyClient- Network.Polkadot.Api.Account- Network.Polkadot.Api.Author- Network.Polkadot.Api.Babe- Network.Polkadot.Api.Chain- Network.Polkadot.Api.Childstate- Network.Polkadot.Api.Contracts- Network.Polkadot.Api.Engine- Network.Polkadot.Api.Grandpa- Network.Polkadot.Api.Offchain- Network.Polkadot.Api.Payment- Network.Polkadot.Api.Rpc- Network.Polkadot.Api.State- Network.Polkadot.Api.System- Network.Polkadot.Api.Types- Network.Web3- Network.Web3.Provider- Paths_web3-- default-language: Haskell2010- ghc-options:- -funbox-strict-fields -Wduplicate-exports -Whi-shadowing- -Widentities -Woverlapping-patterns -Wpartial-type-signatures- -Wunrecognised-pragmas -Wtyped-holes -Wincomplete-patterns- -Wincomplete-uni-patterns -Wmissing-fields -Wmissing-methods- -Wmissing-exported-signatures -Wmissing-monadfail-instances- -Wmissing-signatures -Wname-shadowing -Wunused-binds- -Wunused-top-binds -Wunused-local-binds -Wunused-pattern-binds- -Wunused-imports -Wunused-matches -Wunused-foralls -Wtabs -threaded- -rtsopts -with-rtsopts=-N-- build-depends:- OneTuple >=0.2.1 && <0.3,- aeson >=1.2.2.0 && <1.5,- async >=2.1.1.1 && <2.3,- attoparsec >=0.13.2.1 && <0.14,- base >4.11 && <4.14,- base58string >=0.10.0 && <0.11,- basement >=0.0.4 && <0.1,- bitvec >=1.0.0 && <2.0,- bytestring >=0.10.8.1 && <0.11,- cereal >=0.5.4.0 && <0.6,- cryptonite >=0.23 && <0.27,- data-default >=0.7.1.1 && <0.8,- errors >=2.2 && <2.4,- exceptions >=0.8.3 && <0.11,- generics-sop >=0.3.1.0 && <0.6,- hspec >=2.4.4 && <2.8,- hspec-contrib >=0.4.0 && <0.6,- hspec-discover >=2.4.4 && <2.8,- hspec-expectations >=0.8.2 && <0.9,- http-client >=0.5.7.1 && <0.7,- http-client-tls >=0.3.5.1 && <0.4,- http-media >=0.7 && <0.8.1,- http-types >=0.12 && <0.14,- machines >=0.6.3 && <0.8,- memory >=0.14.11 && <0.16,- microlens >=0.4.8.1 && <0.5,- microlens-aeson >=2.2.0.2 && <2.4,- microlens-mtl >=0.1.11.0 && <0.3,- microlens-th >=0.4.1.1 && <0.5,- mtl >=2.2.1 && <2.3,- network >=2.6 && <3.2,- parsec >=3.1.11 && <3.2,- relapse >=1.0.0.0 && <2.0,- servant >=0.13 && <0.17,- servant-client >=0.13 && <0.17,- tagged >=0.8.5 && <0.9,- tar ==0.5.*,- template-haskell >=2.12 && <2.16,- text >=1.2.2.2 && <1.3,- transformers >=0.5.2.0 && <0.6,- unordered-containers ==0.2.*,- uuid-types >=1.0.3 && <1.1,- vector ==0.12.*,- vinyl >=0.5.3 && <0.13,- websockets >=0.11 && <0.13-- if flag(debug)- ghc-options: -ddump-splices-- if flag(compiler)- cpp-options: -DSOLIDITY_COMPILER- c-sources: ./compiler/cbits/solidity_lite.cpp- hs-source-dirs: compiler- other-modules:- Language.Solidity.Compiler- Language.Solidity.Compiler.Foreign-- extra-libraries: solidity- include-dirs: ./compiler/cbits- build-depends: containers >=0.6.2.1 && <0.7+ base >4.11 && <4.15,+ web3-ethereum ==1.0.*,+ web3-polkadot ==1.0.*,+ web3-provider ==1.0.*