├── .vscode └── settings.json ├── LICENSE ├── README.md ├── mod.ts ├── packages ├── web3-bzz │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── bzz-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-core-helpers │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── errors.js │ │ ├── formatters.js │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ ├── errors-test.ts │ │ └── formatters-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-core-method │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-core-promievent │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ └── tsconfig.json ├── web3-core-requestmanager │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── batch.js │ │ ├── givenProvider.js │ │ ├── index.js │ │ └── jsonrpc.js │ └── tsconfig.json ├── web3-core-subscriptions │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.js │ │ └── subscription.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── subscriptions.tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-core │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── extend.js │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth-abi │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── abi-coder-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth-accounts │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── accounts-tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth-contract │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── contract-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth-ens │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── ENS.js │ │ ├── config.js │ │ ├── contracts │ │ │ └── Registry.js │ │ ├── index.js │ │ ├── lib │ │ │ ├── ResolverMethodHandler.js │ │ │ └── contentHash.js │ │ └── resources │ │ │ └── ABI │ │ │ ├── Registry.js │ │ │ └── Resolver.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── ens-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth-iban │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── iban-tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth-personal │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── personal-tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── getNetworkType.js │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── eth.tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-eth2-beaconchain │ ├── .babelrc │ ├── Makefile │ ├── babel.config.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── schema.ts │ ├── test │ │ ├── constructor.test.ts │ │ └── schemaMethods.test.ts │ ├── tsconfig.json │ ├── tslint.json │ └── types.ts ├── web3-eth2-core │ ├── .babelrc │ ├── babel.config.json │ ├── jest.config.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── constructor.test.ts │ │ └── routeBuild.test.ts │ ├── tsconfig.json │ ├── tslint.json │ └── types.ts ├── web3-net │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── network-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-providers-http │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── web3-provider-http-tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-providers-ipc │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── web3-provider-ipc-tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-providers-ws │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── helpers.js │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── web3-provider-ws-tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-shh │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ └── shh-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── web3-utils │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.js │ │ ├── soliditySha3.js │ │ └── utils.js │ ├── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ ├── tests │ │ ├── ascii-to-hex-test.ts │ │ ├── bytes-to-hex-test.ts │ │ ├── check-address-checksum-test.ts │ │ ├── encode-packed.ts │ │ ├── from-ascii-test.ts │ │ ├── from-decimal-test.ts │ │ ├── from-utf8-test.ts │ │ ├── from-wei-test.ts │ │ ├── get-signature-params-test.ts │ │ ├── get-unit-value-test.ts │ │ ├── hex-to-ascii-test.ts │ │ ├── hex-to-bytes-test.ts │ │ ├── hex-to-number-string-test.ts │ │ ├── hex-to-number-test.ts │ │ ├── hex-to-string-test.ts │ │ ├── hex-to-utf8-test.ts │ │ ├── is-address-test.ts │ │ ├── is-big-number-test.ts │ │ ├── is-bloom-test.ts │ │ ├── is-bn-test.ts │ │ ├── is-contract-address-in-bloom.ts │ │ ├── is-hex-strict-test.ts │ │ ├── is-hex-test.ts │ │ ├── is-in-bloom.ts │ │ ├── is-topic-in-bloom.ts │ │ ├── is-topic-test.ts │ │ ├── is-topic.ts │ │ ├── is-user-ethereum-address-in-bloom.ts │ │ ├── json-interface-method-to-string-test.ts │ │ ├── keccak256-test.ts │ │ ├── left-pad-test.ts │ │ ├── number-to-hex-test.ts │ │ ├── pad-left-test.ts │ │ ├── pad-right-test.ts │ │ ├── random-hex-test.ts │ │ ├── right-pad-test.ts │ │ ├── sha3-raw-test.ts │ │ ├── sha3-test.ts │ │ ├── solidity-sha3-raw-test.ts │ │ ├── solidity-sha3-test.ts │ │ ├── string-to-hex-test.ts │ │ ├── strip-hex-prefix-test.ts │ │ ├── test-address-test.ts │ │ ├── test-topic-test.ts │ │ ├── to-ascii-test.ts │ │ ├── to-bn-test.ts │ │ ├── to-check-sum-address-test.ts │ │ ├── to-decimal-test.ts │ │ ├── to-hex-test.ts │ │ ├── to-number-test.ts │ │ ├── to-twos-compement-test.ts │ │ ├── to-utf8-test.ts │ │ ├── to-wei-test.ts │ │ ├── unit-map-test.ts │ │ └── utf8-to-hex-test.ts │ │ ├── tsconfig.json │ │ └── tslint.json └── web3 │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ └── index.js │ ├── tsconfig.json │ └── types │ ├── index.d.ts │ ├── tests │ └── web3-test.ts │ ├── tsconfig.json │ └── tslint.json ├── test.ts ├── types ├── bignumber.d.ts ├── bn.d.ts ├── buffer.d.ts ├── http.d.ts └── net.d.ts └── usage-examples ├── create-account.ts ├── get-balance.ts └── get-transaction.ts /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": true, 3 | "deno.suggest.imports.hosts": { 4 | "https://deno.land": false 5 | } 6 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 michael spengler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /mod.ts: -------------------------------------------------------------------------------- 1 | // @deno-types="https://deno.land/x/web3@v0.11.1/packages/web3/types/index.d.ts" 2 | import Web3 from 'https://deno.land/x/web3@v0.11.1/packages/web3/src/index.js'; 3 | 4 | export default Web3; 5 | -------------------------------------------------------------------------------- /packages/web3-bzz/README.md: -------------------------------------------------------------------------------- 1 | # web3-bzz 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the swarm package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-bzz 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3Bzz = require('https://deno.land/x/web3@v0.9.2/packages/web3-bzz/src/index.js'); 23 | 24 | const bzz = new Web3Bzz('http://swarm-gateways.net'); 25 | ``` 26 | 27 | ## Types 28 | 29 | All the TypeScript typings are placed in the `types` folder. 30 | 31 | [docs]: http://web3js.readthedocs.io/en/1.0/ 32 | [repo]: https://github.com/ethereum/web3.js 33 | [npm-image]: https://img.shields.io/npm/v/web3-bzz.svg 34 | [npm-url]: https://npmjs.org/package/web3-bzz 35 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-bzz 36 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-bzz 37 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-bzz 38 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-bzz 39 | -------------------------------------------------------------------------------- /packages/web3-bzz/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-bzz", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "12.20.33", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.33.tgz", 10 | "integrity": "sha512-5XmYX2GECSa+CxMYaFsr2mrql71Q4EvHjKS+ox/SiwSdaASMoBIWE6UmZqFO+VX1jIcsYLStI4FFoB6V7FeIYw==" 11 | }, 12 | "typescript": { 13 | "version": "3.9.10", 14 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 15 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 16 | "dev": true 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/web3-bzz/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-bzz", 3 | "version": "1.7.0", 4 | "description": "Web3 module to interact with the Swarm network.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-bzz", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types", 14 | "postinstall": "echo \"WARNING: the web3-bzz api will be deprecated in the next version\"" 15 | }, 16 | "main": "lib/index.js", 17 | "dependencies": { 18 | "@types/node": "^12.12.6", 19 | "got": "9.6.0", 20 | "swarm-js": "^0.1.40" 21 | }, 22 | "devDependencies": { 23 | "dtslint": "^3.4.1", 24 | "typescript": "^3.9.5" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/web3-bzz/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-bzz/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file index.d.ts 16 | * @author Josh Stevens 17 | * @date 2018 18 | */ 19 | 20 | export class Bzz { 21 | constructor(); 22 | 23 | constructor(provider: any); 24 | 25 | readonly givenProvider: any; 26 | 27 | static readonly givenProvider: any; 28 | 29 | readonly currentProvider: any; 30 | 31 | setProvider(provider: any): boolean; 32 | 33 | upload(data: any): Promise; 34 | 35 | download(bzzHash: string, localPath?: string): Promise; 36 | 37 | pick: Pick; 38 | } 39 | 40 | export interface Pick { 41 | file: () => Promise; 42 | directory: () => Promise; 43 | data: () => Promise; 44 | } 45 | -------------------------------------------------------------------------------- /packages/web3-bzz/types/tests/bzz-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file bzz-tests.ts 16 | * @author Josh Stevens 17 | * @date 2018 18 | */ 19 | 20 | import { Bzz } from 'https://deno.land/x/web3@v0.9.2/packages/web3-bzz/src/index.js'; 21 | 22 | // $ExpectType Bzz 23 | const bzz_empty = new Bzz(); 24 | 25 | // $ExpectType Bzz 26 | const bzz = new Bzz('http://swarm-gateways.net'); 27 | 28 | // $ExpectType any 29 | Bzz.givenProvider; 30 | 31 | // $ExpectType boolean 32 | bzz.setProvider('test.com'); 33 | 34 | // $ExpectType any 35 | bzz.currentProvider; 36 | 37 | // $ExpectType any 38 | bzz.givenProvider; 39 | 40 | // $ExpectType boolean 41 | bzz.setProvider('https://localhost:2100'); 42 | 43 | // $ExpectType Promise 44 | bzz.upload('test file'); 45 | 46 | const dir = { 47 | '/foo.txt': { type: 'text/plain', data: 'sample file' }, 48 | '/bar.txt': { type: 'text/plain', data: 'another file' }, 49 | }; 50 | 51 | // $ExpectType Promise 52 | bzz.upload(dir); 53 | // $ExpectType Promise 54 | bzz.upload({ 55 | path: '/path/to/thing', 56 | kind: 'directory', 57 | defaultFile: '/index.html', 58 | }); 59 | 60 | // ExpectType Promise; 61 | bzz.download('hash'); 62 | 63 | // ExpectType Promise; 64 | bzz.download('hash', 'path'); 65 | 66 | // $ExpectType Promise 67 | bzz.pick.file(); 68 | 69 | // $ExpectType Promise 70 | bzz.pick.directory(); 71 | 72 | // $ExpectType Promise 73 | bzz.pick.data(); 74 | -------------------------------------------------------------------------------- /packages/web3-bzz/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-bzz": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-bzz/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false, 10 | "no-redundant-jsdoc": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/web3-core-helpers/README.md: -------------------------------------------------------------------------------- 1 | # web3-core-helpers 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo] with useful helper functions. 6 | 7 | Please read the [documentation][docs] for more. 8 | 9 | ## Installation 10 | 11 | ### Node.js 12 | 13 | ```bash 14 | npm install web3-core-helpers 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | const helpers = require('https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/src/index.js'); 21 | 22 | helpers.formatters; 23 | helpers.errors; 24 | ... 25 | ``` 26 | 27 | ## Types 28 | 29 | All the TypeScript typings are placed in the `types` folder. 30 | 31 | [docs]: http://web3js.readthedocs.io/en/1.0/ 32 | [repo]: https://github.com/ethereum/web3.js 33 | [npm-image]: https://img.shields.io/npm/v/web3-core-helpers.svg 34 | [npm-url]: https://npmjs.org/package/web3-core-helpers 35 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-core-helpers 36 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-core-helpers 37 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-core-helpers 38 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-core-helpers -------------------------------------------------------------------------------- /packages/web3-core-helpers/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-helpers", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "12.20.33", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.33.tgz", 10 | "integrity": "sha512-5XmYX2GECSa+CxMYaFsr2mrql71Q4EvHjKS+ox/SiwSdaASMoBIWE6UmZqFO+VX1jIcsYLStI4FFoB6V7FeIYw==", 11 | "dev": true 12 | }, 13 | "typescript": { 14 | "version": "3.9.10", 15 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 16 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 17 | "dev": true 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/web3-core-helpers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-helpers", 3 | "version": "1.7.0", 4 | "description": "Web3 core tools helper for sub packages. This is an internal package.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-core-helpers", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "web3-eth-iban": "1.7.0", 18 | "web3-utils": "1.7.0" 19 | }, 20 | "devDependencies": { 21 | "@types/node": "^12.12.6", 22 | "dtslint": "^3.4.1", 23 | "typescript": "^3.9.5" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/web3-core-helpers/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file index.js 19 | * @author Fabian Vogelsteller 20 | * @date 2017 21 | */ 22 | 23 | 'use strict'; 24 | 25 | import errors from './errors.js'; 26 | import formatters from './formatters.js'; 27 | 28 | export { 29 | errors, 30 | formatters, 31 | }; 32 | -------------------------------------------------------------------------------- /packages/web3-core-helpers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-core-helpers/types/tests/formatters-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file formatters-test.ts 16 | * @author Samuel Furter 17 | * @date 2018 18 | */ 19 | 20 | import { formatters } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/src/index.js'; 21 | 22 | // $ExpectType number 23 | formatters.outputBigNumberFormatter(100); 24 | 25 | // $ExpectType string 26 | formatters.inputSignFormatter('0x0'); 27 | 28 | // $ExpectType string 29 | formatters.inputAddressFormatter('0x0'); 30 | 31 | // $ExpectType boolean 32 | formatters.isPredefinedBlockNumber('latest'); 33 | 34 | // $ExpectType string | number 35 | formatters.inputBlockNumberFormatter('0x0'); 36 | 37 | // $ExpectType any 38 | formatters.outputBlockFormatter({}); 39 | 40 | // $ExpectType any 41 | formatters.txInputFormatter({}); 42 | 43 | // $ExpectType any 44 | formatters.inputCallFormatter({}); 45 | 46 | // $ExpectType any 47 | formatters.inputTransactionFormatter({}); 48 | 49 | // $ExpectType any 50 | formatters.outputTransactionFormatter({}); 51 | 52 | // $ExpectType any 53 | formatters.outputTransactionReceiptFormatter({}); 54 | 55 | // $ExpectType any 56 | formatters.inputLogFormatter({}); 57 | 58 | // $ExpectType any 59 | formatters.outputLogFormatter({}); 60 | 61 | // $ExpectType any 62 | formatters.inputPostFormatter({}); 63 | 64 | // $ExpectType any 65 | formatters.outputPostFormatter({}); 66 | 67 | // $ExpectType any 68 | formatters.outputSyncingFormatter({}); 69 | -------------------------------------------------------------------------------- /packages/web3-core-helpers/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-core-helpers": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-core-helpers/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-core-method/README.md: -------------------------------------------------------------------------------- 1 | # web3-core-method 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This method package is used within most [web3.js][repo] packages. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-core-method 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3Method = require('https://deno.land/x/web3@v0.9.2/packages/web3-core-method/src/index.js'); 23 | 24 | const method = new Web3Method({ 25 | name: 'sendTransaction', 26 | call: 'eth_sendTransaction', 27 | params: 1, 28 | inputFormatter: [inputTransactionFormatter] 29 | }); 30 | method.attachToObject(myCoolLib); 31 | 32 | myCoolLib.sendTransaction({...}, function(){ ... }); 33 | ``` 34 | 35 | ## Types 36 | 37 | All the TypeScript typings are placed in the `types` folder. 38 | 39 | [docs]: http://web3js.readthedocs.io/en/1.0/ 40 | [repo]: https://github.com/ethereum/web3.js 41 | [npm-image]: https://img.shields.io/npm/v/web3-core-method.svg 42 | [npm-url]: https://npmjs.org/package/web3-core-method 43 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-core-method 44 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-core-method 45 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-core-method 46 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-core-method 47 | -------------------------------------------------------------------------------- /packages/web3-core-method/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-method", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-core-method/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-method", 3 | "version": "1.7.0", 4 | "description": "Creates the methods on the web3 modules. This is an internal package.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-core-method", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "@ethersproject/transactions": "^5.0.0-beta.135", 18 | "web3-core-helpers": "1.7.0", 19 | "web3-core-promievent": "1.7.0", 20 | "web3-core-subscriptions": "1.7.0", 21 | "web3-utils": "1.7.0" 22 | }, 23 | "devDependencies": { 24 | "dtslint": "^3.4.1", 25 | "typescript": "^3.9.5" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/web3-core-method/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib", 5 | "esModuleInterop": true 6 | }, 7 | "include": [ 8 | "./src" 9 | ] 10 | } -------------------------------------------------------------------------------- /packages/web3-core-method/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file index.d.ts 16 | * @author Samuel Furter 17 | * @date 2018 18 | */ 19 | 20 | import { JsonRpcPayload } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/types/index.d.ts'; 21 | 22 | export interface Method { 23 | name: string; 24 | call: string; 25 | params?: number; 26 | inputFormatter?: Array<(() => void) | null>; 27 | outputFormatter?: () => void; 28 | transformPayload?: () => void; 29 | extraFormatters?: any; 30 | defaultBlock?: string; 31 | defaultAccount?: string | null; 32 | abiCoder?: any; 33 | handleRevert?: boolean; 34 | } 35 | -------------------------------------------------------------------------------- /packages/web3-core-method/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-core-method": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-core-method/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-core-promievent/README.md: -------------------------------------------------------------------------------- 1 | # web3-core-promievent 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the PromiEvent package used to return a EventEmitter mixed with a Promise to allow multiple final states as well as chaining. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-core-promievent 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3PromiEvent = require('https://deno.land/x/web3@v0.9.2/packages/web3-core-promievent/src/index.js'); 23 | 24 | const myFunc = function(){ 25 | const promiEvent = Web3PromiEvent(); 26 | 27 | setTimeout(function() { 28 | promiEvent.eventEmitter.emit('done', 'Hello!'); 29 | promiEvent.resolve('Hello!'); 30 | }, 10); 31 | 32 | return promiEvent.eventEmitter; 33 | }; 34 | 35 | // and run it 36 | myFunc() 37 | .on('done', console.log) 38 | .then(console.log); 39 | ``` 40 | 41 | [docs]: http://web3js.readthedocs.io/en/1.0/ 42 | [repo]: https://github.com/ethereum/web3.js 43 | [npm-image]: https://img.shields.io/npm/v/web3-core-promievent.svg 44 | [npm-url]: https://npmjs.org/package/web3-core-promievent 45 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-core-promievent 46 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-core-promievent 47 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-core-promievent 48 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-core-promievent 49 | -------------------------------------------------------------------------------- /packages/web3-core-promievent/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-promievent", 3 | "version": "1.7.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "version": "1.6.1-rc.0", 9 | "license": "LGPL-3.0", 10 | "dependencies": { 11 | "eventemitter3": "4.0.4" 12 | }, 13 | "engines": { 14 | "node": ">=8.0.0" 15 | } 16 | }, 17 | "node_modules/eventemitter3": { 18 | "version": "4.0.4", 19 | "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.4.tgz", 20 | "integrity": "sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ==" 21 | } 22 | }, 23 | "dependencies": { 24 | "eventemitter3": { 25 | "version": "4.0.4", 26 | "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.4.tgz", 27 | "integrity": "sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ==" 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/web3-core-promievent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-promievent", 3 | "version": "1.7.0", 4 | "description": "This package extends the EventEmitter with the Promise class to allow chaining as well as multiple final states of a function.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-core-promievent", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "main": "lib/index.js", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json" 13 | }, 14 | "dependencies": { 15 | "eventemitter3": "4.0.4" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-core-promievent/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file index.js 19 | * @author Fabian Vogelsteller 20 | * @date 2016 21 | */ 22 | 23 | 'use strict'; 24 | 25 | import EventEmitter from 'https://jspm.dev/eventemitter3'; 26 | 27 | /** 28 | * This function generates a defer promise and adds eventEmitter functionality to it 29 | * 30 | * @method eventifiedPromise 31 | */ 32 | const PromiEvent = function PromiEvent(justPromise) { 33 | let resolve; let reject; 34 | const eventEmitter = new Promise(function () { 35 | resolve = arguments[0]; 36 | reject = arguments[1]; 37 | }); 38 | 39 | if (justPromise) { 40 | return { 41 | resolve, 42 | reject, 43 | eventEmitter, 44 | }; 45 | } 46 | 47 | // get eventEmitter 48 | const emitter = new EventEmitter(); 49 | 50 | // add eventEmitter to the promise 51 | eventEmitter._events = emitter._events; 52 | eventEmitter.emit = emitter.emit; 53 | eventEmitter.on = emitter.on; 54 | eventEmitter.once = emitter.once; 55 | eventEmitter.off = emitter.off; 56 | eventEmitter.listeners = emitter.listeners; 57 | eventEmitter.addListener = emitter.addListener; 58 | eventEmitter.removeListener = emitter.removeListener; 59 | eventEmitter.removeAllListeners = emitter.removeAllListeners; 60 | 61 | return { 62 | resolve, 63 | reject, 64 | eventEmitter, 65 | }; 66 | }; 67 | 68 | PromiEvent.resolve = function (value) { 69 | const promise = PromiEvent(true); 70 | promise.resolve(value); 71 | return promise.eventEmitter; 72 | }; 73 | 74 | export default PromiEvent; 75 | -------------------------------------------------------------------------------- /packages/web3-core-promievent/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-core-requestmanager/README.md: -------------------------------------------------------------------------------- 1 | # web3-core-requestmanager 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This requestmanager package is used by most [web3.js][repo] packages. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-core-requestmanager 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3WsProvider = require('https://deno.land/x/web3@v0.9.2/packages/web3-providers-ws/src/index.js'); 23 | const Web3RequestManager = require('https://deno.land/x/web3@v0.9.2/packages/web3-core-requestmanager/src/index.js'); 24 | 25 | const requestManager = new Web3RequestManager(new Web3WsProvider('ws://localhost:8546')); 26 | ``` 27 | 28 | [docs]: http://web3js.readthedocs.io/en/1.0/ 29 | [repo]: https://github.com/ethereum/web3.js 30 | [npm-image]: https://img.shields.io/npm/v/web3-core-requestmanager.svg 31 | [npm-url]: https://npmjs.org/package/web3-core-requestmanager 32 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-core-requestmanager 33 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-core-requestmanager 34 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-core-requestmanager 35 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-core-requestmanager 36 | 37 | -------------------------------------------------------------------------------- /packages/web3-core-requestmanager/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-requestmanager", 3 | "version": "1.7.0", 4 | "description": "Web3 module to handle requests to external providers.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-core-requestmanager", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "main": "lib/index.js", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json" 13 | }, 14 | "dependencies": { 15 | "util": "^0.12.0", 16 | "web3-core-helpers": "1.7.0", 17 | "web3-providers-http": "1.7.0", 18 | "web3-providers-ipc": "1.7.0", 19 | "web3-providers-ws": "1.7.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/web3-core-requestmanager/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-core-subscriptions/README.md: -------------------------------------------------------------------------------- 1 | # web3-core-subscriptions 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url]tus][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo] 6 | 7 | This subscriptions package is used within some [web3.js][repo] packages. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-core-subscriptions 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3Subscriptions = require('https://deno.land/x/web3@v0.9.2/packages/web3-core-subscriptions/src/index.js'); 23 | 24 | const sub = new Web3Subscriptions({ 25 | name: 'subscribe', 26 | type: 'eth', 27 | subscriptions: { 28 | 'newBlockHeaders': { 29 | subscriptionName: 'newHeads', 30 | params: 0, 31 | outputFormatter: formatters.outputBlockFormatter 32 | }, 33 | 'pendingTransactions': { 34 | params: 0, 35 | outputFormatter: formatters.outputTransactionFormatter 36 | } 37 | } 38 | }); 39 | sub.attachToObject(myCoolLib); 40 | 41 | myCoolLib.subscribe('newBlockHeaders', function(){ ... }); 42 | ``` 43 | 44 | [docs]: http://web3js.readthedocs.io/en/1.0/ 45 | [repo]: https://github.com/ethereum/web3.js 46 | [npm-image]: https://img.shields.io/npm/v/web3-core-subscriptions.svg 47 | [npm-url]: https://npmjs.org/package/web3-core-subscriptions 48 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-core-subscriptions 49 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-core-subscriptions 50 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-core-subscriptions 51 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-core-subscriptions 52 | 53 | -------------------------------------------------------------------------------- /packages/web3-core-subscriptions/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-subscriptions", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-core-subscriptions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core-subscriptions", 3 | "version": "1.7.0", 4 | "description": "Manages web3 subscriptions. This is an internal package.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-core-subscriptions", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "eventemitter3": "4.0.4", 18 | "web3-core-helpers": "1.7.0" 19 | }, 20 | "devDependencies": { 21 | "dtslint": "^3.4.1", 22 | "typescript": "^3.9.5" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/web3-core-subscriptions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-core-subscriptions/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-core-subscriptions": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-core-subscriptions/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false, 10 | "no-redundant-jsdoc": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/web3-core/README.md: -------------------------------------------------------------------------------- 1 | # web3-core 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | The core package contains core functions for [web3.js][repo] packages. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-core 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const core = require('https://deno.land/x/web3@v0.9.2/packages/web3-core/src/index.js'); 23 | 24 | const CoolLib = function CoolLib() { 25 | // sets _requestmanager and adds basic functions 26 | core.packageInit(this, arguments); 27 | }; 28 | 29 | CoolLib.providers; 30 | CoolLib.givenProvider; 31 | CoolLib.setProvider(); 32 | CoolLib.BatchRequest(); 33 | CoolLib.extend(); 34 | ... 35 | ``` 36 | 37 | ## Types 38 | 39 | All the TypeScript typings are placed in the `types` folder. 40 | 41 | [docs]: http://web3js.readthedocs.io/en/1.0/ 42 | [repo]: https://github.com/ethereum/web3.js 43 | [npm-image]: https://img.shields.io/npm/v/web3-core.svg 44 | [npm-url]: https://npmjs.org/package/web3-core 45 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-core 46 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-core 47 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-core 48 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-core 49 | -------------------------------------------------------------------------------- /packages/web3-core/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/bn.js": { 8 | "version": "4.11.6", 9 | "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", 10 | "integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", 11 | "requires": { 12 | "@types/node": "*" 13 | } 14 | }, 15 | "@types/node": { 16 | "version": "12.20.33", 17 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.33.tgz", 18 | "integrity": "sha512-5XmYX2GECSa+CxMYaFsr2mrql71Q4EvHjKS+ox/SiwSdaASMoBIWE6UmZqFO+VX1jIcsYLStI4FFoB6V7FeIYw==" 19 | }, 20 | "bignumber.js": { 21 | "version": "9.0.1", 22 | "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz", 23 | "integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA==" 24 | }, 25 | "typescript": { 26 | "version": "3.9.10", 27 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 28 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 29 | "dev": true 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/web3-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-core", 3 | "version": "1.7.0", 4 | "description": "Web3 core tools for sub-packages. This is an internal package.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-core", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "@types/bn.js": "^4.11.5", 18 | "@types/node": "^12.12.6", 19 | "bignumber.js": "^9.0.0", 20 | "web3-core-helpers": "1.7.0", 21 | "web3-core-method": "1.7.0", 22 | "web3-core-requestmanager": "1.7.0", 23 | "web3-utils": "1.7.0" 24 | }, 25 | "devDependencies": { 26 | "dtslint": "^3.4.1", 27 | "typescript": "^3.9.5" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/web3-core/src/extend.js: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file extend.js 19 | * @author Fabian Vogelsteller 20 | * @date 2017 21 | */ 22 | 23 | 'use strict'; 24 | 25 | import { formatters } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/src/index.js'; 26 | import Method from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-method/src/index.js'; 27 | import utils from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 28 | 29 | const extend = function (pckg) { 30 | /* jshint maxcomplexity:5 */ 31 | const ex = function (extension) { 32 | let extendedObject; 33 | if (extension.property) { 34 | if (!pckg[extension.property]) { 35 | pckg[extension.property] = {}; 36 | } 37 | extendedObject = pckg[extension.property]; 38 | } else { 39 | extendedObject = pckg; 40 | } 41 | 42 | if (extension.methods) { 43 | extension.methods.forEach((method) => { 44 | if (!(method instanceof Method)) { 45 | method = new Method(method); 46 | } 47 | 48 | method.attachToObject(extendedObject); 49 | method.setRequestManager(pckg._requestManager); 50 | }); 51 | } 52 | 53 | return pckg; 54 | }; 55 | 56 | ex.formatters = formatters; 57 | ex.utils = utils; 58 | ex.Method = Method; 59 | 60 | return ex; 61 | }; 62 | 63 | export default extend; 64 | -------------------------------------------------------------------------------- /packages/web3-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-core/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-core": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-core/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false, 10 | "no-redundant-jsdoc": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/web3-eth-abi/README.md: -------------------------------------------------------------------------------- 1 | # web3-eth-abi 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the abi package used in the `web3-eth` package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-eth-abi 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3EthAbi = require('https://deno.land/x/web3@v0.9.2/packages/web3-eth-abi/src/index.js'); 23 | 24 | Web3EthAbi.encodeFunctionSignature('myMethod(uint256,string)'); 25 | > '0x24ee0097' 26 | ``` 27 | 28 | ## Types 29 | 30 | All the TypeScript typings are placed in the `types` folder. 31 | 32 | [docs]: http://web3js.readthedocs.io/en/1.0/ 33 | [repo]: https://github.com/ethereum/web3.js 34 | [npm-image]: https://img.shields.io/npm/v/web3-eth-abi.svg 35 | [npm-url]: https://npmjs.org/package/web3-eth-abi 36 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-eth-abi 37 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-eth-abi 38 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-eth-abi 39 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-eth-abi 40 | -------------------------------------------------------------------------------- /packages/web3-eth-abi/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-abi", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-eth-abi/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-abi", 3 | "version": "1.7.0", 4 | "description": "Web3 module encode and decode EVM in/output.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-abi", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "@ethersproject/abi": "5.0.7", 18 | "web3-utils": "1.7.0" 19 | }, 20 | "devDependencies": { 21 | "dtslint": "^3.4.1", 22 | "typescript": "^3.9.5" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/web3-eth-abi/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ], 9 | } -------------------------------------------------------------------------------- /packages/web3-eth-abi/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file index.d.ts 16 | * @author Josh Stevens 17 | * @date 2018 18 | */ 19 | 20 | import { AbiInput, AbiItem } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/types/index.d.ts'; 21 | 22 | export class AbiCoder { 23 | encodeFunctionSignature(functionName: string | AbiItem): string; 24 | 25 | encodeEventSignature(functionName: string | AbiItem): string; 26 | 27 | encodeParameter(type: any, parameter: any): string; 28 | 29 | encodeParameters(types: any[], paramaters: any[]): string; 30 | 31 | encodeFunctionCall(abiItem: AbiItem, params: string[]): string; 32 | 33 | decodeParameter(type: any, hex: string): { [key: string]: any }; 34 | 35 | decodeParameters(types: any[], hex: string): { [key: string]: any }; 36 | 37 | decodeLog( 38 | inputs: AbiInput[], 39 | hex: string, 40 | topics: string[] 41 | ): { [key: string]: string }; 42 | } 43 | -------------------------------------------------------------------------------- /packages/web3-eth-abi/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-eth-abi": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-eth-abi/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "typedef-whitespace": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-eth-accounts/README.md: -------------------------------------------------------------------------------- 1 | # web3-eth-accounts 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the accounts package used in the `web3-eth` package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-eth-accounts 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3EthAccounts = require('https://deno.land/x/web3@v0.9.2/packages/web3-eth-accounts/src/index.js'); 23 | 24 | const account = new Web3EthAccounts('ws://localhost:8546'); 25 | account.create(); 26 | > { 27 | address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', 28 | privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', 29 | signTransaction: function(tx){...}, 30 | sign: function(data){...}, 31 | encrypt: function(password){...} 32 | } 33 | ``` 34 | 35 | ## Types 36 | 37 | All the TypeScript typings are placed in the `types` folder. 38 | 39 | [docs]: http://web3js.readthedocs.io/en/1.0/ 40 | [repo]: https://github.com/ethereum/web3.js 41 | [npm-image]: https://img.shields.io/npm/v/web3-eth-accounts.svg 42 | [npm-url]: https://npmjs.org/package/web3-eth-accounts 43 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-eth-accounts 44 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-eth-accounts 45 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-eth-accounts 46 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-eth-accounts 47 | -------------------------------------------------------------------------------- /packages/web3-eth-accounts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-accounts", 3 | "version": "1.7.0", 4 | "description": "Web3 module to generate Ethereum accounts and sign data and transactions.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-accounts", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "@ethereumjs/common": "^2.5.0", 18 | "@ethereumjs/tx": "^3.3.2", 19 | "crypto-browserify": "3.12.0", 20 | "eth-lib": "0.2.8", 21 | "ethereumjs-util": "^7.0.10", 22 | "scrypt-js": "^3.0.1", 23 | "uuid": "3.3.2", 24 | "web3-core": "1.7.0", 25 | "web3-core-helpers": "1.7.0", 26 | "web3-core-method": "1.7.0", 27 | "web3-utils": "1.7.0" 28 | }, 29 | "devDependencies": { 30 | "dtslint": "^3.4.1", 31 | "typescript": "^3.9.5" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/web3-eth-accounts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib", 5 | "esModuleInterop": true 6 | }, 7 | "include": [ 8 | "./src" 9 | ] 10 | } -------------------------------------------------------------------------------- /packages/web3-eth-accounts/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file index.d.ts 16 | * @author Josh Stevens , Samuel Furter 17 | * @date 2018 18 | */ 19 | 20 | import { AccountsBase, SignedTransaction, WalletBase } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core/types/index.d.ts'; 21 | 22 | export { SignedTransaction } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core/types/index.d.ts'; 23 | 24 | export class Accounts extends AccountsBase {} 25 | 26 | export class Wallet extends WalletBase {} 27 | 28 | export interface Sign extends SignedTransaction { 29 | message: string; 30 | signature: string; 31 | } 32 | 33 | export interface SignatureObject { 34 | messageHash: string; 35 | r: string; 36 | s: string; 37 | v: string; 38 | } 39 | -------------------------------------------------------------------------------- /packages/web3-eth-accounts/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-eth-accounts": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-eth-accounts/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-eth-contract/README.md: -------------------------------------------------------------------------------- 1 | # web3-eth-contract 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the contract package used in the `web3-eth` package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-eth-contract 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3EthContract = require('https://deno.land/x/web3@v0.9.2/packages/web3-eth-contract/src/index.js'); 23 | 24 | // Set provider for all later instances to use 25 | Web3EthContract.setProvider('ws://localhost:8546'); 26 | 27 | const contract = new Web3EthContract(jsonInterface, address); 28 | contract.methods.somFunc().send({from: ....}) 29 | .on('receipt', function(){ 30 | ... 31 | }); 32 | ``` 33 | 34 | [docs]: http://web3js.readthedocs.io/en/1.0/ 35 | [repo]: https://github.com/ethereum/web3.js 36 | 37 | ## Types 38 | 39 | All the TypeScript typings are placed in the `types` folder. 40 | 41 | [docs]: http://web3js.readthedocs.io/en/1.0/ 42 | [repo]: https://github.com/ethereum/web3.js 43 | [npm-image]: https://img.shields.io/npm/v/web3-eth-contract.svg 44 | [npm-url]: https://npmjs.org/package/web3-eth-contract 45 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-eth-contract 46 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-eth-contract 47 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-eth-contract 48 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-eth-contract 49 | -------------------------------------------------------------------------------- /packages/web3-eth-contract/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-contract", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/bn.js": { 8 | "version": "4.11.6", 9 | "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", 10 | "integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", 11 | "requires": { 12 | "@types/node": "*" 13 | }, 14 | "dependencies": { 15 | "@types/node": { 16 | "version": "16.11.1", 17 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.1.tgz", 18 | "integrity": "sha512-PYGcJHL9mwl1Ek3PLiYgyEKtwTMmkMw4vbiyz/ps3pfdRYLVv+SN7qHVAImrjdAXxgluDEw6Ph4lyv+m9UpRmA==" 19 | } 20 | } 21 | }, 22 | "typescript": { 23 | "version": "3.9.10", 24 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 25 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 26 | "dev": true 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/web3-eth-contract/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-contract", 3 | "version": "1.7.0", 4 | "description": "Web3 module to interact with Ethereum smart contracts.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-contract", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "@types/bn.js": "^4.11.5", 18 | "web3-core": "1.7.0", 19 | "web3-core-helpers": "1.7.0", 20 | "web3-core-method": "1.7.0", 21 | "web3-core-promievent": "1.7.0", 22 | "web3-core-subscriptions": "1.7.0", 23 | "web3-eth-abi": "1.7.0", 24 | "web3-utils": "1.7.0" 25 | }, 26 | "devDependencies": { 27 | "dtslint": "^3.4.1", 28 | "typescript": "^3.9.5" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/web3-eth-contract/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-eth-contract/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-eth-contract": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-eth-contract/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "no-empty-interface": false, 10 | "unified-signatures": false, 11 | "no-redundant-jsdoc": false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/web3-eth-ens/README.md: -------------------------------------------------------------------------------- 1 | # web3-eth-ens 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the contract package to be used in the `web3-eth` package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-eth-ens 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const eth = new Web3Eth(web3.currentProvider); 23 | const ens = new EthEns(eth); 24 | 25 | ens.getAddress('ethereum.eth').then(function(result) { 26 | console.log(result); 27 | }); 28 | ``` 29 | 30 | ## Types 31 | 32 | All the TypeScript typings are placed in the `types` folder. 33 | 34 | [docs]: http://web3js.readthedocs.io/en/1.0/ 35 | [repo]: https://github.com/ethereum/web3.js 36 | [npm-image]: https://img.shields.io/npm/v/web3-eth-ens.svg 37 | [npm-url]: https://npmjs.org/package/web3-eth-ens 38 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-eth-ens 39 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-eth-ens 40 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-eth-ens 41 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-eth-ens -------------------------------------------------------------------------------- /packages/web3-eth-ens/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-ens", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-eth-ens/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-ens", 3 | "version": "1.7.0", 4 | "description": "ENS support for web3.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-ens", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "content-hash": "^2.5.2", 18 | "eth-ens-namehash": "2.0.8", 19 | "web3-core": "1.7.0", 20 | "web3-core-helpers": "1.7.0", 21 | "web3-core-promievent": "1.7.0", 22 | "web3-eth-abi": "1.7.0", 23 | "web3-eth-contract": "1.7.0", 24 | "web3-utils": "1.7.0" 25 | }, 26 | "devDependencies": { 27 | "dtslint": "^3.4.1", 28 | "typescript": "^3.9.5", 29 | "web3-eth": "1.7.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/web3-eth-ens/src/config.js: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file config.js 16 | * 17 | * @author Samuel Furter 18 | * @date 2017 19 | */ 20 | 21 | 'use strict'; 22 | 23 | /** 24 | * Source: https://docs.ens.domains/ens-deployments 25 | * 26 | * @type {{addresses: {main: string, rinkeby: string, goerli: string, ropsten: string}}} 27 | */ 28 | const config = { 29 | addresses: { 30 | main: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', 31 | ropsten: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', 32 | rinkeby: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', 33 | goerli: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', 34 | }, 35 | // These ids obtained at ensdomains docs: 36 | // https://docs.ens.domains/contract-developer-guide/writing-a-resolver 37 | interfaceIds: { 38 | addr: '0x3b3b57de', 39 | setAddr: '0x3b3b57de', 40 | pubkey: '0xc8690233', 41 | setPubkey: '0xc8690233', 42 | contenthash: '0xbc1c58d1', 43 | setContenthash: '0xbc1c58d1', 44 | content: '0xd8389dc5', 45 | setContent: '0xd8389dc5', 46 | }, 47 | }; 48 | 49 | export default config; 50 | -------------------------------------------------------------------------------- /packages/web3-eth-ens/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file index.js 16 | * 17 | * @author Samuel Furter 18 | * @date 2018 19 | */ 20 | 21 | 'use strict'; 22 | 23 | import ENS from './ENS.js'; 24 | 25 | export default ENS; 26 | -------------------------------------------------------------------------------- /packages/web3-eth-ens/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-eth-ens/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-eth-ens": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-eth-ens/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "no-empty-interface": false, 10 | "unified-signatures": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/web3-eth-iban/README.md: -------------------------------------------------------------------------------- 1 | # web3-eth-iban 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub package of [web3.js][repo] 6 | 7 | This is the IBAN package to be used in the `web3-eth` package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-eth-iban 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3EthIban = require('https://deno.land/x/web3@v0.9.2/packages/web3-eth-iban/src/index.js'); 23 | 24 | const iban = new Web3EthIban('XE75JRZCTTLBSYEQBGAS7GID8DKR7QY0QA3'); 25 | iban.toAddress() > '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B'; 26 | ``` 27 | 28 | [docs]: http://web3js.readthedocs.io/en/1.0/ 29 | [repo]: https://github.com/ethereum/web3.js 30 | 31 | ## Types 32 | 33 | All the TypeScript typings are placed in the `types` folder. 34 | 35 | [docs]: http://web3js.readthedocs.io/en/1.0/ 36 | [repo]: https://github.com/ethereum/web3.js 37 | [npm-image]: https://img.shields.io/npm/v/web3-eth-iban.svg 38 | [npm-url]: https://npmjs.org/package/web3-eth-iban 39 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-eth-iban 40 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-eth-iban 41 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-eth-iban 42 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=web3-eth-iban 43 | -------------------------------------------------------------------------------- /packages/web3-eth-iban/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-iban", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-eth-iban/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-iban", 3 | "version": "1.7.0", 4 | "description": "This package converts Ethereum addresses to IBAN addresses a vice versa.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-iban", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "bn.js": "^4.11.9", 18 | "web3-utils": "1.7.0" 19 | }, 20 | "devDependencies": { 21 | "dtslint": "^3.4.1", 22 | "typescript": "^3.9.5" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/web3-eth-iban/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-eth-iban/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file index.d.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | export class Iban { 24 | constructor( 25 | iban: string 26 | ) 27 | 28 | static toAddress(iban: string): string; 29 | 30 | static toIban(address: string): string; 31 | 32 | static fromAddress(address: string): Iban; 33 | 34 | static fromBban(bban: string): Iban; 35 | 36 | static createIndirect(options: IndirectOptions): Iban; 37 | 38 | static isValid(iban: string): boolean; 39 | 40 | isValid(): boolean; 41 | 42 | isDirect(): boolean; 43 | 44 | isIndirect(): boolean; 45 | 46 | checksum(): string; 47 | 48 | institution(): string; 49 | 50 | client(): string; 51 | 52 | toAddress(): string; 53 | 54 | toString(): string; 55 | } 56 | 57 | export interface IndirectOptions { 58 | institution: string; 59 | identifier: string; 60 | } 61 | -------------------------------------------------------------------------------- /packages/web3-eth-iban/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-eth-iban": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-eth-iban/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/web3-eth-personal/README.md: -------------------------------------------------------------------------------- 1 | # web3-eth-personal 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the personal package used in the `web3-eth` package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-eth-personal 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3EthPersonal = require('https://deno.land/x/web3@v0.9.2/packages/web3-eth-personal/src/index.js'); 23 | 24 | const personal = new Web3EthPersonal('ws://localhost:8546'); 25 | ``` 26 | 27 | ## Types 28 | 29 | All the TypeScript typings are placed in the `types` folder. 30 | 31 | [docs]: http://web3js.readthedocs.io/en/1.0/ 32 | [repo]: https://github.com/ethereum/web3.js 33 | [npm-image]: https://img.shields.io/npm/v/web3-eth-personal.svg 34 | [npm-url]: https://npmjs.org/package/web3-eth-personal 35 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-eth-personal 36 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-eth-personal 37 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-eth-personal 38 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-eth-personal 39 | -------------------------------------------------------------------------------- /packages/web3-eth-personal/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-personal", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "12.20.33", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.33.tgz", 10 | "integrity": "sha512-5XmYX2GECSa+CxMYaFsr2mrql71Q4EvHjKS+ox/SiwSdaASMoBIWE6UmZqFO+VX1jIcsYLStI4FFoB6V7FeIYw==" 11 | }, 12 | "typescript": { 13 | "version": "3.9.10", 14 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 15 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 16 | "dev": true 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/web3-eth-personal/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth-personal", 3 | "version": "1.7.0", 4 | "description": "Web3 module to interact with the Ethereum blockchain accounts stored in the node.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-personal", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "@types/node": "^12.12.6", 18 | "web3-core": "1.7.0", 19 | "web3-core-helpers": "1.7.0", 20 | "web3-core-method": "1.7.0", 21 | "web3-net": "1.7.0", 22 | "web3-utils": "1.7.0" 23 | }, 24 | "devDependencies": { 25 | "dtslint": "^3.4.1", 26 | "typescript": "^3.9.5" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/web3-eth-personal/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-eth-personal/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-eth-personal": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-eth-personal/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/web3-eth/README.md: -------------------------------------------------------------------------------- 1 | # web3-eth 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This Eth package is used within some [web3.js][repo] packages. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-eth 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3Eth = require('https://deno.land/x/web3@v0.9.2/packages/web3-eth/src/index.js'); 23 | 24 | const eth = new Web3Eth('ws://localhost:8546'); 25 | ``` 26 | 27 | ## Types 28 | 29 | All the TypeScript typings are placed in the `types` folder. 30 | 31 | [docs]: http://web3js.readthedocs.io/en/1.0/ 32 | [repo]: https://github.com/ethereum/web3-eth.js 33 | [npm-image]: https://img.shields.io/npm/v/web3-eth.svg 34 | [npm-url]: https://npmjs.org/package/web3-eth 35 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-eth 36 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-eth 37 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-eth 38 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-eth 39 | -------------------------------------------------------------------------------- /packages/web3-eth/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-eth/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth", 3 | "version": "1.7.0", 4 | "description": "Web3 module to interact with the Ethereum blockchain and smart contracts.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "web3-core": "1.7.0", 18 | "web3-core-helpers": "1.7.0", 19 | "web3-core-method": "1.7.0", 20 | "web3-core-subscriptions": "1.7.0", 21 | "web3-eth-abi": "1.7.0", 22 | "web3-eth-accounts": "1.7.0", 23 | "web3-eth-contract": "1.7.0", 24 | "web3-eth-ens": "1.7.0", 25 | "web3-eth-iban": "1.7.0", 26 | "web3-eth-personal": "1.7.0", 27 | "web3-net": "1.7.0", 28 | "web3-utils": "1.7.0" 29 | }, 30 | "devDependencies": { 31 | "dtslint": "^3.4.1", 32 | "typescript": "^3.9.5" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/web3-eth/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-eth/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-eth": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-eth/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env", 4 | "@babel/preset-typescript" 5 | ], 6 | "plugins": [ 7 | "@babel/plugin-proposal-class-properties", 8 | "@babel/plugin-transform-runtime" 9 | ] 10 | } -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: lodestar-docker lighthouse-docker 2 | 3 | lodestar-docker: 4 | docker run --network host chainsafe/lodestar beacon --testnet medalla --api.rest.enabled true 5 | 6 | lighthouse-docker: 7 | docker run -p 9000:9000 -p 127.0.0.1:5052:5052 -v ${HOME}/.lighthouse:/root/.lighthouse sigp/lighthouse lighthouse --network mainnet beacon --http --http-address 0.0.0.0 8 | -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/babel.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | presets: [ 3 | [ 4 | '@babel/preset-env', 5 | { 6 | targets: { 7 | node: 'current', 8 | }, 9 | }, 10 | ], 11 | ], 12 | env: { 13 | test: { 14 | plugins: ['@babel/plugin-transform-runtime'], 15 | }, 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth2-beaconchain", 3 | "version": "1.7.0", 4 | "description": "Web3 ETH2 Beacon chain API wrappers.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth2-beaconchain", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types.ts", 11 | "scripts": { 12 | "test": "jest", 13 | "compile": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline", 14 | "type-check": "tsc --noEmit", 15 | "type-check:watch": "npm run type-check -- --watch" 16 | }, 17 | "main": "lib/index.js", 18 | "dependencies": { 19 | "web3-eth2-core": "1.7.0" 20 | }, 21 | "devDependencies": { 22 | "@babel/cli": "^7.12.10", 23 | "@babel/core": "^7.12.10", 24 | "@babel/plugin-proposal-class-properties": "^7.12.1", 25 | "@babel/plugin-transform-runtime": "^7.12.10", 26 | "@babel/preset-env": "^7.12.11", 27 | "@babel/preset-typescript": "^7.12.7", 28 | "@babel/runtime": "^7.12.5", 29 | "@chainsafe/lodestar-types": "^0.13.0", 30 | "@types/jest": "^26.0.14", 31 | "@types/node": "^14.11.2", 32 | "babel-jest": "^26.6.3", 33 | "jest": "^26.4.2", 34 | "typescript": "^4.0.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ETH2Core, BaseAPISchema, ETH2BaseOpts } from 'https://deno.land/x/web3@v0.9.2/packages/web3-eth2-core/src/index.js'; 2 | import { DefaultSchema } from './schema.ts'; 3 | 4 | import { ETH2BeaconChain as IETH2BeaconChain } from '../types.ts'; 5 | 6 | // @ts-ignore - ETH2BeaconChain incorrectly implements interface IETH2BeaconChain 7 | // because methods are added during runtime 8 | export class ETH2BeaconChain extends ETH2Core implements IETH2BeaconChain { 9 | constructor( 10 | provider: string, 11 | schema: BaseAPISchema = DefaultSchema, 12 | opts: ETH2BaseOpts = { protectProvider: true }, 13 | ) { 14 | super(provider, schema, opts); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/test/constructor.test.ts: -------------------------------------------------------------------------------- 1 | import { ETH2BeaconChain } from '../src/index' 2 | 3 | const provider = 'http://127.0.0.1:9596' 4 | const providerSuffix = '/eth/v1/beacon/' 5 | 6 | it('constructs a ETH2BeaconChain instance with expected properties', () => { 7 | const eth2BeaconChain = new ETH2BeaconChain(provider) 8 | expect(eth2BeaconChain.name).toBe('eth2-beaconchain') 9 | expect(eth2BeaconChain.provider).toBe(`${provider}${providerSuffix}`) 10 | expect(eth2BeaconChain.protectProvider) 11 | }) 12 | -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false, 10 | "no-redundant-jsdoc": false, 11 | "interface-name": [true, "always-prefix"] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/web3-eth2-beaconchain/types.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Slot, 3 | Root, 4 | Genesis, 5 | Fork, 6 | FinalityCheckpoints, 7 | Validator, 8 | ValidatorResponse, 9 | ValidatorBalance, 10 | Epoch, 11 | BeaconCommitteeResponse, 12 | SignedBeaconHeaderResponse, 13 | Attestation, 14 | CommitteeIndex, 15 | IndexedAttestation, 16 | ProposerSlashing, 17 | SignedVoluntaryExit, 18 | } from '@chainsafe/lodestar-types'; 19 | 20 | export type StateId = 'head' | 'genesis' | 'finalized' | 'justified' | Slot | Root 21 | export type BlockId = 'head' | 'genesis' | 'finalized' | Slot | Root 22 | 23 | export interface ETH2BeaconChain { 24 | getGenesis(): Promise 25 | getHashRoot(params: {stateId: StateId}): Promise<{ root: Root }> 26 | getForkData(params: {stateId: StateId}): Promise 27 | getFinalityCheckpoint(params: {stateId: StateId}): Promise 28 | getValidators(params: {stateId: StateId}): Promise 29 | getValidatorById(params: {stateId: StateId, validatorId: string}): Promise 30 | getValidatorBalances(params: {stateId: StateId}): Promise 31 | getEpochCommittees(params: {stateId: StateId, epoch: Epoch}): Promise 32 | getBlockHeaders(): Promise 33 | getBlockHeader(params: {blockId: BlockId}): Promise 34 | publishSignedBlock(): Promise 35 | getBlock(params: {blockId: BlockId}): Promise 36 | getBlockRoot(params: {blockId: BlockId}): Promise 37 | getBlockAttestations(params: {blockId: BlockId}): Promise 38 | getAttestationsFromPool(params: {slot: Slot, committee_index: CommitteeIndex}): Promise 39 | submitAttestation(): Promise 40 | getAttesterSlashings(): Promise<{ [index: string]: IndexedAttestation }> 41 | submitAttesterSlashings(): Promise 42 | getProposerSlashings(): Promise 43 | submitProposerSlashings(): Promise 44 | getSignedVoluntaryExits(): Promise 45 | submitVoluntaryExit(): Promise 46 | } 47 | -------------------------------------------------------------------------------- /packages/web3-eth2-core/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env", 4 | "@babel/preset-typescript" 5 | ], 6 | "plugins": [ 7 | "@babel/plugin-proposal-class-properties" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-eth2-core/babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"] 3 | } -------------------------------------------------------------------------------- /packages/web3-eth2-core/jest.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | roots: ['/test'], 3 | transform: { 4 | '^.+\\.tsx?$': 'ts-jest', 5 | }, 6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', 7 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 8 | }; 9 | -------------------------------------------------------------------------------- /packages/web3-eth2-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-eth2-core", 3 | "version": "1.7.0", 4 | "description": "Web3 ETH2 core tools for sub-packages. This is an internal package.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth2-core", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types.ts", 11 | "scripts": { 12 | "test": "jest", 13 | "compile": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline", 14 | "type-check": "tsc --noEmit", 15 | "type-check:watch": "npm run type-check -- --watch" 16 | }, 17 | "main": "lib/index.js", 18 | "dependencies": { 19 | "axios": "^0.21.1" 20 | }, 21 | "devDependencies": { 22 | "@babel/cli": "^7.12.10", 23 | "@babel/core": "^7.12.10", 24 | "@babel/plugin-proposal-class-properties": "^7.12.1", 25 | "@babel/preset-env": "^7.12.11", 26 | "@babel/preset-typescript": "^7.12.7", 27 | "@types/jest": "^26.0.14", 28 | "@types/node": "^14.14.22", 29 | "jest": "^26.5.3", 30 | "ts-jest": "^26.4.4", 31 | "typescript": "^3.9.7" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/web3-eth2-core/test/constructor.test.ts: -------------------------------------------------------------------------------- 1 | import { ETH2Core } from '../src/index' 2 | 3 | const provider = 'http://127.0.0.1:9596' 4 | const testAPISchema = { 5 | packageName: 'testValue', 6 | routePrefix: '/test/route/', 7 | methods: [ 8 | { 9 | name: 'testMethod', 10 | route: 'additional/route', 11 | restMethod: 'get', 12 | inputFormatter: null, 13 | outputFormatter: null, 14 | errors: null, 15 | errorPrefix: 'Test error prefix:' 16 | } 17 | ] 18 | } 19 | 20 | it('constructs a ETH2Core instance with expected properties', () => { 21 | // @ts-ignore using a mock schema for test 22 | const eth2Core = new ETH2Core(provider, testAPISchema, { protectProvider: true }) 23 | 24 | expect(eth2Core.name).toBe(testAPISchema.packageName) 25 | expect(eth2Core.provider).toBe(`${provider}${testAPISchema.routePrefix}`) 26 | expect(eth2Core.protectProvider) 27 | expect(eth2Core.testMethod).toBeDefined() 28 | }) 29 | -------------------------------------------------------------------------------- /packages/web3-eth2-core/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false, 10 | "no-redundant-jsdoc": false, 11 | "interface-name": [true, "always-prefix"] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/web3-eth2-core/types.ts: -------------------------------------------------------------------------------- 1 | import { AxiosInstance } from 'https://jspm.dev/axios'; 2 | 3 | export interface ETH2BaseOpts { 4 | protectProvider?: boolean 5 | } 6 | 7 | export type ETH2Function = (...args: any[]) => Promise; 8 | 9 | export interface BaseAPISchemaMethod { 10 | notImplemented?: true, 11 | name: string, 12 | route: string, 13 | restMethod: 'get' | 'post' 14 | inputFormatter: any, 15 | outputFormatter: any, 16 | errors: any 17 | errorPrefix: string 18 | } 19 | 20 | export interface BaseAPISchema { 21 | packageName: string, 22 | routePrefix: string, 23 | methods: BaseAPISchemaMethod[] 24 | } 25 | 26 | export declare class ETH2Core { 27 | private _httpClient; 28 | 29 | [key: string]: ETH2Function | any; 30 | 31 | name: string; 32 | 33 | provider: string | undefined; 34 | 35 | protectProvider: boolean; 36 | 37 | constructor(provider: string, schema: BaseAPISchema, opts?: ETH2BaseOpts); 38 | 39 | static createHttpClient(baseUrl: string): AxiosInstance; 40 | 41 | setProvider(provider: string): void; 42 | 43 | private routeBuilder; 44 | 45 | private buildAPIWrappersFromSchema; 46 | } 47 | -------------------------------------------------------------------------------- /packages/web3-net/README.md: -------------------------------------------------------------------------------- 1 | # web3-net 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This is the net package used in other [web3.js][repo] packages. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-net 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3Net = require('https://deno.land/x/web3@v0.9.2/packages/web3-net/src/index.js'); 23 | 24 | const net = new Web3Net('ws://localhost:8546'); 25 | ``` 26 | 27 | ## Types 28 | 29 | All the TypeScript typings are placed in the `types` folder. 30 | 31 | [docs]: http://web3js.readthedocs.io/en/1.0/ 32 | [repo]: https://github.com/ethereum/web3.js 33 | [npm-image]: https://img.shields.io/npm/v/web3-net.svg 34 | [npm-url]: https://npmjs.org/package/web3-net 35 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-net 36 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-net 37 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-net 38 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-net 39 | -------------------------------------------------------------------------------- /packages/web3-net/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-net", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-net/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-net", 3 | "version": "1.7.0", 4 | "description": "Web3 module to interact with the Ethereum nodes networking properties.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-net", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "web3-core": "1.7.0", 18 | "web3-core-method": "1.7.0", 19 | "web3-utils": "1.7.0" 20 | }, 21 | "devDependencies": { 22 | "dtslint": "^3.4.1", 23 | "typescript": "^3.9.5" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/web3-net/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file index.js 19 | * @author Fabian Vogelsteller 20 | * @date 2017 21 | */ 22 | 23 | 'use strict'; 24 | 25 | import core from 'https://deno.land/x/web3@v0.9.2/packages/web3-core/src/index.js'; 26 | import Method from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-method/src/index.js'; 27 | import utils from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 28 | 29 | const Net = function () { 30 | const _this = this; 31 | 32 | // sets _requestmanager 33 | core.packageInit(this, arguments); 34 | 35 | [ 36 | new Method({ 37 | name: 'getId', 38 | call: 'net_version', 39 | params: 0, 40 | outputFormatter: parseInt, 41 | }), 42 | new Method({ 43 | name: 'isListening', 44 | call: 'net_listening', 45 | params: 0, 46 | }), 47 | new Method({ 48 | name: 'getPeerCount', 49 | call: 'net_peerCount', 50 | params: 0, 51 | outputFormatter: utils.hexToNumber, 52 | }), 53 | ].forEach((method) => { 54 | method.attachToObject(_this); 55 | method.setRequestManager(_this._requestManager); 56 | }); 57 | }; 58 | 59 | core.addProviders(Net); 60 | 61 | export default Net; 62 | -------------------------------------------------------------------------------- /packages/web3-net/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-net/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | web3.js is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | web3.js is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | You should have received a copy of the GNU Lesser General Public License 12 | along with web3.js. If not, see . 13 | */ 14 | /** 15 | * @file index.d.ts 16 | * @author Josh Stevens 17 | * @date 2018 18 | */ 19 | 20 | import { NetworkBase } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core/types/index.d.ts'; 21 | 22 | export class Network extends NetworkBase {} 23 | -------------------------------------------------------------------------------- /packages/web3-net/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-net": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-net/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-providers-http/README.md: -------------------------------------------------------------------------------- 1 | # web3-providers-http 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a HTTP provider sub-package for [web3.js][repo]. 6 | 7 | Please read the [documentation][docs] for more. 8 | 9 | ## Installation 10 | 11 | ### Node.js 12 | 13 | ```bash 14 | npm install web3-providers-http 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | const http = require('https://jspm.dev/npm:@jspm/core@2/nodelibs/http'); 21 | const Web3HttpProvider = require('https://deno.land/x/web3@v0.9.2/packages/web3-providers-http/src/index.js'); 22 | 23 | const options = { 24 | keepAlive: true, 25 | timeout: 20000, // milliseconds, 26 | headers: [{name: 'Access-Control-Allow-Origin', value: '*'},{...}], 27 | withCredentials: false, 28 | agent: {http: http.Agent(...), baseUrl: ''} 29 | }; 30 | 31 | const provider = new Web3HttpProvider('http://localhost:8545', options); 32 | ``` 33 | 34 | ## Types 35 | 36 | All the TypeScript typings are placed in the `types` folder. 37 | 38 | [docs]: http://web3js.readthedocs.io/en/1.0/ 39 | [repo]: https://github.com/ethereum/web3.js 40 | [npm-image]: https://img.shields.io/npm/dm/web3-providers-http.svg 41 | [npm-url]: https://npmjs.org/package/web3-providers-http 42 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-providers-http 43 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-providers-http 44 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-providers-http 45 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-providers-http 46 | -------------------------------------------------------------------------------- /packages/web3-providers-http/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-providers-http", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-providers-http/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-providers-http", 3 | "version": "1.7.0", 4 | "description": "Module to handle web3 RPC connections over HTTP.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-http", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "scripts": { 11 | "compile": "tsc -b tsconfig.json", 12 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 13 | }, 14 | "types": "types/index.d.ts", 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "web3-core-helpers": "1.7.0", 18 | "xhr2-cookies": "1.1.0" 19 | }, 20 | "devDependencies": { 21 | "dtslint": "^3.4.1", 22 | "typescript": "^3.9.5" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/web3-providers-http/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-providers-http/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file index.d.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | import * as http from 'https://deno.land/x/web3/types/http.d.ts'; 23 | import * as https from 'https://deno.land/x/web3/types/http.d.ts'; 24 | 25 | import { HttpProviderBase, JsonRpcResponse } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/types/index.d.ts'; 26 | 27 | export interface HttpHeader { 28 | name: string; 29 | value: string; 30 | } 31 | 32 | export interface HttpProviderAgent { 33 | baseUrl?: string; 34 | http?: http.Agent; 35 | https?: https.Agent; 36 | } 37 | 38 | export interface HttpProviderOptions { 39 | withCredentials?: boolean; 40 | timeout?: number; 41 | headers?: HttpHeader[]; 42 | agent?: HttpProviderAgent; 43 | keepAlive?: boolean; 44 | } 45 | 46 | export class HttpProvider extends HttpProviderBase { 47 | host: string; 48 | 49 | withCredentials: boolean; 50 | 51 | timeout: number; 52 | 53 | headers?: HttpHeader[]; 54 | 55 | agent?: HttpProviderAgent; 56 | 57 | connected: boolean; 58 | 59 | constructor(host?: string, options?: HttpProviderOptions); 60 | 61 | send( 62 | payload: object, 63 | callback?: ( 64 | error: Error | null, 65 | result: JsonRpcResponse | undefined 66 | ) => void 67 | ): void; 68 | 69 | disconnect(): boolean; 70 | 71 | supportsSubscriptions(): boolean; 72 | } 73 | -------------------------------------------------------------------------------- /packages/web3-providers-http/types/tests/web3-provider-http-tests.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file web3-provider-http-tests.ts 19 | * @author Josh Stevens , Samuel Furter 20 | * @date 2018 21 | */ 22 | 23 | import * as http from 'https://deno.land/x/web3/types/http.d.ts'; 24 | import * as https from 'https://deno.land/x/web3/types/http.d.ts'; 25 | import { HttpProvider } from 'web3-providers'; 26 | import { JsonRpcResponse } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/src/index.js'; 27 | 28 | const httpProvider = new HttpProvider('http://localhost:8545', { 29 | timeout: 20000, 30 | headers: [ 31 | { 32 | name: 'Access-Control-Allow-Origin', 33 | value: '*', 34 | }, 35 | ], 36 | withCredentials: false, 37 | agent: { 38 | baseUrl: 'base', 39 | http: new http.Agent({}), 40 | https: new https.Agent({}), 41 | }, 42 | }); 43 | 44 | // $ExpectType void 45 | httpProvider.send({}, (error: Error | null) => {}); 46 | 47 | // $ExpectType void 48 | httpProvider.send({}, (error: Error | null, result: JsonRpcResponse | undefined) => {}); 49 | 50 | // $ExpectType boolean 51 | httpProvider.disconnect(); 52 | -------------------------------------------------------------------------------- /packages/web3-providers-http/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-providers": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-providers-http/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-providers-ipc/README.md: -------------------------------------------------------------------------------- 1 | # web3-providers-ipc 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is an IPC provider sub-package for [web3.js][repo]. 6 | 7 | Please read the [documentation][docs] for more. 8 | 9 | ## Installation 10 | 11 | ### Node.js 12 | 13 | ```bash 14 | npm install web3-providers-ipc 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | const Web3IpcProvider = require('https://deno.land/x/web3@v0.9.2/packages/web3-providers-ipc/src/index.js'); 21 | const net = require(net); 22 | 23 | const ipc = new Web3IpcProvider('/Users/me/Library/Ethereum/geth.ipc', net); 24 | ``` 25 | 26 | ## Types 27 | 28 | All the TypeScript typings are placed in the `types` folder. 29 | 30 | [docs]: http://web3js.readthedocs.io/en/1.0/ 31 | [repo]: https://github.com/ethereum/web3.js 32 | [npm-image]: https://img.shields.io/npm/v/web3-providers-ipc.svg 33 | [npm-url]: https://npmjs.org/package/web3-providers-ipc 34 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-providers-ipc 35 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-providers-ipc 36 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-providers-ipc 37 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-providers-ipc 38 | -------------------------------------------------------------------------------- /packages/web3-providers-ipc/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-providers-ipc", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "12.20.33", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.33.tgz", 10 | "integrity": "sha512-5XmYX2GECSa+CxMYaFsr2mrql71Q4EvHjKS+ox/SiwSdaASMoBIWE6UmZqFO+VX1jIcsYLStI4FFoB6V7FeIYw==", 11 | "dev": true 12 | }, 13 | "typescript": { 14 | "version": "3.9.10", 15 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 16 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 17 | "dev": true 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/web3-providers-ipc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-providers-ipc", 3 | "version": "1.7.0", 4 | "description": "Module to handle web3 RPC connections over IPC sockets.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ipc", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "scripts": { 11 | "compile": "tsc -b tsconfig.json", 12 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 13 | }, 14 | "types": "types/index.d.ts", 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "oboe": "2.1.5", 18 | "web3-core-helpers": "1.7.0" 19 | }, 20 | "devDependencies": { 21 | "@types/node": "^12.12.6", 22 | "dtslint": "^3.4.1", 23 | "typescript": "^3.9.5" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/web3-providers-ipc/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-providers-ipc/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file index.d.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import { IpcProviderBase } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/types/index.d.ts'; 24 | 25 | export class IpcProvider extends IpcProviderBase { } 26 | -------------------------------------------------------------------------------- /packages/web3-providers-ipc/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-providers": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-providers-ipc/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-providers-ws/README.md: -------------------------------------------------------------------------------- 1 | # web3-providers-ws 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a websocket provider sub-package for [web3.js][repo]. 6 | 7 | Please read the [documentation][docs] for more. 8 | 9 | ## Installation 10 | 11 | ### Node.js 12 | 13 | ```bash 14 | npm install web3-providers-ws 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | const Web3WsProvider = require('https://deno.land/x/web3@v0.9.2/packages/web3-providers-ws/src/index.js'); 21 | 22 | const options = { 23 | timeout: 30000, // ms 24 | 25 | // Useful for credentialed urls, e.g: ws://username:password@localhost:8546 26 | headers: { 27 | authorization: 'Basic username:password' 28 | }, 29 | 30 | clientConfig: { 31 | // Useful if requests are large 32 | maxReceivedFrameSize: 100000000, // bytes - default: 1MiB 33 | maxReceivedMessageSize: 100000000, // bytes - default: 8MiB 34 | 35 | // Useful to keep a connection alive 36 | keepalive: true, 37 | keepaliveInterval: 60000 // ms 38 | }, 39 | 40 | // Enable auto reconnection 41 | reconnect: { 42 | auto: true, 43 | delay: 5000, // ms 44 | maxAttempts: 5, 45 | onTimeout: false 46 | } 47 | }; 48 | 49 | const ws = new Web3WsProvider('ws://localhost:8546', options); 50 | ``` 51 | 52 | Additional client config options can be found [here](https://github.com/theturtle32/WebSocket-Node/blob/v1.0.31/docs/WebSocketClient.md#client-config-options). 53 | 54 | ## Types 55 | 56 | All the TypeScript typings are placed in the `types` folder. 57 | 58 | [docs]: http://web3js.readthedocs.io/en/1.0/ 59 | [repo]: https://github.com/ethereum/web3.js 60 | [npm-image]: https://img.shields.io/npm/v/web3-providers-ws.svg 61 | [npm-url]: https://npmjs.org/package/web3-providers-ws 62 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-providers-ws 63 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-providers-ws 64 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-providers-ws 65 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-providers-ws 66 | -------------------------------------------------------------------------------- /packages/web3-providers-ws/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-providers-ws", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-providers-ws/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-providers-ws", 3 | "version": "1.7.0", 4 | "description": "Module to handle web3 RPC connections over WebSockets.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ws", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "scripts": { 11 | "compile": "tsc -b tsconfig.json", 12 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 13 | }, 14 | "types": "types/index.d.ts", 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "eventemitter3": "4.0.4", 18 | "web3-core-helpers": "1.7.0", 19 | "websocket": "^1.0.32" 20 | }, 21 | "devDependencies": { 22 | "dtslint": "^3.4.1", 23 | "typescript": "^3.9.5" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/web3-providers-ws/src/helpers.js: -------------------------------------------------------------------------------- 1 | const isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; 2 | const isRN = typeof navigator !== 'undefined' && navigator.product === 'ReactNative'; 3 | 4 | let _btoa = null; 5 | let helpers = null; 6 | if (isNode || isRN) { 7 | _btoa = function (str) { 8 | return Buffer.from(str).toString('base64'); 9 | }; 10 | const url = require('url'); 11 | if (url.URL) { 12 | // Use the new Node 6+ API for parsing URLs that supports username/password 13 | const newURL = url.URL; 14 | helpers = function (url) { 15 | return new newURL(url); 16 | }; 17 | } else { 18 | // Web3 supports Node.js 5, so fall back to the legacy URL API if necessary 19 | helpers = require('url').parse; 20 | } 21 | } else { 22 | _btoa = btoa.bind(typeof globalThis === 'object' ? globalThis : self); 23 | helpers = function (url) { 24 | return new URL(url); 25 | }; 26 | } 27 | 28 | export default { 29 | parseURL: helpers, 30 | btoa: _btoa, 31 | }; 32 | -------------------------------------------------------------------------------- /packages/web3-providers-ws/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-providers-ws/types/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file index.d.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import { WebsocketProviderBase } from 'https://deno.land/x/web3@v0.9.2/packages/web3-core-helpers/types/index.d.ts'; 24 | 25 | export class WebsocketProvider extends WebsocketProviderBase { } 26 | -------------------------------------------------------------------------------- /packages/web3-providers-ws/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-providers": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-providers-ws/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-shh/README.md: -------------------------------------------------------------------------------- 1 | # web3-shh 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo] 6 | 7 | This is the whisper v5 package. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-shh 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3Personal = require('https://deno.land/x/web3@v0.9.2/packages/web3-shh/src/index.js'); 23 | 24 | const shh = new Web3Personal('ws://localhost:8546'); 25 | ``` 26 | 27 | ## Types 28 | 29 | All the TypeScript typings are placed in the `types` folder. 30 | 31 | [docs]: http://web3js.readthedocs.io/en/1.0/ 32 | [repo]: https://github.com/ethereum/web3.js 33 | [npm-image]: https://img.shields.io/npm/v/web3-shh.svg 34 | [npm-url]: https://npmjs.org/package/web3-shh 35 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-shh 36 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-shh 37 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-shh 38 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-shh 39 | -------------------------------------------------------------------------------- /packages/web3-shh/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-shh", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "12.20.33", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.33.tgz", 10 | "integrity": "sha512-5XmYX2GECSa+CxMYaFsr2mrql71Q4EvHjKS+ox/SiwSdaASMoBIWE6UmZqFO+VX1jIcsYLStI4FFoB6V7FeIYw==", 11 | "dev": true 12 | }, 13 | "typescript": { 14 | "version": "3.9.10", 15 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 16 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 17 | "dev": true 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/web3-shh/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-shh", 3 | "version": "1.7.0", 4 | "description": "Web3 module to interact with the Whisper messaging protocol.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-shh", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types", 14 | "postinstall": "echo \"WARNING: the web3-shh api will be deprecated in the next version\"" 15 | }, 16 | "main": "lib/index.js", 17 | "dependencies": { 18 | "web3-core": "1.7.0", 19 | "web3-core-method": "1.7.0", 20 | "web3-core-subscriptions": "1.7.0", 21 | "web3-net": "1.7.0" 22 | }, 23 | "devDependencies": { 24 | "@types/node": "^12.12.6", 25 | "dtslint": "^3.4.1", 26 | "typescript": "^3.9.5" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/web3-shh/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3-shh/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-shh": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-shh/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/web3-utils/README.md: -------------------------------------------------------------------------------- 1 | # web3-utils 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is a sub-package of [web3.js][repo]. 6 | 7 | This contains useful utility functions for Dapp developers. 8 | 9 | Please read the [documentation][docs] for more. 10 | 11 | ## Installation 12 | 13 | ### Node.js 14 | 15 | ```bash 16 | npm install web3-utils 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | const Web3Utils = require('https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'); 23 | console.log(Web3Utils); 24 | { 25 | sha3: function(){}, 26 | soliditySha3: function(){}, 27 | isAddress: function(){}, 28 | ... 29 | } 30 | ``` 31 | 32 | ## Types 33 | 34 | All the TypeScript typings are placed in the `types` folder. 35 | 36 | [docs]: http://web3js.readthedocs.io/en/1.0/ 37 | [repo]: https://github.com/ethereum/web3.js 38 | [npm-image]: https://img.shields.io/npm/v/web3-utils.svg 39 | [npm-url]: https://npmjs.org/package/web3-utils 40 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-utils 41 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-utils 42 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-utils 43 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-utils 44 | -------------------------------------------------------------------------------- /packages/web3-utils/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-utils", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "3.9.10", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 10 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/web3-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3-utils", 3 | "version": "1.7.0", 4 | "description": "Collection of utility functions used in web3.js.", 5 | "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-utils", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "types": "types/index.d.ts", 11 | "scripts": { 12 | "compile": "tsc -b tsconfig.json", 13 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "bn.js": "^4.11.9", 18 | "ethereum-bloom-filters": "^1.0.6", 19 | "ethereumjs-util": "^7.1.0", 20 | "ethjs-unit": "0.1.6", 21 | "number-to-bn": "1.7.0", 22 | "randombytes": "^2.1.0", 23 | "utf8": "3.0.0" 24 | }, 25 | "devDependencies": { 26 | "dtslint": "^3.4.1", 27 | "typescript": "^3.9.5" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/web3-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib", 5 | "esModuleInterop": true 6 | }, 7 | "include": [ 8 | "./src" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/ascii-to-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file ascii-to-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { asciiToHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | asciiToHex('I have 100!'); 28 | 29 | // $ExpectType string 30 | asciiToHex('I have 100!', 32); 31 | 32 | // $ExpectError 33 | asciiToHex(345); 34 | // $ExpectError 35 | asciiToHex(new BN(3)); 36 | // $ExpectError 37 | asciiToHex({}); 38 | // $ExpectError 39 | asciiToHex(true); 40 | // $ExpectError 41 | asciiToHex(['string']); 42 | // $ExpectError 43 | asciiToHex([4]); 44 | // $ExpectError 45 | asciiToHex(null); 46 | // $ExpectError 47 | asciiToHex(undefined); 48 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/bytes-to-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file bytes-to-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { bytesToHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | bytesToHex([72]); 28 | 29 | // $ExpectError 30 | bytesToHex(['string']); 31 | // $ExpectError 32 | bytesToHex(345); 33 | // $ExpectError 34 | bytesToHex(new BN(3)); 35 | // $ExpectError 36 | bytesToHex({}); 37 | // $ExpectError 38 | bytesToHex(true); 39 | // $ExpectError 40 | bytesToHex(['string']); 41 | // $ExpectError 42 | bytesToHex(null); 43 | // $ExpectError 44 | bytesToHex(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/encode-packed.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file solidity-sha3-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { encodePacked } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string | null 27 | encodePacked('234564535', '0xfff23243', true, -10); 28 | // $ExpectType string | null 29 | encodePacked('Hello!%'); 30 | // $ExpectType string | null 31 | encodePacked('234'); 32 | // $ExpectType string | null 33 | encodePacked(0xea); 34 | // $ExpectType string | null 35 | encodePacked(new BN(3)); 36 | // $ExpectType string | null 37 | encodePacked({ type: 'uint256', value: '234' }); 38 | // $ExpectType string | null 39 | encodePacked({ t: 'uint', v: new BN('234') }); 40 | // $ExpectType string | null 41 | encodePacked({ t: 'string', v: 'Hello!%' }, { t: 'int8', v: -23 }, { t: 'address', v: '0x85F43D8a49eeB85d32Cf465507DD71d507100C1d' }); 42 | // $ExpectType string | null 43 | encodePacked('0x407D73d8a49eeb85D32Cf465507dd71d507100c1'); 44 | 45 | // $ExpectError 46 | encodePacked(['hey']); 47 | // $ExpectError 48 | encodePacked([34]); 49 | // $ExpectError 50 | encodePacked(null); 51 | // $ExpectError 52 | encodePacked(undefined); 53 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/from-ascii-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file from-ascii-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { fromAscii } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | fromAscii('I have 100!'); 28 | 29 | // $ExpectError 30 | fromAscii(345); 31 | // $ExpectError 32 | fromAscii(new BN(3)); 33 | // $ExpectError 34 | fromAscii({}); 35 | // $ExpectError 36 | fromAscii(true); 37 | // $ExpectError 38 | fromAscii(['string']); 39 | // $ExpectError 40 | fromAscii([4]); 41 | // $ExpectError 42 | fromAscii(null); 43 | // $ExpectError 44 | fromAscii(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/from-decimal-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file from-decimal-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { fromDecimal } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | fromDecimal('232'); 28 | // $ExpectType string 29 | fromDecimal(232); 30 | 31 | // $ExpectError 32 | fromDecimal(new BN(3)); 33 | // $ExpectError 34 | fromDecimal(['string']); 35 | // $ExpectError 36 | fromDecimal([4]); 37 | // $ExpectError 38 | fromDecimal({}); 39 | // $ExpectError 40 | fromDecimal(true); 41 | // $ExpectError 42 | fromDecimal(null); 43 | // $ExpectError 44 | fromDecimal(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/from-utf8-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file from-utf8-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { fromUtf8 } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | fromUtf8('I have 100£'); 28 | 29 | // $ExpectError 30 | fromUtf8(232); 31 | // $ExpectError 32 | fromUtf8(new BN(3)); 33 | // $ExpectError 34 | fromUtf8(['string']); 35 | // $ExpectError 36 | fromUtf8([4]); 37 | // $ExpectError 38 | fromUtf8({}); 39 | // $ExpectError 40 | fromUtf8(true); 41 | // $ExpectError 42 | fromUtf8(null); 43 | // $ExpectError 44 | fromUtf8(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/from-wei-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file from-wei-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { fromWei } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | const bigNumber = new BN(3); 27 | 28 | // $ExpectType string 29 | fromWei(bigNumber); 30 | // $ExpectType string 31 | fromWei('1'); 32 | // $ExpectType string 33 | fromWei(bigNumber, 'ether'); 34 | // $ExpectType string 35 | fromWei('1', 'ether'); 36 | 37 | // $ExpectError 38 | fromWei(232); 39 | // $ExpectError 40 | fromWei(['string']); 41 | // $ExpectError 42 | fromWei([4]); 43 | // $ExpectError 44 | fromWei({}); 45 | // $ExpectError 46 | fromWei(true); 47 | // $ExpectError 48 | fromWei(null); 49 | // $ExpectError 50 | fromWei(undefined); 51 | // $ExpectError 52 | fromWei(new BN(3), 'blah'); 53 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/get-signature-params-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file get-signature-params-tests.ts 19 | * @author Aalok Singh 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { getSignatureParameters } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType { r: string; s: string; v: number; } 27 | getSignatureParameters( 28 | '0x90dc0e49b5a80eef86fcedcb863dcc727aeae5c11187c001fd3d18780ead2cc7701ba1986099a49164702f3d8b2c8dbbd45a6d1beb37d212d21fb1be4bb762a400', 29 | ); 30 | // $ExpectError 31 | getSignatureParameters(345); 32 | // $ExpectError 33 | getSignatureParameters(new BN(3)); 34 | // $ExpectError 35 | getSignatureParameters({}); 36 | // $ExpectError 37 | getSignatureParameters(true); 38 | // $ExpectError 39 | getSignatureParameters(['string']); 40 | // $ExpectError 41 | getSignatureParameters([4]); 42 | // $ExpectError 43 | getSignatureParameters(null); 44 | // $ExpectError 45 | getSignatureParameters(undefined); 46 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/get-unit-value-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file get-unit-value-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { getUnitValue } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | getUnitValue('ether'); 28 | 29 | // $ExpectError 30 | getUnitValue('fake'); 31 | // $ExpectError 32 | getUnitValue(656); 33 | // $ExpectError 34 | getUnitValue(new BN(3)); 35 | // $ExpectError 36 | getUnitValue(['string']); 37 | // $ExpectError 38 | getUnitValue([4]); 39 | // $ExpectError 40 | getUnitValue({}); 41 | // $ExpectError 42 | getUnitValue(true); 43 | // $ExpectError 44 | getUnitValue(null); 45 | // $ExpectError 46 | getUnitValue(undefined); 47 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/hex-to-ascii-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file hex-to-ascii-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { hexToAscii } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | hexToAscii('0x4920686176652031303021'); 28 | 29 | // $ExpectError 30 | hexToAscii(345); 31 | // $ExpectError 32 | hexToAscii(new BN(3)); 33 | // $ExpectError 34 | hexToAscii({}); 35 | // $ExpectError 36 | hexToAscii(true); 37 | // $ExpectError 38 | hexToAscii(['string']); 39 | // $ExpectError 40 | hexToAscii([4]); 41 | // $ExpectError 42 | hexToAscii(null); 43 | // $ExpectError 44 | hexToAscii(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/hex-to-bytes-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file hex-to-bytes-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { hexToBytes } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType number[] 27 | hexToBytes('0x000000ea'); 28 | // $ExpectType number[] 29 | hexToBytes(0x000000ea); 30 | 31 | // $ExpectError 32 | hexToBytes([4]); 33 | // $ExpectError 34 | hexToBytes(['string']); 35 | // $ExpectError 36 | hexToBytes(new BN(3)); 37 | // $ExpectError 38 | hexToBytes({}); 39 | // $ExpectError 40 | hexToBytes(true); 41 | // $ExpectError 42 | hexToBytes(null); 43 | // $ExpectError 44 | hexToBytes(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/hex-to-number-string-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file hex-to-number-string-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import {hexToNumberString} from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | hexToNumberString('0xea'); 28 | // $ExpectType string 29 | hexToNumberString(0xea); 30 | 31 | // $ExpectError 32 | hexToNumberString(new BN(3); 33 | // $ExpectError 34 | hexToNumberString(['string']); 35 | // $ExpectError 36 | hexToNumberString([4]); 37 | // $ExpectError 38 | hexToNumberString({}); 39 | // $ExpectError 40 | hexToNumberString(true); 41 | // $ExpectError 42 | hexToNumberString(null); 43 | // $ExpectError 44 | hexToNumberString(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/hex-to-number-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file hex-to-number-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { hexToNumber } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType number 27 | hexToNumber('232'); 28 | // $ExpectType number 29 | hexToNumber(232); 30 | 31 | // $ExpectError 32 | hexToNumber(new BN(3)); 33 | // $ExpectError 34 | hexToNumber(['string']); 35 | // $ExpectError 36 | hexToNumber([4]); 37 | // $ExpectError 38 | hexToNumber({}); 39 | // $ExpectError 40 | hexToNumber(true); 41 | // $ExpectError 42 | hexToNumber(null); 43 | // $ExpectError 44 | hexToNumber(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/hex-to-string-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file hex-to-string-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { hexToString } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | hexToString('0x49206861766520313030e282ac'); 28 | // $ExpectType string 29 | hexToString(0x49206861766520313030e282ac); 30 | 31 | // $ExpectError 32 | hexToString(new BN(3)); 33 | // $ExpectError 34 | hexToString(['string']); 35 | // $ExpectError 36 | hexToString([4]); 37 | // $ExpectError 38 | hexToString({}); 39 | // $ExpectError 40 | hexToString(true); 41 | // $ExpectError 42 | hexToString(null); 43 | // $ExpectError 44 | hexToString(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/hex-to-utf8-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file hex-to-utf8-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { hexToUtf8 } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | hexToUtf8('0x49206861766520313030e282ac'); 28 | 29 | // $ExpectError 30 | hexToUtf8(656); 31 | // $ExpectError 32 | hexToUtf8(new BN(3)); 33 | // $ExpectError 34 | hexToUtf8(['string']); 35 | // $ExpectError 36 | hexToUtf8([4]); 37 | // $ExpectError 38 | hexToUtf8({}); 39 | // $ExpectError 40 | hexToUtf8(true); 41 | // $ExpectError 42 | hexToUtf8(null); 43 | // $ExpectError 44 | hexToUtf8(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-big-number-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-big-number-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { isBigNumber } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType boolean 27 | isBigNumber(new BN(3)); 28 | 29 | // $ExpectError 30 | isBigNumber(7); 31 | // $ExpectError 32 | isBigNumber('4325'); 33 | // $ExpectError 34 | isBigNumber({}); 35 | // $ExpectError 36 | isBigNumber(true); 37 | // $ExpectError 38 | isBigNumber(['string']); 39 | // $ExpectError 40 | isBigNumber([4]); 41 | // $ExpectError 42 | isBigNumber(null); 43 | // $ExpectError 44 | isBigNumber(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-bloom-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-bloom-tests.ts 19 | * @author Josh Stevens 20 | * @date 2019 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { isBloom } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType boolean 27 | isBloom('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'); 28 | 29 | // $ExpectError 30 | isBloom(656); 31 | // $ExpectError 32 | isBloom(new BN(3)); 33 | // $ExpectError 34 | isBloom(['string']); 35 | // $ExpectError 36 | isBloom([4]); 37 | // $ExpectError 38 | isBloom({}); 39 | // $ExpectError 40 | isBloom(true); 41 | // $ExpectError 42 | isBloom(null); 43 | // $ExpectError 44 | isBloom(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-bn-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-bn-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { isBN } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType boolean 27 | isBN(7); 28 | // $ExpectType boolean 29 | isBN('4325'); 30 | 31 | // $ExpectError 32 | isBN({}); 33 | // $ExpectError 34 | isBN(true); 35 | // $ExpectError 36 | isBN(new BN(3)); 37 | // $ExpectError 38 | isBN(['string']); 39 | // $ExpectError 40 | isBN([4]); 41 | // $ExpectError 42 | isBN(null); 43 | // $ExpectError 44 | isBN(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-contract-address-in-bloom.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-contract-address-in-bloom.ts 19 | * @author Josh Stevens 20 | * @date 2019 21 | */ 22 | 23 | import { isContractAddressInBloom } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 24 | 25 | // $ExpectType boolean 26 | isContractAddressInBloom('0x08200081a06415012858022200cc48143008908c0000824e5405b41520795989024800380a8d4b198910b422b231086c3a62cc402e2573070306f180446440ad401016c3e30781115844d028c89028008a12240c0a2c184c0425b90d7af0530002f981221aa565809132000818c82805023a132a25150400010530ba0080420a10a137054454021882505080a6b6841082d84151010400ba8100c8802d440d060388084052c1300105a0868410648a40540c0f0460e190400807008914361118000a5202e94445ccc088311050052c8002807205212a090d90ba428030266024a910644b1042011aaae05391cc2094c45226400000380880241282ce4e12518c', '0x494bfa3a4576ba6cfe835b0deb78834f0c3e3994'); 27 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-hex-strict-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-hex-strict-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { isHexStrict } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType boolean 27 | isHexStrict('0xc1912'); 28 | // $ExpectType boolean 29 | isHexStrict(345); 30 | 31 | // $ExpectError 32 | isHexStrict(new BN(3)); 33 | // $ExpectError 34 | isHexStrict({}); 35 | // $ExpectError 36 | isHexStrict(true); 37 | // $ExpectError 38 | isHexStrict(['string']); 39 | // $ExpectError 40 | isHexStrict([4]); 41 | // $ExpectError 42 | isHexStrict(null); 43 | // $ExpectError 44 | isHexStrict(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { isHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType boolean 27 | isHex('0xc1912'); 28 | // $ExpectType boolean 29 | isHex(345); 30 | 31 | // $ExpectError 32 | isHex(new BN(3)); 33 | // $ExpectError 34 | isHex({}); 35 | // $ExpectError 36 | isHex(true); 37 | // $ExpectError 38 | isHex(['string']); 39 | // $ExpectError 40 | isHex([4]); 41 | // $ExpectError 42 | isHex(null); 43 | // $ExpectError 44 | isHex(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-in-bloom.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-in-bloom-tests.ts 19 | * @author Josh Stevens 20 | * @date 2019 21 | */ 22 | 23 | import { isInBloom } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 24 | 25 | // $ExpectType boolean 26 | isInBloom('0x08200081a06415012858022200cc48143008908c0000824e5405b41520795989024800380a8d4b198910b422b231086c3a62cc402e2573070306f180446440ad401016c3e30781115844d028c89028008a12240c0a2c184c0425b90d7af0530002f981221aa565809132000818c82805023a132a25150400010530ba0080420a10a137054454021882505080a6b6841082d84151010400ba8100c8802d440d060388084052c1300105a0868410648a40540c0f0460e190400807008914361118000a5202e94445ccc088311050052c8002807205212a090d90ba428030266024a910644b1042011aaae05391cc2094c45226400000380880241282ce4e12518c', '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'); 27 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-topic-in-bloom.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-topic-in-bloom.ts 19 | * @author Josh Stevens 20 | * @date 2019 21 | */ 22 | 23 | import { isTopicInBloom } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 24 | 25 | // $ExpectType boolean 26 | isTopicInBloom('0x08200081a06415012858022200cc48143008908c0000824e5405b41520795989024800380a8d4b198910b422b231086c3a62cc402e2573070306f180446440ad401016c3e30781115844d028c89028008a12240c0a2c184c0425b90d7af0530002f981221aa565809132000818c82805023a132a25150400010530ba0080420a10a137054454021882505080a6b6841082d84151010400ba8100c8802d440d060388084052c1300105a0868410648a40540c0f0460e190400807008914361118000a5202e94445ccc088311050052c8002807205212a090d90ba428030266024a910644b1042011aaae05391cc2094c45226400000380880241282ce4e12518c', '0x4d61726b65745061792e696f206973206465706c6f79696e6720536d61727420'); 27 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-topic-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-topic-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { isTopic } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType boolean 27 | isTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'); 28 | 29 | // $ExpectError 30 | isTopic(656); 31 | // $ExpectError 32 | isTopic(new BN(3)); 33 | // $ExpectError 34 | isTopic(['string']); 35 | // $ExpectError 36 | isTopic([4]); 37 | // $ExpectError 38 | isTopic({}); 39 | // $ExpectError 40 | isTopic(true); 41 | // $ExpectError 42 | isTopic(null); 43 | // $ExpectError 44 | isTopic(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-topic.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-user-ethereum-address-in-bloom.ts 19 | * @author Josh Stevens 20 | * @date 2019 21 | */ 22 | 23 | import { isTopic } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 24 | 25 | // $ExpectType boolean 26 | isTopic('0x000000000000000000000000b3bb037d2f2341a1c2775d51909a3d944597987d'); 27 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/is-user-ethereum-address-in-bloom.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file is-user-ethereum-address-in-bloom.ts 19 | * @author Josh Stevens 20 | * @date 2019 21 | */ 22 | 23 | import { isUserEthereumAddressInBloom } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 24 | 25 | // $ExpectType boolean 26 | isUserEthereumAddressInBloom('0x08200081a06415012858022200cc48143008908c0000824e5405b41520795989024800380a8d4b198910b422b231086c3a62cc402e2573070306f180446440ad401016c3e30781115844d028c89028008a12240c0a2c184c0425b90d7af0530002f981221aa565809132000818c82805023a132a25150400010530ba0080420a10a137054454021882505080a6b6841082d84151010400ba8100c8802d440d060388084052c1300105a0868410648a40540c0f0460e190400807008914361118000a5202e94445ccc088311050052c8002807205212a090d90ba428030266024a910644b1042011aaae05391cc2094c45226400000380880241282ce4e12518c', '0x494bfa3a4576ba6cfe835b0deb78834f0c3e3994'); 27 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/keccak256-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file keccak256-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { keccak256 } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | keccak256('234'); 28 | // $ExpectType string 29 | keccak256(new BN(3)); 30 | 31 | // $ExpectError 32 | keccak256(['string']); 33 | // $ExpectError 34 | keccak256(234); 35 | // $ExpectError 36 | keccak256([4]); 37 | // $ExpectError 38 | keccak256({}); 39 | // $ExpectError 40 | keccak256(true); 41 | // $ExpectError 42 | keccak256(null); 43 | // $ExpectError 44 | keccak256(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/left-pad-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file left-pad-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { leftPad } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | const bigNumber = new BN(3); 27 | // $ExpectType string 28 | leftPad('0x3456ff', 20); 29 | // $ExpectType string 30 | leftPad(0x3456ff, 20); 31 | // $ExpectType string 32 | leftPad('Hello', 20, 'x'); 33 | 34 | // $ExpectError 35 | leftPad(bigNumber, 20); 36 | // $ExpectError 37 | leftPad(['string'], 20); 38 | // $ExpectError 39 | leftPad([4], 20); 40 | // $ExpectError 41 | leftPad({}, 20); 42 | // $ExpectError 43 | leftPad(true, 20); 44 | // $ExpectError 45 | leftPad(null, 20); 46 | // $ExpectError 47 | leftPad(undefined, 20); 48 | // $ExpectError 49 | leftPad('0x3456ff', bigNumber); 50 | // $ExpectError 51 | leftPad('0x3456ff', ['string']); 52 | // $ExpectError 53 | leftPad('0x3456ff', [4]); 54 | // $ExpectError 55 | leftPad('0x3456ff', {}); 56 | // $ExpectError 57 | leftPad('0x3456ff', true); 58 | // $ExpectError 59 | leftPad('0x3456ff', null); 60 | // $ExpectError 61 | leftPad('0x3456ff', undefined); 62 | // $ExpectError 63 | leftPad('Hello', 20, bigNumber); 64 | // $ExpectError 65 | leftPad('Hello', 20, ['string']); 66 | // $ExpectError 67 | leftPad('Hello', 20, [4]); 68 | // $ExpectError 69 | leftPad('Hello', 20, {}); 70 | // $ExpectError 71 | leftPad('Hello', 20, true); 72 | // $ExpectError 73 | leftPad('Hello', 20, null); 74 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/number-to-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file number-to-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { numberToHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | numberToHex('232'); 28 | // $ExpectType string 29 | numberToHex(232); 30 | // $ExpectType string 31 | numberToHex(new BN(3)); 32 | 33 | // $ExpectError 34 | numberToHex(['72']); 35 | // $ExpectError 36 | numberToHex([4]); 37 | // $ExpectError 38 | numberToHex([36]); 39 | // $ExpectError 40 | numberToHex({}); 41 | // $ExpectError 42 | numberToHex(true); 43 | // $ExpectError 44 | numberToHex(null); 45 | // $ExpectError 46 | numberToHex(undefined); 47 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/pad-left-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file pad-left-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { padLeft } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | const bigNumber = new BN(3); 27 | 28 | // $ExpectType string 29 | padLeft('0x3456ff', 20); 30 | // $ExpectType string 31 | padLeft(0x3456ff, 20); 32 | // $ExpectType string 33 | padLeft('Hello', 20, 'x'); 34 | 35 | // $ExpectError 36 | padLeft(bigNumber, 20); 37 | // $ExpectError 38 | padLeft(['string'], 20); 39 | // $ExpectError 40 | padLeft([4], 20); 41 | // $ExpectError 42 | padLeft({}, 20); 43 | // $ExpectError 44 | padLeft(true, 20); 45 | // $ExpectError 46 | padLeft(null, 20); 47 | // $ExpectError 48 | padLeft(undefined, 20); 49 | // $ExpectError 50 | padLeft('0x3456ff', bigNumber); 51 | // $ExpectError 52 | padLeft('0x3456ff', ['string']); 53 | // $ExpectError 54 | padLeft('0x3456ff', [4]); 55 | // $ExpectError 56 | padLeft('0x3456ff', {}); 57 | // $ExpectError 58 | padLeft('0x3456ff', true); 59 | // $ExpectError 60 | padLeft('0x3456ff', null); 61 | // $ExpectError 62 | padLeft('0x3456ff', undefined); 63 | // $ExpectError 64 | padLeft('Hello', 20, bigNumber); 65 | // $ExpectError 66 | padLeft('Hello', 20, ['string']); 67 | // $ExpectError 68 | padLeft('Hello', 20, [4]); 69 | // $ExpectError 70 | padLeft('Hello', 20, {}); 71 | // $ExpectError 72 | padLeft('Hello', 20, true); 73 | // $ExpectError 74 | padLeft('Hello', 20, null); 75 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/random-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file random-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { randomHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | randomHex(32); 28 | 29 | // $ExpectError 30 | randomHex('234'); 31 | // $ExpectError 32 | randomHex(new BN(3)); 33 | // $ExpectError 34 | randomHex(['string']); 35 | // $ExpectError 36 | randomHex([4]); 37 | // $ExpectError 38 | randomHex({}); 39 | // $ExpectError 40 | randomHex(true); 41 | // $ExpectError 42 | randomHex(null); 43 | // $ExpectError 44 | randomHex(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/sha3-raw-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file sha3Raw-tests.ts 19 | * @author Samuel Furter 20 | * @date 2019 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { sha3Raw } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | sha3Raw('234'); 28 | // $ExpectType string 29 | sha3Raw(new BN(3)); 30 | 31 | // $ExpectError 32 | sha3Raw(['string']); 33 | // $ExpectError 34 | sha3Raw(234); 35 | // $ExpectError 36 | sha3Raw([4]); 37 | // $ExpectError 38 | sha3Raw({}); 39 | // $ExpectError 40 | sha3Raw(true); 41 | // $ExpectError 42 | sha3Raw(null); 43 | // $ExpectError 44 | sha3Raw(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/sha3-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file sha3-tests.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { sha3 } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string | null 27 | sha3('234'); 28 | // $ExpectType string | null 29 | sha3(new BN(3)); 30 | 31 | // $ExpectError 32 | sha3(['string']); 33 | // $ExpectError 34 | sha3(234); 35 | // $ExpectError 36 | sha3([4]); 37 | // $ExpectError 38 | sha3({}); 39 | // $ExpectError 40 | sha3(true); 41 | // $ExpectError 42 | sha3(null); 43 | // $ExpectError 44 | sha3(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/solidity-sha3-raw-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file solidity-sha3-raw-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { soliditySha3Raw } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | soliditySha3Raw('234564535', '0xfff23243', true, -10); 28 | // $ExpectType string 29 | soliditySha3Raw('Hello!%'); 30 | // $ExpectType string 31 | soliditySha3Raw('234'); 32 | // $ExpectType string 33 | soliditySha3Raw(0xea); 34 | // $ExpectType string 35 | soliditySha3Raw(new BN(3)); 36 | // $ExpectType string 37 | soliditySha3Raw({ type: 'uint256', value: '234' }); 38 | // $ExpectType string 39 | soliditySha3Raw({ t: 'uint', v: new BN('234') }); 40 | // $ExpectType string 41 | soliditySha3Raw({ t: 'string', v: 'Hello!%' }, { t: 'int8', v: -23 }, { t: 'address', v: '0x85F43D8a49eeB85d32Cf465507DD71d507100C1d' }); 42 | // $ExpectType string 43 | soliditySha3Raw('0x407D73d8a49eeb85D32Cf465507dd71d507100c1'); 44 | 45 | // $ExpectError 46 | soliditySha3Raw(['hey']); 47 | // $ExpectError 48 | soliditySha3Raw([34]); 49 | // $ExpectError 50 | soliditySha3Raw(null); 51 | // $ExpectError 52 | soliditySha3Raw(undefined); 53 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/solidity-sha3-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file solidity-sha3-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { soliditySha3 } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string | null 27 | soliditySha3('234564535', '0xfff23243', true, -10); 28 | // $ExpectType string | null 29 | soliditySha3('Hello!%'); 30 | // $ExpectType string | null 31 | soliditySha3('234'); 32 | // $ExpectType string | null 33 | soliditySha3(0xea); 34 | // $ExpectType string | null 35 | soliditySha3(new BN(3)); 36 | // $ExpectType string | null 37 | soliditySha3({ type: 'uint256', value: '234' }); 38 | // $ExpectType string | null 39 | soliditySha3({ t: 'uint', v: new BN('234') }); 40 | // $ExpectType string | null 41 | soliditySha3({ t: 'string', v: 'Hello!%' }, { t: 'int8', v: -23 }, { t: 'address', v: '0x85F43D8a49eeB85d32Cf465507DD71d507100C1d' }); 42 | // $ExpectType string | null 43 | soliditySha3('0x407D73d8a49eeb85D32Cf465507dd71d507100c1'); 44 | 45 | // $ExpectError 46 | soliditySha3(['hey']); 47 | // $ExpectError 48 | soliditySha3([34]); 49 | // $ExpectError 50 | soliditySha3(null); 51 | // $ExpectError 52 | soliditySha3(undefined); 53 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/string-to-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file string-to-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { stringToHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | stringToHex('I have 100£'); 28 | 29 | // $ExpectError 30 | stringToHex(232); 31 | // $ExpectError 32 | stringToHex(new BN(3)); 33 | // $ExpectError 34 | stringToHex(['string']); 35 | // $ExpectError 36 | stringToHex([4]); 37 | // $ExpectError 38 | stringToHex({}); 39 | // $ExpectError 40 | stringToHex(true); 41 | // $ExpectError 42 | stringToHex(null); 43 | // $ExpectError 44 | stringToHex(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/strip-hex-prefix-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file strip-hex-prefix-test.ts 19 | * @author Alejandro Cavallero 20 | * @date 2019 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { stripHexPrefix } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | stripHexPrefix('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb'); 28 | 29 | // $ExpectError 30 | stripHexPrefix(123); 31 | // $ExpectError 32 | stripHexPrefix(new BN(3)); 33 | // $ExpectError 34 | stripHexPrefix(['string']); 35 | // $ExpectError 36 | stripHexPrefix([4]); 37 | // $ExpectError 38 | stripHexPrefix({}); 39 | // $ExpectError 40 | stripHexPrefix(true); 41 | // $ExpectError 42 | stripHexPrefix(null); 43 | // $ExpectError 44 | stripHexPrefix(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-ascii-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-ascii-tests.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { toAscii } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | toAscii('0x4920686176652031303021'); 28 | 29 | // $ExpectError 30 | toAscii(345); 31 | // $ExpectError 32 | toAscii(new BN(3)); 33 | // $ExpectError 34 | toAscii({}); 35 | // $ExpectError 36 | toAscii(true); 37 | // $ExpectError 38 | toAscii(['string']); 39 | // $ExpectError 40 | toAscii([4]); 41 | // $ExpectError 42 | toAscii(null); 43 | // $ExpectError 44 | toAscii(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-bn-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-bn-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import { toBN } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 24 | 25 | // $ExpectType BN 26 | toBN(4); 27 | // $ExpectType BN 28 | toBN('443'); 29 | 30 | // $ExpectError 31 | toBN({}); 32 | // $ExpectError 33 | toBN(true); 34 | // $ExpectError 35 | toBN(['string']); 36 | // $ExpectError 37 | toBN([4]); 38 | // $ExpectError 39 | toBN(null); 40 | // $ExpectError 41 | toBN(undefined); 42 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-decimal-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-decimal-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { toDecimal } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType number 27 | toDecimal('232'); 28 | // $ExpectType number 29 | toDecimal(232); 30 | 31 | // $ExpectError 32 | toDecimal(new BN(3)); 33 | // $ExpectError 34 | toDecimal(['string']); 35 | // $ExpectError 36 | toDecimal([4]); 37 | // $ExpectError 38 | toDecimal({}); 39 | // $ExpectError 40 | toDecimal(true); 41 | // $ExpectError 42 | toDecimal(null); 43 | // $ExpectError 44 | toDecimal(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { toHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | toHex('234'); 28 | // $ExpectType string 29 | toHex(234); 30 | // $ExpectType string 31 | toHex(new BN(3)); 32 | 33 | // $ExpectError 34 | toHex(['string']); 35 | // $ExpectError 36 | toHex(true); 37 | // $ExpectError 38 | toHex([4]); 39 | // $ExpectError 40 | toHex({}); 41 | // $ExpectError 42 | toHex(null); 43 | // $ExpectError 44 | toHex(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-number-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-number-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { toNumber } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType number 27 | toNumber('234'); 28 | // $ExpectType number 29 | toNumber(234); 30 | // $ExpectType number 31 | toNumber(new BN(3)); 32 | 33 | // $ExpectError 34 | toNumber(['string']); 35 | // $ExpectError 36 | toNumber(true); 37 | // $ExpectError 38 | toNumber([4]); 39 | // $ExpectError 40 | toNumber({}); 41 | // $ExpectError 42 | toNumber(null); 43 | // $ExpectError 44 | toNumber(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-twos-compement-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-twos-compement-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { toTwosComplement } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | toTwosComplement(4); 28 | // $ExpectType string 29 | toTwosComplement('443'); 30 | // $ExpectType string 31 | toTwosComplement(new BN(3)); 32 | 33 | // $ExpectError 34 | toTwosComplement({}); 35 | // $ExpectError 36 | toTwosComplement(true); 37 | // $ExpectError 38 | toTwosComplement(['string']); 39 | // $ExpectError 40 | toTwosComplement([4]); 41 | // $ExpectError 42 | toTwosComplement(null); 43 | // $ExpectError 44 | toTwosComplement(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-utf8-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-utf8-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { toUtf8 } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | toUtf8('0x49206861766520313030e282ac'); 28 | 29 | // $ExpectError 30 | toUtf8(656); 31 | // $ExpectError 32 | toUtf8(new BN(3)); 33 | // $ExpectError 34 | toUtf8(['string']); 35 | // $ExpectError 36 | toUtf8([4]); 37 | // $ExpectError 38 | toUtf8({}); 39 | // $ExpectError 40 | toUtf8(true); 41 | // $ExpectError 42 | toUtf8(null); 43 | // $ExpectError 44 | toUtf8(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/to-wei-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file to-wei-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { toWei } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | const bigNumber = new BN(3); 27 | 28 | // $ExpectType string 29 | toWei('1'); 30 | // $ExpectType BN 31 | toWei(bigNumber); 32 | // $ExpectType string 33 | toWei('1', 'finney'); 34 | // $ExpectType BN 35 | toWei(bigNumber, 'finney'); 36 | 37 | // $ExpectError 38 | toWei(['string']); 39 | // $ExpectError 40 | toWei([4]); 41 | // $ExpectError 42 | toWei({}); 43 | // $ExpectError 44 | toWei(true); 45 | // $ExpectError 46 | toWei(null); 47 | // $ExpectError 48 | toWei(undefined); 49 | // $ExpectError 50 | toWei(1, 'blah'); 51 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/unit-map-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file unit-map-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import { unitMap } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 24 | 25 | // $ExpectType Units 26 | unitMap(); 27 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tests/utf8-to-hex-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of web3.js. 3 | 4 | web3.js is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | web3.js is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with web3.js. If not, see . 16 | */ 17 | /** 18 | * @file utf8-to-hex-test.ts 19 | * @author Josh Stevens 20 | * @date 2018 21 | */ 22 | 23 | import BN = require('https://jspm.dev/bn.js'); 24 | import { utf8ToHex } from 'https://deno.land/x/web3@v0.9.2/packages/web3-utils/src/index.js'; 25 | 26 | // $ExpectType string 27 | utf8ToHex('I have 100£'); 28 | 29 | // $ExpectError 30 | utf8ToHex(232); 31 | // $ExpectError 32 | utf8ToHex(new BN(3)); 33 | // $ExpectError 34 | utf8ToHex(['string']); 35 | // $ExpectError 36 | utf8ToHex([4]); 37 | // $ExpectError 38 | utf8ToHex({}); 39 | // $ExpectError 40 | utf8ToHex(true); 41 | // $ExpectError 42 | utf8ToHex(null); 43 | // $ExpectError 44 | utf8ToHex(undefined); 45 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3-utils": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3-utils/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-redundant-jsdoc": false, 9 | "max-line-length": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/web3/README.md: -------------------------------------------------------------------------------- 1 | # web3 2 | 3 | [![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] 4 | 5 | This is the main package of [web3.js][repo]. 6 | 7 | Please read the main [README][repo-readme] and [documentation][docs] for more. 8 | 9 | ## Installation 10 | 11 | ### Node.js 12 | 13 | ```bash 14 | npm install web3 15 | ``` 16 | 17 | ## Types 18 | 19 | All the TypeScript typings are placed in the `types` folder. 20 | 21 | [docs]: http://web3js.readthedocs.io/en/1.0/ 22 | [repo]: https://github.com/ethereum/web3.js 23 | [repo-readme]: https://github.com/ethereum/web3.js/blob/1.x/README.md 24 | [npm-image]: https://img.shields.io/npm/v/web3.svg 25 | [npm-url]: https://npmjs.org/package/web3 26 | [deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3 27 | [deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3 28 | [deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3 29 | [deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3 -------------------------------------------------------------------------------- /packages/web3/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3", 3 | "version": "1.7.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "12.20.33", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.33.tgz", 10 | "integrity": "sha512-5XmYX2GECSa+CxMYaFsr2mrql71Q4EvHjKS+ox/SiwSdaASMoBIWE6UmZqFO+VX1jIcsYLStI4FFoB6V7FeIYw==", 11 | "dev": true 12 | }, 13 | "typescript": { 14 | "version": "3.9.10", 15 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 16 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 17 | "dev": true 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/web3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3", 3 | "version": "1.7.0", 4 | "description": "Ethereum JavaScript API", 5 | "repository": "https://github.com/ethereum/web3.js", 6 | "license": "LGPL-3.0", 7 | "engines": { 8 | "node": ">=8.0.0" 9 | }, 10 | "main": "lib/index.js", 11 | "bugs": { 12 | "url": "https://github.com/ethereum/web3.js/issues" 13 | }, 14 | "keywords": [ 15 | "Ethereum", 16 | "JavaScript", 17 | "API" 18 | ], 19 | "author": "ethereum.org", 20 | "types": "types/index.d.ts", 21 | "scripts": { 22 | "compile": "tsc -b tsconfig.json", 23 | "dtslint": "dtslint --localTs ../../node_modules/typescript/lib types", 24 | "postinstall": "echo \"WARNING: the web3-shh and web3-bzz api will be deprecated in the next version\"" 25 | }, 26 | "authors": [ 27 | { 28 | "name": "Fabian Vogelsteller", 29 | "email": "fabian@ethereum.org", 30 | "homepage": "http://frozeman.de" 31 | }, 32 | { 33 | "name": "Marek Kotewicz", 34 | "email": "marek@parity.io", 35 | "url": "https://github.com/debris" 36 | }, 37 | { 38 | "name": "Marian Oancea", 39 | "url": "https://github.com/cubedro" 40 | }, 41 | { 42 | "name": "Gav Wood", 43 | "email": "g@parity.io", 44 | "homepage": "http://gavwood.com" 45 | }, 46 | { 47 | "name": "Jeffery Wilcke", 48 | "email": "jeffrey.wilcke@ethereum.org", 49 | "url": "https://github.com/obscuren" 50 | } 51 | ], 52 | "dependencies": { 53 | "web3-bzz": "1.7.0", 54 | "web3-core": "1.7.0", 55 | "web3-eth": "1.7.0", 56 | "web3-eth-personal": "1.7.0", 57 | "web3-net": "1.7.0", 58 | "web3-shh": "1.7.0", 59 | "web3-utils": "1.7.0" 60 | }, 61 | "devDependencies": { 62 | "@types/node": "^12.12.6", 63 | "dtslint": "^3.4.1", 64 | "typescript": "^3.9.5", 65 | "web3-core-helpers": "1.7.0" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /packages/web3/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib" 5 | }, 6 | "include": [ 7 | "./src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/web3/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | "allowSyntheticDefaultImports": false, 12 | "baseUrl": ".", 13 | "paths": { 14 | "web3": ["."] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/web3/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-import-default-of-export-equals": false, 6 | "file-name-casing": [true, "kebab-case"], 7 | "whitespace": false, 8 | "no-unnecessary-class": false, 9 | "unified-signatures": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test.ts: -------------------------------------------------------------------------------- 1 | import Web3 from 'https://deno.land/x/web3@v0.5.1/mod.ts' 2 | 3 | const providerURL = Deno.args[0] 4 | 5 | const web3 = new Web3(new (Web3 as any).providers.HttpProvider(providerURL)) 6 | 7 | const balance = await (web3 as any).eth.getBalance("0x7a915e362353d72570dcf90aa5baa1c5b341c7aa") 8 | 9 | console.log(`the balance is ${balance} wei`) -------------------------------------------------------------------------------- /usage-examples/create-account.ts: -------------------------------------------------------------------------------- 1 | 2 | import Web3 from 'https://deno.land/x/web3/mod.ts' 3 | 4 | const providerURL = Deno.args[0] 5 | 6 | const web3 = new Web3(new (Web3 as any).providers.HttpProvider(providerURL)) 7 | 8 | const newAccount = await (web3 as any).eth.accounts.create() 9 | 10 | console.log(newAccount) -------------------------------------------------------------------------------- /usage-examples/get-balance.ts: -------------------------------------------------------------------------------- 1 | 2 | // import Web3 from '../mod.ts' 3 | 4 | import Web3 from 'https://deno.land/x/web3/mod.ts' 5 | 6 | const providerURL = Deno.args[0] 7 | 8 | const web3 = new Web3(new (Web3 as any).providers.HttpProvider(providerURL)) 9 | 10 | const balance = await (web3 as any).eth.getBalance("0x7a915e362353d72570dcf90aa5baa1c5b341c7aa") 11 | 12 | console.log(`the balance is ${balance} wei`) 13 | 14 | -------------------------------------------------------------------------------- /usage-examples/get-transaction.ts: -------------------------------------------------------------------------------- 1 | 2 | import Web3 from 'https://deno.land/x/web3/mod.ts' 3 | 4 | const providerURL = Deno.args[0] 5 | 6 | const web3 = new Web3(new (Web3 as any).providers.HttpProvider(providerURL)) 7 | 8 | const transactionHash = "0x0d558d490c89fc94ddfebd284e39da5c1bcff15d18c4e9fd2eb37a202d20c703" 9 | 10 | const transaction = (await (web3.eth as any).getTransaction(transactionHash)) 11 | 12 | console.log(transaction) --------------------------------------------------------------------------------