├── light ├── index.d.ts ├── workspace ├── .package.json └── index.js ├── node ├── index.d.ts ├── workspace └── index.js ├── puppet ├── index.d.ts ├── index.js ├── workspace └── .package.json ├── explorer ├── index.d.ts ├── workspace ├── test │ └── index.js └── package.json ├── abi ├── workspace ├── index.js ├── lib │ ├── util.js │ └── function.js ├── package.json └── index.d.ts ├── ens ├── workspace ├── package.json ├── test │ └── index.js └── index.d.ts ├── units ├── workspace ├── test │ └── index.js ├── package.json ├── index.d.ts └── index.js ├── utils ├── workspace ├── lib │ ├── association.js │ ├── interval.js │ ├── observable.js │ ├── tx-listener.js │ ├── rlp.js │ ├── crypto.js │ ├── address.js │ ├── emitter.js │ └── param.js ├── index.js ├── test │ └── index.js └── package.json ├── browser ├── workspace └── package.json ├── contract ├── workspace ├── test │ └── index.js ├── package.json └── index.d.ts ├── account-online ├── workspace ├── test │ └── index.js ├── index.d.ts └── package.json ├── account-readonly ├── workspace ├── test │ └── index.js ├── index.d.ts └── package.json ├── account-signer ├── workspace ├── test │ └── index.js ├── index.d.ts └── package.json ├── signer-ledger ├── workspace ├── index.d.ts ├── package.json └── test │ └── index.js ├── signer-utils ├── workspace ├── index.js ├── test │ └── index.js ├── index.d.ts ├── package.json └── lib │ └── recover.js ├── .prettierignore ├── .yarnrc ├── jsonrpc-request-queue ├── workspace ├── test │ └── index.js └── package.json ├── signer-private-key ├── workspace ├── index.d.ts ├── package.json └── test │ └── index.js ├── docs ├── source │ ├── _templates │ │ └── layout.html │ ├── _static │ │ └── css │ │ │ └── browseth.css │ ├── index.rst │ ├── ens.rst │ ├── units.rst │ ├── signers.rst │ └── cookbook.rst ├── Makefile └── make.bat ├── cli ├── subscription │ ├── contracts │ │ ├── zeppelin │ │ │ ├── .npmignore │ │ │ ├── mocks │ │ │ │ ├── ReentrancyAttack.sol │ │ │ │ ├── WhitelistMock.sol │ │ │ │ ├── LimitBalanceMock.sol │ │ │ │ ├── HasNoEtherTest.sol │ │ │ │ ├── PausableTokenMock.sol │ │ │ │ ├── BurnableTokenMock.sol │ │ │ │ ├── BasicTokenMock.sol │ │ │ │ ├── StandardBurnableTokenMock.sol │ │ │ │ ├── ERC827TokenMock.sol │ │ │ │ ├── StandardTokenMock.sol │ │ │ │ ├── DetailedERC20Mock.sol │ │ │ │ ├── MerkleProofWrapper.sol │ │ │ │ ├── PullPaymentMock.sol │ │ │ │ ├── MintedCrowdsaleImpl.sol │ │ │ │ ├── WhitelistedCrowdsaleImpl.sol │ │ │ │ ├── SecureTargetBounty.sol │ │ │ │ ├── InsecureTargetBounty.sol │ │ │ │ ├── IndividuallyCappedCrowdsaleImpl.sol │ │ │ │ ├── CappedCrowdsaleImpl.sol │ │ │ │ ├── ForceEther.sol │ │ │ │ ├── AllowanceCrowdsaleImpl.sol │ │ │ │ ├── BouncerMock.sol │ │ │ │ ├── ECRecoveryMock.sol │ │ │ │ ├── TimedCrowdsaleImpl.sol │ │ │ │ ├── ERC721BasicTokenMock.sol │ │ │ │ ├── PostDeliveryCrowdsaleImpl.sol │ │ │ │ ├── PausableMock.sol │ │ │ │ ├── FinalizableCrowdsaleImpl.sol │ │ │ │ ├── MathMock.sol │ │ │ │ ├── RefundableCrowdsaleImpl.sol │ │ │ │ ├── SafeMathMock.sol │ │ │ │ ├── IncreasingPriceCrowdsaleImpl.sol │ │ │ │ ├── ERC721TokenMock.sol │ │ │ │ ├── ERC721ReceiverMock.sol │ │ │ │ ├── MessageHelper.sol │ │ │ │ ├── ERC223TokenMock.sol │ │ │ │ ├── ReentrancyMock.sol │ │ │ │ └── RBACMock.sol │ │ │ ├── token │ │ │ │ ├── ERC721 │ │ │ │ │ ├── ERC721Holder.sol │ │ │ │ │ ├── DeprecatedERC721.sol │ │ │ │ │ ├── ERC721.sol │ │ │ │ │ ├── ERC721Receiver.sol │ │ │ │ │ └── ERC721Basic.sol │ │ │ │ ├── ERC20 │ │ │ │ │ ├── ERC20Basic.sol │ │ │ │ │ ├── ERC20.sol │ │ │ │ │ ├── DetailedERC20.sol │ │ │ │ │ ├── CappedToken.sol │ │ │ │ │ ├── SafeERC20.sol │ │ │ │ │ ├── StandardBurnableToken.sol │ │ │ │ │ ├── BurnableToken.sol │ │ │ │ │ ├── RBACMintableToken.sol │ │ │ │ │ ├── TokenTimelock.sol │ │ │ │ │ ├── BasicToken.sol │ │ │ │ │ ├── PausableToken.sol │ │ │ │ │ └── MintableToken.sol │ │ │ │ └── ERC827 │ │ │ │ │ └── ERC827.sol │ │ │ ├── ownership │ │ │ │ ├── NoOwner.sol │ │ │ │ ├── Contactable.sol │ │ │ │ ├── HasNoContracts.sol │ │ │ │ ├── CanReclaimToken.sol │ │ │ │ ├── HasNoTokens.sol │ │ │ │ ├── Claimable.sol │ │ │ │ ├── rbac │ │ │ │ │ └── Roles.sol │ │ │ │ ├── DelayedClaimable.sol │ │ │ │ ├── HasNoEther.sol │ │ │ │ ├── Ownable.sol │ │ │ │ └── Superuser.sol │ │ │ ├── math │ │ │ │ ├── Math.sol │ │ │ │ └── SafeMath.sol │ │ │ ├── lifecycle │ │ │ │ ├── Destructible.sol │ │ │ │ ├── Pausable.sol │ │ │ │ └── TokenDestructible.sol │ │ │ ├── crowdsale │ │ │ │ ├── emission │ │ │ │ │ ├── MintedCrowdsale.sol │ │ │ │ │ └── AllowanceCrowdsale.sol │ │ │ │ ├── distribution │ │ │ │ │ ├── FinalizableCrowdsale.sol │ │ │ │ │ ├── PostDeliveryCrowdsale.sol │ │ │ │ │ ├── utils │ │ │ │ │ │ └── RefundVault.sol │ │ │ │ │ └── RefundableCrowdsale.sol │ │ │ │ └── validation │ │ │ │ │ ├── CappedCrowdsale.sol │ │ │ │ │ ├── TimedCrowdsale.sol │ │ │ │ │ └── WhitelistedCrowdsale.sol │ │ │ ├── LimitBalance.sol │ │ │ ├── ReentrancyGuard.sol │ │ │ ├── examples │ │ │ │ ├── SimpleToken.sol │ │ │ │ ├── SimpleSavingsWallet.sol │ │ │ │ └── RBACWithAdmin.sol │ │ │ ├── AddressUtils.sol │ │ │ ├── payment │ │ │ │ ├── PullPayment.sol │ │ │ │ └── SplitPayment.sol │ │ │ └── MerkleProof.sol │ │ ├── ERC165.sol │ │ ├── ERC20.sol │ │ └── NFTResolver.sol │ ├── src │ │ ├── index.css │ │ ├── assets │ │ │ └── images │ │ │ │ ├── diamond.png │ │ │ │ └── sapphire.png │ │ ├── config.json │ │ ├── index.js │ │ ├── App.js │ │ └── components │ │ │ └── TransactionHash.js │ ├── public │ │ ├── favicon.ico │ │ ├── manifest.json │ │ └── index.html │ ├── .gitmodules │ └── package.json ├── sample_site │ ├── src │ │ ├── config.json │ │ ├── index.js │ │ ├── App.test.js │ │ └── App.js │ ├── README.md │ ├── public │ │ ├── manifest.json │ │ └── index.html │ └── package.json ├── wallet_gen │ ├── src │ │ ├── index.css │ │ ├── config.json │ │ ├── assets │ │ │ ├── arrow.png │ │ │ ├── visible.png │ │ │ └── invisible.png │ │ ├── index.js │ │ ├── App.test.js │ │ ├── App.js │ │ └── components │ │ │ ├── EnableWallet.js │ │ │ ├── Flipper.js │ │ │ └── Wallet.js │ ├── .gitignore │ ├── public │ │ ├── manifest.json │ │ └── index.html │ └── package.json ├── package.json └── yarn.lock ├── .gitignore ├── test ├── babel-hook.js ├── README.md ├── index.js ├── units │ ├── index.js │ ├── etherToWei.js │ ├── weiToEther.js │ ├── gweiToWei.js │ ├── unitToPow.js │ └── convert.js ├── utils │ ├── crypto.js │ ├── index.js │ ├── emitter.js │ ├── tx-listener.js │ ├── observable.js │ ├── address.js │ └── ab.js ├── signer-ledger │ └── index.js ├── contract │ └── testContract.sol └── ens │ └── index.js ├── .prettierrc ├── workspace ├── rollup.config.js ├── rollup.node-config.js └── rollup.browser-config.js ├── lerna.json ├── .babelrc ├── .github └── workflows │ └── always_fail_workflow.yaml ├── LICENSE ├── package.json └── README.md /light/index.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /node/index.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /puppet/index.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /puppet/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /explorer/index.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /abi/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /ens/workspace: -------------------------------------------------------------------------------- 1 | ../workspace/ -------------------------------------------------------------------------------- /light/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /node/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /puppet/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /units/workspace: -------------------------------------------------------------------------------- 1 | ../workspace/ -------------------------------------------------------------------------------- /utils/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /browser/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /contract/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /explorer/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /account-online/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /account-readonly/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /account-signer/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /signer-ledger/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /signer-utils/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/tmp/ 3 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | workspaces-experimental true 2 | -------------------------------------------------------------------------------- /jsonrpc-request-queue/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /signer-private-key/workspace: -------------------------------------------------------------------------------- 1 | ../workspace -------------------------------------------------------------------------------- /docs/source/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} -------------------------------------------------------------------------------- /signer-utils/index.js: -------------------------------------------------------------------------------- 1 | export { recover } from './lib/recover' 2 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/.npmignore: -------------------------------------------------------------------------------- 1 | mocks 2 | examples 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | tmp/ 4 | 5 | yarn-error.log 6 | 7 | .idea* -------------------------------------------------------------------------------- /test/babel-hook.js: -------------------------------------------------------------------------------- 1 | require('babel-register')({ 2 | presets: ['es2015'], 3 | }) 4 | -------------------------------------------------------------------------------- /cli/sample_site/src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://mainnet.infura.io/sbKHoVmtRnQ8GbOZbJ4z" 3 | } 4 | -------------------------------------------------------------------------------- /cli/subscription/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /cli/wallet_gen/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /signer-utils/test/index.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | const { recover } = require('..') 3 | 4 | recover({}) 5 | -------------------------------------------------------------------------------- /account-online/test/index.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | const { recover } = require('..') 3 | 4 | recover({}) 5 | -------------------------------------------------------------------------------- /account-readonly/test/index.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | const { recover } = require('..') 3 | 4 | recover({}) 5 | -------------------------------------------------------------------------------- /account-signer/test/index.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | const { recover } = require('..') 3 | 4 | recover({}) 5 | -------------------------------------------------------------------------------- /cli/wallet_gen/src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://mainnet.infura.io/sbKHoVmtRnQ8GbOZbJ4z", 3 | "chainId": 1 4 | } 5 | -------------------------------------------------------------------------------- /units/test/index.js: -------------------------------------------------------------------------------- 1 | const { convert, etherToWei, gweiToWei, toWei } = require('..') 2 | 3 | console.log(etherToWei(1.234)) 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "proseWrap": "always", 4 | "singleQuote": true, 5 | "semi": false 6 | } 7 | -------------------------------------------------------------------------------- /cli/subscription/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unstoppabledomains/browseth/HEAD/cli/subscription/public/favicon.ico -------------------------------------------------------------------------------- /cli/wallet_gen/src/assets/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unstoppabledomains/browseth/HEAD/cli/wallet_gen/src/assets/arrow.png -------------------------------------------------------------------------------- /cli/wallet_gen/src/assets/visible.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unstoppabledomains/browseth/HEAD/cli/wallet_gen/src/assets/visible.png -------------------------------------------------------------------------------- /cli/wallet_gen/src/assets/invisible.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unstoppabledomains/browseth/HEAD/cli/wallet_gen/src/assets/invisible.png -------------------------------------------------------------------------------- /cli/subscription/src/assets/images/diamond.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unstoppabledomains/browseth/HEAD/cli/subscription/src/assets/images/diamond.png -------------------------------------------------------------------------------- /cli/subscription/src/assets/images/sapphire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unstoppabledomains/browseth/HEAD/cli/subscription/src/assets/images/sapphire.png -------------------------------------------------------------------------------- /workspace/rollup.config.js: -------------------------------------------------------------------------------- 1 | import browserConfig from './rollup.browser-config' 2 | import nodeConfig from './rollup.node-config' 3 | 4 | export default [browserConfig, nodeConfig] 5 | -------------------------------------------------------------------------------- /contract/test/index.js: -------------------------------------------------------------------------------- 1 | const { Contract } = require('..') 2 | 3 | const c = new Contract({}, []) 4 | 5 | const tracker = c.ev.a().subscribe() 6 | tracker.on(() => {}) 7 | tracker.dispose() 8 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "npmClientArgs": [ 4 | "--production", 5 | "--no-optional" 6 | ], 7 | "useWorkspaces": true, 8 | "version": "2.1.2" 9 | } 10 | -------------------------------------------------------------------------------- /cli/subscription/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/OpenZeppelin/zeppelin-solidity"] 2 | path = submodules/OpenZeppelin/zeppelin-solidity 3 | url = https://github.com/OpenZeppelin/zeppelin-solidity.git 4 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | To run tests: 2 | 3 | 1. Run geth locally: geth -dev --rpc -gasprice 1 --dev.period 1 4 | 5 | 2. yarn test in /test 6 | 7 | To build a specific package: yarn --cwd build-node 8 | -------------------------------------------------------------------------------- /cli/subscription/src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "paidAddress": "0x09c1ccd0234b6eb21a3fc967f9856839576ad995", 3 | "freeAddress": "0x537d7b184bbb1b31336dd1ffce6ad4b4e4bcf14b", 4 | "paidPrice": "0.012", 5 | "costPerSecond": 380469245 6 | } 7 | -------------------------------------------------------------------------------- /cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/cli", 3 | "version": "2.1.2", 4 | "bin": { 5 | "browseth-cli": "./bin/browseth-cli.js" 6 | }, 7 | "dependencies": { 8 | "commander": "^2.15.1", 9 | "fs-extra": "^6.0.1" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cli/wallet_gen/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import registerServiceWorker from './registerServiceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | registerServiceWorker(); 9 | -------------------------------------------------------------------------------- /cli/sample_site/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import registerServiceWorker from './registerServiceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | registerServiceWorker(); 9 | -------------------------------------------------------------------------------- /cli/subscription/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import registerServiceWorker from './registerServiceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | registerServiceWorker(); 9 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [["env", { "modules": false }]], 3 | "plugins": [ 4 | "external-helpers", 5 | "transform-runtime", 6 | "transform-object-rest-spread", 7 | "transform-class-properties", 8 | "transform-decorators-legacy", 9 | "transform-async-to-generator" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ReentrancyAttack.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | contract ReentrancyAttack { 5 | 6 | function callSender(bytes4 data) public { 7 | // solium-disable-next-line security/no-low-level-calls 8 | require(msg.sender.call(data)); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cli/sample_site/README.md: -------------------------------------------------------------------------------- 1 | ## Create a simple site 2 | 3 | `browseth-cli create-simple-site `
`cd ` 4 | 5 | ### Install dependencies and run 6 | 7 | `yarn`
`yarn start` 8 | 9 | ![Sample Site](https://raw.githubusercontent.com/buyethdomains/browseth/master/screenshot.png 'Sample Site') 10 | -------------------------------------------------------------------------------- /cli/sample_site/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/WhitelistMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../ownership/Whitelist.sol"; 4 | 5 | 6 | contract WhitelistMock is Whitelist { 7 | 8 | function onlyWhitelistedCanDoThis() 9 | onlyWhitelisted 10 | view 11 | external 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cli/wallet_gen/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /abi/index.js: -------------------------------------------------------------------------------- 1 | import * as param from './lib/param' 2 | 3 | export { AbiCodec } from './lib/codec' 4 | export { AbiFunction } from './lib/function' 5 | export { AbiEvent } from './lib/event' 6 | 7 | export { param } 8 | 9 | // TODO's 10 | // checksum 11 | // fixedpoint 12 | // tight packing 13 | // topic decoding 14 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC721/ERC721Holder.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./ERC721Receiver.sol"; 4 | 5 | 6 | contract ERC721Holder is ERC721Receiver { 7 | function onERC721Received(address, uint256, bytes) public returns(bytes4) { 8 | return ERC721_RECEIVED; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/LimitBalanceMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../LimitBalance.sol"; 5 | 6 | 7 | // mock class using LimitBalance 8 | contract LimitBalanceMock is LimitBalance(1000) { 9 | 10 | function limitedDeposit() public payable limitedPayable { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/HasNoEtherTest.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../../contracts/ownership/HasNoEther.sol"; 4 | 5 | 6 | contract HasNoEtherTest is HasNoEther { 7 | 8 | // Constructor with explicit payable — should still fail 9 | constructor() public payable { 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /light/.package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/light", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "build-browser": " ", 7 | "build-node": " ", 8 | "build": " ", 9 | "start": " ", 10 | "pretest": "yarn build-node" 11 | 12 | }, 13 | "dependencies": { 14 | "babel-runtime": "^6.26.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /abi/lib/util.js: -------------------------------------------------------------------------------- 1 | export { getFullName } 2 | 3 | function getFullName(object) { 4 | return ( 5 | object.name + 6 | '(' + 7 | object.inputs 8 | .map( 9 | input => 10 | input.type === 'uint' || input.type === 'int' 11 | ? input.type + '256' 12 | : input.type, 13 | ) 14 | .join() + 15 | ')' 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /account-signer/index.d.ts: -------------------------------------------------------------------------------- 1 | export = SignerUtils 2 | export as namespace SignerUtils 3 | 4 | declare namespace SignerUtils { 5 | function recover(object: { 6 | hash: string | ArrayBuffer | ArrayBufferView 7 | r: string | ArrayBuffer | ArrayBufferView 8 | s: string | ArrayBuffer | ArrayBufferView 9 | v: string | ArrayBuffer | ArrayBufferView 10 | }): string 11 | } 12 | -------------------------------------------------------------------------------- /signer-utils/index.d.ts: -------------------------------------------------------------------------------- 1 | export = SignerUtils 2 | export as namespace SignerUtils 3 | 4 | declare namespace SignerUtils { 5 | function recover(object: { 6 | hash: string | ArrayBuffer | ArrayBufferView 7 | r: string | ArrayBuffer | ArrayBufferView 8 | s: string | ArrayBuffer | ArrayBufferView 9 | v: string | ArrayBuffer | ArrayBufferView 10 | }): string 11 | } 12 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/PausableTokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/PausableToken.sol"; 4 | 5 | 6 | // mock class using PausableToken 7 | contract PausableTokenMock is PausableToken { 8 | 9 | constructor(address initialAccount, uint initialBalance) public { 10 | balances[initialAccount] = initialBalance; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/BurnableTokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/BurnableToken.sol"; 4 | 5 | 6 | contract BurnableTokenMock is BurnableToken { 7 | 8 | constructor(address initialAccount, uint initialBalance) public { 9 | balances[initialAccount] = initialBalance; 10 | totalSupply_ = initialBalance; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | function importTest(name, path) { 2 | describe(name, () => { 3 | require(path) 4 | }) 5 | } 6 | 7 | // importTest('Utils', './utils') 8 | // importTest('Units', './units') 9 | // importTest('Private Key Signer', './signer-private-key') 10 | importTest('Ledger Signer', './signer-ledger') 11 | // importTest('ENS', './ens') 12 | // importTest('Contract', './contract') 13 | -------------------------------------------------------------------------------- /cli/wallet_gen/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /signer-ledger/index.d.ts: -------------------------------------------------------------------------------- 1 | export = SignerLedger 2 | export as namespace SignerLedger 3 | 4 | declare namespace SignerLedger { 5 | export { SignerLedger as default, SignerLedger } 6 | 7 | class SignerLedger { 8 | constructor() 9 | signTransaction(transaction: any): ArrayBuffer 10 | signMessage(message: string, shouldConcat: boolean): ArrayBuffer 11 | toAddress(): string 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cli/wallet_gen/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /cli/subscription/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /cli/sample_site/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Browseth App", 3 | "name": "Create Browseth App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/BasicTokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../token/ERC20/BasicToken.sol"; 5 | 6 | 7 | // mock class using BasicToken 8 | contract BasicTokenMock is BasicToken { 9 | 10 | constructor(address initialAccount, uint256 initialBalance) public { 11 | balances[initialAccount] = initialBalance; 12 | totalSupply_ = initialBalance; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/StandardBurnableTokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/StandardBurnableToken.sol"; 4 | 5 | 6 | contract StandardBurnableTokenMock is StandardBurnableToken { 7 | 8 | constructor(address initialAccount, uint initialBalance) public { 9 | balances[initialAccount] = initialBalance; 10 | totalSupply_ = initialBalance; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/units/index.js: -------------------------------------------------------------------------------- 1 | function importTest(name, path) { 2 | describe(name, () => { 3 | require(path) 4 | }) 5 | } 6 | 7 | importTest('toEther()', './toEther') 8 | importTest('toWei()', './toWei') 9 | importTest('weiToEther()', './weiToEther') 10 | importTest('gweiToWei()', './gweiToWei') 11 | importTest('etherToWei()', './etherToWei') 12 | importTest('convert()', './convert') 13 | importTest('unitToPow()', './unitToPow') -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ERC827TokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../token/ERC827/ERC827Token.sol"; 5 | 6 | 7 | // mock class using ERC827 Token 8 | contract ERC827TokenMock is ERC827Token { 9 | 10 | constructor(address initialAccount, uint256 initialBalance) public { 11 | balances[initialAccount] = initialBalance; 12 | totalSupply_ = initialBalance; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/StandardTokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/StandardToken.sol"; 4 | 5 | 6 | // mock class using StandardToken 7 | contract StandardTokenMock is StandardToken { 8 | 9 | constructor(address initialAccount, uint256 initialBalance) public { 10 | balances[initialAccount] = initialBalance; 11 | totalSupply_ = initialBalance; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/DetailedERC20Mock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/StandardToken.sol"; 4 | import "../token/ERC20/DetailedERC20.sol"; 5 | 6 | 7 | contract DetailedERC20Mock is StandardToken, DetailedERC20 { 8 | constructor( 9 | string _name, 10 | string _symbol, 11 | uint8 _decimals 12 | ) 13 | DetailedERC20(_name, _symbol, _decimals) 14 | public 15 | {} 16 | } 17 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/MerkleProofWrapper.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import { MerkleProof } from "../MerkleProof.sol"; 4 | 5 | 6 | contract MerkleProofWrapper { 7 | 8 | function verifyProof( 9 | bytes32[] _proof, 10 | bytes32 _root, 11 | bytes32 _leaf 12 | ) 13 | public 14 | pure 15 | returns (bool) 16 | { 17 | return MerkleProof.verifyProof(_proof, _root, _leaf); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/PullPaymentMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../payment/PullPayment.sol"; 5 | 6 | 7 | // mock class using PullPayment 8 | contract PullPaymentMock is PullPayment { 9 | 10 | constructor() public payable { } 11 | 12 | // test helper function to call asyncSend 13 | function callSend(address dest, uint256 amount) public { 14 | asyncSend(dest, amount); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /utils/lib/association.js: -------------------------------------------------------------------------------- 1 | export { Association as default, Association } 2 | 3 | class Association { 4 | pairWM = new WeakMap() 5 | 6 | get = aOrB => this.pairsWM.get(aOrB) 7 | 8 | set = (a, b) => { 9 | this.pairsWM.set(a, b) 10 | this.pairsWM.set(b, a) 11 | } 12 | 13 | delete = aOrB => { 14 | this.pairsWM.delete(aOrB) 15 | this.pairsWM.delete(aOrB) 16 | } 17 | 18 | has = aOrB => this.pairsWM.has(aOrB) 19 | } 20 | -------------------------------------------------------------------------------- /docs/source/_static/css/browseth.css: -------------------------------------------------------------------------------- 1 | dt sup { 2 | font-weight: normal; 3 | font-style: italic; 4 | opacity: 0.8; 5 | vertical-align: baseline; 6 | top: auto; 7 | font-size: medium; 8 | } 9 | 10 | dt { 11 | padding-bottom: 5px; 12 | } 13 | 14 | .rst-content dl dd { 15 | margin-bottom: 20px; 16 | } 17 | 18 | .code-block-caption { 19 | margin-bottom: 4px; 20 | } 21 | 22 | .code-block-caption .headerlink { 23 | display: none; 24 | } 25 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/MintedCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/MintableToken.sol"; 4 | import "../crowdsale/emission/MintedCrowdsale.sol"; 5 | 6 | 7 | contract MintedCrowdsaleImpl is MintedCrowdsale { 8 | 9 | constructor ( 10 | uint256 _rate, 11 | address _wallet, 12 | MintableToken _token 13 | ) 14 | public 15 | Crowdsale(_rate, _wallet, _token) 16 | { 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/WhitelistedCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/ERC20.sol"; 4 | import "../crowdsale/validation/WhitelistedCrowdsale.sol"; 5 | 6 | 7 | contract WhitelistedCrowdsaleImpl is WhitelistedCrowdsale { 8 | 9 | constructor ( 10 | uint256 _rate, 11 | address _wallet, 12 | ERC20 _token 13 | ) 14 | public 15 | Crowdsale(_rate, _wallet, _token) 16 | { 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/SecureTargetBounty.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import {Bounty, Target} from "../../contracts/Bounty.sol"; 4 | 5 | 6 | contract SecureTargetMock is Target { 7 | function checkInvariant() public returns(bool) { 8 | return true; 9 | } 10 | } 11 | 12 | 13 | contract SecureTargetBounty is Bounty { 14 | function deployContract() internal returns (address) { 15 | return new SecureTargetMock(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/InsecureTargetBounty.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import {Bounty, Target} from "../../contracts/Bounty.sol"; 4 | 5 | 6 | contract InsecureTargetMock is Target { 7 | function checkInvariant() public returns(bool) { 8 | return false; 9 | } 10 | } 11 | 12 | 13 | contract InsecureTargetBounty is Bounty { 14 | function deployContract() internal returns (address) { 15 | return new InsecureTargetMock(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /node/index.js: -------------------------------------------------------------------------------- 1 | import { ab } from '@browseth/utils' 2 | 3 | export { NodeClient as default, NodeClient } 4 | 5 | class NodeClient extends LightClient { 6 | constructor( 7 | config = { 8 | codec: { 9 | data: { 10 | to: value => Buffer.from(value), 11 | }, 12 | quantity: { 13 | to: value => BigInt(ab.toHex(value)), 14 | from: value => '0x' + value.toString(16), 15 | }, 16 | }, 17 | }, 18 | ) {} 19 | } 20 | -------------------------------------------------------------------------------- /signer-private-key/index.d.ts: -------------------------------------------------------------------------------- 1 | export = SignerPrivatekey 2 | export as namespace SignerPrivatekey 3 | 4 | declare namespace SignerPrivatekey { 5 | export { SignerPrivatekey as default, SignerPrivatekey } 6 | 7 | class SignerPrivatekey { 8 | constructor(privateKey: string | ArrayBuffer | ArrayBufferView) 9 | signTransaction(transaction: any): ArrayBuffer 10 | signMessage(message: string, shouldConcat: boolean): ArrayBuffer 11 | address(): string 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cli/wallet_gen/src/App.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import './App.css'; 3 | import Flipper from './components/Flipper'; 4 | 5 | class App extends Component { 6 | render() { 7 | return ( 8 |
9 |
10 |

Wallet Example

11 |
12 |
13 | 14 |
15 | ); 16 | } 17 | } 18 | 19 | export default App; 20 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/IndividuallyCappedCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/ERC20.sol"; 4 | import "../crowdsale/validation/IndividuallyCappedCrowdsale.sol"; 5 | 6 | 7 | contract IndividuallyCappedCrowdsaleImpl is IndividuallyCappedCrowdsale { 8 | 9 | constructor ( 10 | uint256 _rate, 11 | address _wallet, 12 | ERC20 _token 13 | ) 14 | public 15 | Crowdsale(_rate, _wallet, _token) 16 | { 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/CappedCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/ERC20.sol"; 4 | import "../crowdsale/validation/CappedCrowdsale.sol"; 5 | 6 | 7 | contract CappedCrowdsaleImpl is CappedCrowdsale { 8 | 9 | constructor ( 10 | uint256 _rate, 11 | address _wallet, 12 | ERC20 _token, 13 | uint256 _cap 14 | ) 15 | public 16 | Crowdsale(_rate, _wallet, _token) 17 | CappedCrowdsale(_cap) 18 | { 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ForceEther.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | // @title Force Ether into a contract. 5 | // @notice even 6 | // if the contract is not payable. 7 | // @notice To use, construct the contract with the target as argument. 8 | // @author Remco Bloemen 9 | contract ForceEther { 10 | 11 | constructor() public payable { } 12 | 13 | function destroyAndSend(address _recipient) public { 14 | selfdestruct(_recipient); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /utils/lib/interval.js: -------------------------------------------------------------------------------- 1 | export { setUnrefedInterval, setUnrefedTimeout } 2 | 3 | function setUnrefedInterval(fn, delay, ...args) { 4 | const interval = setInterval(fn, delay, ...args) 5 | if (typeof interval.unref === 'function') { 6 | interval.unref() 7 | } 8 | return interval 9 | } 10 | 11 | function setUnrefedTimeout(fn, delay, ...args) { 12 | const timeout = setTimeout(fn, delay, ...args) 13 | if (typeof timeout.unref === 'function') { 14 | timeout.unref() 15 | } 16 | return timeout 17 | } 18 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/AllowanceCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/ERC20.sol"; 4 | import "../crowdsale/emission/AllowanceCrowdsale.sol"; 5 | 6 | 7 | contract AllowanceCrowdsaleImpl is AllowanceCrowdsale { 8 | 9 | constructor ( 10 | uint256 _rate, 11 | address _wallet, 12 | ERC20 _token, 13 | address _tokenWallet 14 | ) 15 | public 16 | Crowdsale(_rate, _wallet, _token) 17 | AllowanceCrowdsale(_tokenWallet) 18 | { 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/BouncerMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../access/SignatureBouncer.sol"; 4 | 5 | 6 | contract SignatureBouncerMock is SignatureBouncer { 7 | function checkValidSignature(address _address, bytes _sig) 8 | public 9 | view 10 | returns (bool) 11 | { 12 | return isValidSignature(_address, _sig); 13 | } 14 | 15 | function onlyWithValidSignature(bytes _sig) 16 | onlyValidSignature(_sig) 17 | public 18 | view 19 | { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/units/etherToWei.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import * as units from '@browseth/units' 3 | 4 | it('should convert ether to wei', () => { 5 | expect(units.etherToWei(1000000000000)).to.equal( 6 | '0xc9f2c9cd04674edea40000000', 7 | ) 8 | expect(units.etherToWei('100000020000')).to.equal( 9 | '0x1431e13eaa133ab4004800000', 10 | ) 11 | expect(units.etherToWei('1000000000')).to.equal('0x33b2e3c9fd0803ce8000000') 12 | expect(units.etherToWei(0x12132123231)).to.equal('0xfad65210472e95c1c92240000') 13 | }) 14 | -------------------------------------------------------------------------------- /cli/subscription/contracts/ERC165.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | interface ERC165Interface { 4 | function supportsInterface(bytes4 interfaceID) external view returns (bool); 5 | } 6 | 7 | contract ERC165 is ERC165Interface { 8 | /* 9 | * bytes4(keccak256('supportsInterface(bytes4)')); 10 | */ 11 | bytes4 constant InterfaceID_ERC165 = 0x01ffc9a7; 12 | 13 | function supportsInterface(bytes4 interfaceID) external view returns (bool) { 14 | return interfaceID == InterfaceID_ERC165; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ECRecoveryMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../ECRecovery.sol"; 5 | 6 | 7 | contract ECRecoveryMock { 8 | using ECRecovery for bytes32; 9 | 10 | function recover(bytes32 hash, bytes sig) 11 | public 12 | pure 13 | returns (address) 14 | { 15 | return hash.recover(sig); 16 | } 17 | 18 | function toEthSignedMessageHash(bytes32 hash) 19 | public 20 | pure 21 | returns (bytes32) 22 | { 23 | return hash.toEthSignedMessageHash(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/TimedCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/ERC20.sol"; 4 | import "../crowdsale/validation/TimedCrowdsale.sol"; 5 | 6 | 7 | contract TimedCrowdsaleImpl is TimedCrowdsale { 8 | 9 | constructor ( 10 | uint256 _openingTime, 11 | uint256 _closingTime, 12 | uint256 _rate, 13 | address _wallet, 14 | ERC20 _token 15 | ) 16 | public 17 | Crowdsale(_rate, _wallet, _token) 18 | TimedCrowdsale(_openingTime, _closingTime) 19 | { 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/ERC20Basic.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title ERC20Basic 6 | * @dev Simpler version of ERC20 interface 7 | * @dev see https://github.com/ethereum/EIPs/issues/179 8 | */ 9 | contract ERC20Basic { 10 | function totalSupply() public view returns (uint256); 11 | function balanceOf(address who) public view returns (uint256); 12 | function transfer(address to, uint256 value) public returns (bool); 13 | event Transfer(address indexed from, address indexed to, uint256 value); 14 | } 15 | -------------------------------------------------------------------------------- /test/utils/crypto.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { crypto } from '@browseth/utils' 3 | 4 | describe('keccak256', () => { 5 | it('should return keccak256 hash as a uint8array', () => { 6 | expect(crypto.keccak256(Buffer.from('123123123'))).to.be.a('Uint8Array') 7 | }) 8 | }) 9 | 10 | describe('namehash', () => { 11 | it('should return namehash hash as a string', () => { 12 | expect(crypto.namehash('ryan-le.eth')).to.equal( 13 | '0xd22199aae12a9820651b06cb6da9f5d4cccc53f925d7f1ec7e07682f8847ec41', 14 | ) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/NoOwner.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./HasNoEther.sol"; 4 | import "./HasNoTokens.sol"; 5 | import "./HasNoContracts.sol"; 6 | 7 | 8 | /** 9 | * @title Base contract for contracts that should not own things. 10 | * @author Remco Bloemen 11 | * @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or 12 | * Owned contracts. See respective base contracts for details. 13 | */ 14 | contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts { 15 | } 16 | -------------------------------------------------------------------------------- /account-readonly/index.d.ts: -------------------------------------------------------------------------------- 1 | export = AccountReadonlyNamespace 2 | export as namespace AccountReadonlyNamespace 3 | 4 | declare namespace AccountReadonlyNamespace { 5 | class AccountReadonly { 6 | id: string 7 | 8 | constructor( 9 | ethRef, 10 | options: { from: string | ArrayBuffer | ArrayBufferView }, 11 | ) 12 | 13 | address(): Promise 14 | gas(params: any): Promise 15 | call(params: any, block: any): Promise 16 | send(params: any): Promise 17 | sign(message: string): Promise 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ERC721BasicTokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC721/ERC721BasicToken.sol"; 4 | 5 | 6 | /** 7 | * @title ERC721BasicTokenMock 8 | * This mock just provides a public mint and burn functions for testing purposes 9 | */ 10 | contract ERC721BasicTokenMock is ERC721BasicToken { 11 | function mint(address _to, uint256 _tokenId) public { 12 | super._mint(_to, _tokenId); 13 | } 14 | 15 | function burn(uint256 _tokenId) public { 16 | super._burn(ownerOf(_tokenId), _tokenId); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/utils/index.js: -------------------------------------------------------------------------------- 1 | function importTest(name, path) { 2 | describe(name, () => { 3 | require(path) 4 | }) 5 | } 6 | 7 | importTest('ab', './ab') 8 | importTest('address', './address') 9 | importTest('crypto', './crypto') 10 | importTest('observable', './observable') 11 | importTest('emitter', './emitter') 12 | importTest('block-tracker', './block-tracker') 13 | // importTest('interval', './interval') 14 | importTest('observable', './observable') 15 | // importTest('param', './param') 16 | // importTest('rlp', './rlp') 17 | 18 | importTest('tx-listener', './tx-listener') -------------------------------------------------------------------------------- /utils/index.js: -------------------------------------------------------------------------------- 1 | import * as ab from './lib/ab' 2 | import * as address from './lib/address' 3 | import * as param from './lib/param' 4 | import * as crypto from './lib/crypto' 5 | import * as rlp from './lib/rlp' 6 | import * as interval from './lib/interval' 7 | import Observable from './lib/observable' 8 | export { Association } from './lib/association' 9 | export { Emitter } from './lib/emitter' 10 | export { BlockTracker } from './lib/block-tracker' 11 | export { TxListener } from './lib/tx-listener' 12 | 13 | export { ab, address, crypto, param, rlp, interval, Observable } 14 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. Browseth documentation master file, created by 2 | sphinx-quickstart on Sun Sep 23 15:03:13 2018. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Browseth's documentation! 7 | ==================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Developer Documentation 12 | 13 | quickstart 14 | getting-started 15 | cookbook 16 | browser 17 | units 18 | utils 19 | contracts 20 | ens 21 | signers 22 | 23 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/PostDeliveryCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/ERC20.sol"; 4 | import "../crowdsale/distribution/PostDeliveryCrowdsale.sol"; 5 | 6 | 7 | contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale { 8 | 9 | constructor ( 10 | uint256 _openingTime, 11 | uint256 _closingTime, 12 | uint256 _rate, 13 | address _wallet, 14 | ERC20 _token 15 | ) 16 | public 17 | TimedCrowdsale(_openingTime, _closingTime) 18 | Crowdsale(_rate, _wallet, _token) 19 | { 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/PausableMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../lifecycle/Pausable.sol"; 5 | 6 | 7 | // mock class using Pausable 8 | contract PausableMock is Pausable { 9 | bool public drasticMeasureTaken; 10 | uint256 public count; 11 | 12 | constructor() public { 13 | drasticMeasureTaken = false; 14 | count = 0; 15 | } 16 | 17 | function normalProcess() external whenNotPaused { 18 | count++; 19 | } 20 | 21 | function drasticMeasure() external whenPaused { 22 | drasticMeasureTaken = true; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/FinalizableCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/MintableToken.sol"; 4 | import "../crowdsale/distribution/FinalizableCrowdsale.sol"; 5 | 6 | 7 | contract FinalizableCrowdsaleImpl is FinalizableCrowdsale { 8 | 9 | constructor ( 10 | uint256 _openingTime, 11 | uint256 _closingTime, 12 | uint256 _rate, 13 | address _wallet, 14 | MintableToken _token 15 | ) 16 | public 17 | Crowdsale(_rate, _wallet, _token) 18 | TimedCrowdsale(_openingTime, _closingTime) 19 | { 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cli/sample_site/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "browseth": "^0.0.51", 7 | "prismjs": "^1.15.0", 8 | "react": "^16.4.0", 9 | "react-dom": "^16.4.0", 10 | "react-scripts": "1.1.4", 11 | "react-select": "^1.2.1" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test --env=jsdom", 17 | "eject": "react-scripts eject" 18 | }, 19 | "devDependencies": { 20 | "@types/react": "^16.3.17" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cli/wallet_gen/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wallet_gen", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "browseth": "^0.0.54", 7 | "prismjs": "^1.15.0", 8 | "react": "^16.4.1", 9 | "react-dom": "^16.4.1", 10 | "react-scripts": "1.1.4", 11 | "react-select": "^2.0.0" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test --env=jsdom", 17 | "eject": "react-scripts eject", 18 | "geth": "geth -datadir tmp/geth -dev -networkid 1 -gasprice 1 -rpc console --rpccorsdomain='*'" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/units/weiToEther.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import * as units from '@browseth/units' 3 | 4 | it('should convert wei to ether', () => { 5 | expect(units.weiToEther(1000000000000)).to.equal('0.000001') 6 | expect(units.weiToEther('100000000000')).to.equal('0.0000001') 7 | expect(units.weiToEther('1000000000')).to.equal('0.000000001') 8 | expect(units.weiToEther(123222)).to.equal('0.000000000000123222') 9 | expect(units.weiToEther(0x2aa0022211f)).to.equal('0.000002929169932575') 10 | expect(units.weiToEther('2312132123123')).to.equal('0.000002312132123123') 11 | expect(units.weiToEther(0)).to.equal('0') 12 | }) 13 | -------------------------------------------------------------------------------- /account-online/index.d.ts: -------------------------------------------------------------------------------- 1 | export = AccountOnlineNamespace 2 | export as namespace AccountOnlineNamespace 3 | 4 | declare namespace AccountOnlineNamespace { 5 | class AccountOnline { 6 | id: string 7 | cachedAddresses: { 8 | timestamp: number 9 | values: null | string[] 10 | } 11 | 12 | constructor(ethRef, options: { addressTtl: number }) 13 | 14 | addresses(): Promise 15 | 16 | address(): Promise 17 | gas(params: any): Promise 18 | call(params: any, block: any): Promise 19 | send(params: any): Promise 20 | sign(message: string): Promise 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/units/gweiToWei.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import * as units from '@browseth/units' 3 | 4 | it('should convert gwei to wei', () => { 5 | expect(units.gweiToWei(1000000000000)).to.equal('0x3635c9adc5dea00000') 6 | expect(units.gweiToWei('100000020000')).to.equal('0x56bc7705dfff54000') 7 | expect(units.gweiToWei('1000000000')).to.equal('0xde0b6b3a7640000') 8 | expect(units.gweiToWei(0x1221323123fffaa)).to.equal('0x4389cd7b6766d4ce0c0800') 9 | expect(units.gweiToWei(234)).to.equal('0x367b7ca400') 10 | expect(units.gweiToWei(-1)).to.equal('0x-3b9aca00') 11 | expect(units.gweiToWei(0)).to.equal('0x0') 12 | }) 13 | -------------------------------------------------------------------------------- /.github/workflows/always_fail_workflow.yaml: -------------------------------------------------------------------------------- 1 | name: Always Fail Status Check 2 | 3 | on: [push, pull_request] 4 | 5 | env: 6 | NODE_VERSION: 16.15.0 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest] 15 | node: [16] 16 | 17 | name: Always Fail until proper checks are in place 18 | 19 | steps: 20 | - name: Checkout repo 21 | uses: actions/checkout@v4 22 | 23 | - name: Informational Message 24 | run: echo You need to setup proper branch protection rules and status checks 25 | 26 | - name: Force Fail 27 | run: exit 99 -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/MathMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../../contracts/math/Math.sol"; 5 | 6 | 7 | contract MathMock { 8 | uint64 public result64; 9 | uint256 public result256; 10 | 11 | function max64(uint64 a, uint64 b) public { 12 | result64 = Math.max64(a, b); 13 | } 14 | 15 | function min64(uint64 a, uint64 b) public { 16 | result64 = Math.min64(a, b); 17 | } 18 | 19 | function max256(uint256 a, uint256 b) public { 20 | result256 = Math.max256(a, b); 21 | } 22 | 23 | function min256(uint256 a, uint256 b) public { 24 | result256 = Math.min256(a, b); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/RefundableCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/MintableToken.sol"; 4 | import "../crowdsale/distribution/RefundableCrowdsale.sol"; 5 | 6 | 7 | contract RefundableCrowdsaleImpl is RefundableCrowdsale { 8 | 9 | constructor ( 10 | uint256 _openingTime, 11 | uint256 _closingTime, 12 | uint256 _rate, 13 | address _wallet, 14 | MintableToken _token, 15 | uint256 _goal 16 | ) 17 | public 18 | Crowdsale(_rate, _wallet, _token) 19 | TimedCrowdsale(_openingTime, _closingTime) 20 | RefundableCrowdsale(_goal) 21 | { 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/math/Math.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title Math 6 | * @dev Assorted math operations 7 | */ 8 | library Math { 9 | function max64(uint64 a, uint64 b) internal pure returns (uint64) { 10 | return a >= b ? a : b; 11 | } 12 | 13 | function min64(uint64 a, uint64 b) internal pure returns (uint64) { 14 | return a < b ? a : b; 15 | } 16 | 17 | function max256(uint256 a, uint256 b) internal pure returns (uint256) { 18 | return a >= b ? a : b; 19 | } 20 | 21 | function min256(uint256 a, uint256 b) internal pure returns (uint256) { 22 | return a < b ? a : b; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/SafeMathMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../math/SafeMath.sol"; 5 | 6 | 7 | contract SafeMathMock { 8 | 9 | function mul(uint256 a, uint256 b) public pure returns (uint256) { 10 | return SafeMath.mul(a, b); 11 | } 12 | 13 | function div(uint256 a, uint256 b) public pure returns (uint256) { 14 | return SafeMath.div(a, b); 15 | } 16 | 17 | function sub(uint256 a, uint256 b) public pure returns (uint256) { 18 | return SafeMath.sub(a, b); 19 | } 20 | 21 | function add(uint256 a, uint256 b) public pure returns (uint256) { 22 | return SafeMath.add(a, b); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = source 8 | BUILDDIR = build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC721/DeprecatedERC721.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./ERC721.sol"; 4 | 5 | 6 | /** 7 | * @title ERC-721 methods shipped in OpenZeppelin v1.7.0, removed in the latest version of the standard 8 | * @dev Only use this interface for compatibility with previously deployed contracts 9 | * @dev Use ERC721 for interacting with new contracts which are standard-compliant 10 | */ 11 | contract DeprecatedERC721 is ERC721 { 12 | function takeOwnership(uint256 _tokenId) public; 13 | function transfer(address _to, uint256 _tokenId) public; 14 | function tokensOf(address _owner) public view returns (uint256[]); 15 | } 16 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/ERC20.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./ERC20Basic.sol"; 4 | 5 | 6 | /** 7 | * @title ERC20 interface 8 | * @dev see https://github.com/ethereum/EIPs/issues/20 9 | */ 10 | contract ERC20 is ERC20Basic { 11 | function allowance(address owner, address spender) 12 | public view returns (uint256); 13 | 14 | function transferFrom(address from, address to, uint256 value) 15 | public returns (bool); 16 | 17 | function approve(address spender, uint256 value) public returns (bool); 18 | event Approval( 19 | address indexed owner, 20 | address indexed spender, 21 | uint256 value 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /puppet/.package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/puppet", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | 17 | }, 18 | "dependencies": { 19 | "babel-runtime": "^6.26.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/DetailedERC20.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./ERC20.sol"; 4 | 5 | 6 | /** 7 | * @title DetailedERC20 token 8 | * @dev The decimals are only for visualization purposes. 9 | * All the operations are done using the smallest and indivisible token unit, 10 | * just as on Ethereum all the operations are done in wei. 11 | */ 12 | contract DetailedERC20 is ERC20 { 13 | string public name; 14 | string public symbol; 15 | uint8 public decimals; 16 | 17 | constructor(string _name, string _symbol, uint8 _decimals) public { 18 | name = _name; 19 | symbol = _symbol; 20 | decimals = _decimals; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/IncreasingPriceCrowdsaleImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../crowdsale/price/IncreasingPriceCrowdsale.sol"; 4 | import "../math/SafeMath.sol"; 5 | 6 | 7 | contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale { 8 | 9 | constructor ( 10 | uint256 _openingTime, 11 | uint256 _closingTime, 12 | address _wallet, 13 | ERC20 _token, 14 | uint256 _initialRate, 15 | uint256 _finalRate 16 | ) 17 | public 18 | Crowdsale(_initialRate, _wallet, _token) 19 | TimedCrowdsale(_openingTime, _closingTime) 20 | IncreasingPriceCrowdsale(_initialRate, _finalRate) 21 | { 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/Contactable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./Ownable.sol"; 4 | 5 | 6 | /** 7 | * @title Contactable token 8 | * @dev Basic version of a contactable contract, allowing the owner to provide a string with their 9 | * contact information. 10 | */ 11 | contract Contactable is Ownable { 12 | 13 | string public contactInformation; 14 | 15 | /** 16 | * @dev Allows the owner to set a string with their contact information. 17 | * @param info The contact information to attach to the contract. 18 | */ 19 | function setContactInformation(string info) onlyOwner public { 20 | contactInformation = info; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /explorer/test/index.js: -------------------------------------------------------------------------------- 1 | require('isomorphic-fetch') 2 | const { Explorer } = require('..') 3 | const { 4 | default: JsonRpcRequestQueue, 5 | } = require('@browseth/jsonrpc-request-queue') 6 | 7 | const jsonrpc = new JsonRpcRequestQueue('https://mainnet.infura.io/mew') 8 | 9 | const explore = new Explorer(jsonrpc) 10 | 11 | const keepaliveInterval = setInterval(() => {}, 10000) 12 | 13 | Promise.resolve() 14 | .then(async () => { 15 | console.log( 16 | await explore 17 | .account('0x0000000000000000000000000000000000000000') 18 | .balance(), 19 | ) 20 | }) 21 | .catch(console.error) 22 | .then(() => { 23 | clearInterval(keepaliveInterval) 24 | }) 25 | -------------------------------------------------------------------------------- /utils/lib/observable.js: -------------------------------------------------------------------------------- 1 | export { Observable, Observable as default } 2 | 3 | class Observable { 4 | static from(subject) { 5 | return new Observable(subject) 6 | } 7 | 8 | fns = new Set() 9 | 10 | constructor(value) { 11 | this.value = value 12 | } 13 | 14 | set = newValue => { 15 | this.value = newValue 16 | 17 | for (const fn of this.fns.values()) { 18 | if (fn) { 19 | setImmediate(fn.bind(this, this.value)) 20 | } 21 | } 22 | 23 | return this 24 | } 25 | 26 | get = () => this.value 27 | 28 | subscribe = fn => { 29 | this.fns.add(fn) 30 | 31 | return () => { 32 | this.fns.delete(fn) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/lifecycle/Destructible.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../ownership/Ownable.sol"; 5 | 6 | 7 | /** 8 | * @title Destructible 9 | * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. 10 | */ 11 | contract Destructible is Ownable { 12 | 13 | constructor() public payable { } 14 | 15 | /** 16 | * @dev Transfers the current balance to the owner and terminates the contract. 17 | */ 18 | function destroy() onlyOwner public { 19 | selfdestruct(owner); 20 | } 21 | 22 | function destroyAndSend(address _recipient) onlyOwner public { 23 | selfdestruct(_recipient); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jsonrpc-request-queue/test/index.js: -------------------------------------------------------------------------------- 1 | require('isomorphic-fetch') 2 | 3 | const { BufferedJsonRpcRequestQueue } = require('..') 4 | 5 | const requestor = new BufferedJsonRpcRequestQueue( 6 | 'https://mainnet.infura.io/mew', 7 | ) 8 | 9 | let successes = 0 10 | 11 | Promise.all( 12 | Array(100) 13 | .fill(null) 14 | .map(() => 15 | new Promise(r => setTimeout(r, Math.random() * 10000)) 16 | .then(() => requestor.request('eth_blockNumber')) 17 | .then(console.log) 18 | .then(() => { 19 | successes++ 20 | }) 21 | .catch(console.error), 22 | ), 23 | ) 24 | .then(() => console.log('successes:', successes)) 25 | .catch(console.error) 26 | -------------------------------------------------------------------------------- /units/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/units", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "bignumber.js": "^7.2.1" 19 | }, 20 | "publishConfig": { 21 | "access": "public" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ens/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/ens", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0" 20 | }, 21 | "publishConfig": { 22 | "access": "public" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jsonrpc-request-queue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/jsonrpc-request-queue", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "babel-runtime": "^6.26.0" 19 | }, 20 | "publishConfig": { 21 | "access": "public" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /explorer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/explorer", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0" 20 | }, 21 | "publishConfig": { 22 | "access": "public" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /account-online/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/account-online", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0" 20 | }, 21 | "publishConfig": { 22 | "access": "public" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /account-signer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/account-signer", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0" 20 | }, 21 | "publishConfig": { 22 | "access": "public" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /abi/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/abi", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0", 20 | "big.js": "^5.1.2" 21 | }, 22 | "publishConfig": { 23 | "access": "public" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /account-readonly/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/account-readonly", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0" 20 | }, 21 | "publishConfig": { 22 | "access": "public" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /utils/test/index.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | const { ab } = require('..') 3 | 4 | const logBin = v => { 5 | const bin = new Uint8Array(v) 6 | .toString() 7 | .split(',') 8 | .reverse() 9 | .map(v => ('00000000' + Number(v).toString(2)).slice(-8)) 10 | .join('') 11 | .split('') 12 | .reverse() 13 | .join('') 14 | 15 | console.log(bin) 16 | console.log( 17 | parseInt( 18 | bin 19 | .split('') 20 | .reverse() 21 | .join(''), 22 | 2, 23 | ), 24 | ) 25 | } 26 | 27 | new Array(512).fill().map((v, i) => { 28 | logBin(ab.padEnd(ab.fromUInt(i + 1), 4)) 29 | const twos = ab.toTwos(ab.fromUInt(i + 1), 4) 30 | logBin(twos) 31 | logBin(ab.toTwos(twos, 4)) 32 | console.log('--------------') 33 | }) 34 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/HasNoContracts.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./Ownable.sol"; 4 | 5 | 6 | /** 7 | * @title Contracts that should not own Contracts 8 | * @author Remco Bloemen 9 | * @dev Should contracts (anything Ownable) end up being owned by this contract, it allows the owner 10 | * of this contract to reclaim ownership of the contracts. 11 | */ 12 | contract HasNoContracts is Ownable { 13 | 14 | /** 15 | * @dev Reclaim ownership of Ownable contracts 16 | * @param contractAddr The address of the Ownable to be reclaimed. 17 | */ 18 | function reclaimContract(address contractAddr) external onlyOwner { 19 | Ownable contractInst = Ownable(contractAddr); 20 | contractInst.transferOwnership(owner); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/utils", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "babel-runtime": "^6.26.0", 19 | "mipher": "^1.1.5", 20 | "text-encoding": "^0.6.4" 21 | }, 22 | "publishConfig": { 23 | "access": "public" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /light/index.js: -------------------------------------------------------------------------------- 1 | import { address } from '@browseth/utils' 2 | import { tag } from '@browseth/utils/lib/param' 3 | 4 | class LightClient { 5 | request() {} 6 | 7 | logs = ({ 8 | topics = [], 9 | fromBlock = 'latest', 10 | toBlock = 'latest', 11 | address: addresses, 12 | }) => 13 | this.request('eth_getLogs', { 14 | fromBlock: tag(fromBlock), 15 | toBlock: tag(toBlock), 16 | topics: topics.map( 17 | topic => (Array.isArray(topic) ? topic.map(v => data(v)) : data(topic)), 18 | ), 19 | address: Array.isArray(addresses) 20 | ? addresses.map(v => data(v, 20)) 21 | : data(addresses, 20), 22 | }) 23 | 24 | send = () => Promise.resolve({}) 25 | gas = () => Promise.resolve({}) 26 | call = () => Promise.resolve({}) 27 | } 28 | -------------------------------------------------------------------------------- /contract/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/contract", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/abi": "^2.1.0", 19 | "@browseth/utils": "^2.1.0", 20 | "babel-runtime": "^6.26.0" 21 | }, 22 | "publishConfig": { 23 | "access": "public" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /signer-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/signer-utils", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0", 20 | "elliptic": "^6.4.1" 21 | }, 22 | "publishConfig": { 23 | "access": "public" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /signer-utils/lib/recover.js: -------------------------------------------------------------------------------- 1 | import { ec } from 'elliptic' 2 | 3 | import { ab, crypto, address } from '@browseth/utils' 4 | 5 | export { recover as default, recover } 6 | 7 | const secp256k1 = new ec('secp256k1') 8 | 9 | // const address = eth.recover( 10 | // '0x...' || { 11 | // hash, 12 | // s, 13 | // r, 14 | // v, 15 | // }, 16 | // ) 17 | 18 | function recover({ hash, r, s, v }) { 19 | const publicKey = secp256k1.recoverPubKey( 20 | new Uint8Array(ab.fromBytes(hash)), 21 | { 22 | r: new Uint8Array(ab.fromBytes(r)), 23 | s: new Uint8Array(ab.fromBytes(s)), 24 | }, 25 | ab.toHex(v) - 27, 26 | ) 27 | 28 | return address.from( 29 | crypto 30 | .keccak256(new Uint8Array(publicKey.encode('array').slice(1))) 31 | .slice(12, 32), 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ERC721TokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC721/ERC721Token.sol"; 4 | 5 | 6 | /** 7 | * @title ERC721TokenMock 8 | * This mock just provides a public mint and burn functions for testing purposes, 9 | * and a public setter for metadata URI 10 | */ 11 | contract ERC721TokenMock is ERC721Token { 12 | constructor(string name, string symbol) public 13 | ERC721Token(name, symbol) 14 | { } 15 | 16 | function mint(address _to, uint256 _tokenId) public { 17 | super._mint(_to, _tokenId); 18 | } 19 | 20 | function burn(uint256 _tokenId) public { 21 | super._burn(ownerOf(_tokenId), _tokenId); 22 | } 23 | 24 | function setTokenURI(uint256 _tokenId, string _uri) public { 25 | super._setTokenURI(_tokenId, _uri); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /signer-private-key/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/signer-private-key", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "babel-runtime": "^6.26.0", 20 | "elliptic": "^6.4.1" 21 | }, 22 | "publishConfig": { 23 | "access": "public" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/units/unitToPow.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import * as units from '@browseth/units' 3 | 4 | it('should return power of ether', () => { 5 | expect(units.unitToPow('ether')).to.equal(18) 6 | }) 7 | it('should return power of wei', () => { 8 | expect(units.unitToPow('wei')).to.equal(0) 9 | }) 10 | it('should return power of gwei', () => { 11 | expect(units.unitToPow('gwei')).to.equal(9) 12 | }) 13 | it('should return power of kwei', () => { 14 | expect(units.unitToPow('kwei')).to.equal(3) 15 | }) 16 | it('should return power of einstein', () => { 17 | expect(units.unitToPow('einstein')).to.equal(24) 18 | }) 19 | 20 | it('should throw invalid unit', () => { 21 | const invalidUnit = 'asdf' 22 | expect(() => units.unitToPow(invalidUnit)).to.throw( 23 | `invalid unit ${invalidUnit}`, 24 | ) 25 | }) 26 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/crowdsale/emission/MintedCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../Crowdsale.sol"; 4 | import "../../token/ERC20/MintableToken.sol"; 5 | 6 | 7 | /** 8 | * @title MintedCrowdsale 9 | * @dev Extension of Crowdsale contract whose tokens are minted in each purchase. 10 | * Token ownership should be transferred to MintedCrowdsale for minting. 11 | */ 12 | contract MintedCrowdsale is Crowdsale { 13 | 14 | /** 15 | * @dev Overrides delivery by minting tokens upon purchase. 16 | * @param _beneficiary Token purchaser 17 | * @param _tokenAmount Number of tokens to be minted 18 | */ 19 | function _deliverTokens( 20 | address _beneficiary, 21 | uint256 _tokenAmount 22 | ) 23 | internal 24 | { 25 | require(MintableToken(token).mint(_beneficiary, _tokenAmount)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /signer-ledger/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/signer-ledger", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/utils": "^2.1.0", 19 | "@ledgerhq/hw-app-eth": "^4.24.0", 20 | "@ledgerhq/hw-transport-node-hid": "^4.24.0", 21 | "babel-runtime": "^6.26.0" 22 | }, 23 | "publishConfig": { 24 | "access": "public" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cli/subscription/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "subscription", 3 | "version": "1.0.0", 4 | "license": "MIT", 5 | "dependencies": { 6 | "browseth": "^0.0.54", 7 | "react": "^16.4.1", 8 | "react-dom": "^16.4.1", 9 | "react-scripts": "1.1.4", 10 | "xmlhttprequest": "^1.8.0" 11 | }, 12 | "scripts": { 13 | "start": "react-scripts start", 14 | "build": "react-scripts build", 15 | "test": "react-scripts test --env=jsdom", 16 | "eject": "react-scripts eject", 17 | "compile": "solc -o build --gas --abi --bin contracts/**.sol ./=contracts --allow-paths contracts --overwrite --optimize", 18 | "postcompile": "for old in ./build/*.abi; do mv $old ./build/`basename $old .abi`.json; done", 19 | "geth": "geth -datadir tmp/geth -dev -networkid 1 -gasprice 1 -rpc console --rpccorsdomain='*'", 20 | "deploy": "cd src && node deploytoken.js" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ERC721ReceiverMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC721/ERC721Receiver.sol"; 4 | 5 | 6 | contract ERC721ReceiverMock is ERC721Receiver { 7 | bytes4 retval; 8 | bool reverts; 9 | 10 | event Received( 11 | address _address, 12 | uint256 _tokenId, 13 | bytes _data, 14 | uint256 _gas 15 | ); 16 | 17 | constructor(bytes4 _retval, bool _reverts) public { 18 | retval = _retval; 19 | reverts = _reverts; 20 | } 21 | 22 | function onERC721Received( 23 | address _address, 24 | uint256 _tokenId, 25 | bytes _data 26 | ) 27 | public 28 | returns(bytes4) 29 | { 30 | require(!reverts); 31 | emit Received( 32 | _address, 33 | _tokenId, 34 | _data, 35 | gasleft() // msg.gas was deprecated in solidityv0.4.21 36 | ); 37 | return retval; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/CanReclaimToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./Ownable.sol"; 4 | import "../token/ERC20/ERC20Basic.sol"; 5 | import "../token/ERC20/SafeERC20.sol"; 6 | 7 | 8 | /** 9 | * @title Contracts that should be able to recover tokens 10 | * @author SylTi 11 | * @dev This allow a contract to recover any ERC20 token received in a contract by transferring the balance to the contract owner. 12 | * This will prevent any accidental loss of tokens. 13 | */ 14 | contract CanReclaimToken is Ownable { 15 | using SafeERC20 for ERC20Basic; 16 | 17 | /** 18 | * @dev Reclaim all ERC20Basic compatible tokens 19 | * @param token ERC20Basic The address of the token contract 20 | */ 21 | function reclaimToken(ERC20Basic token) external onlyOwner { 22 | uint256 balance = token.balanceOf(this); 23 | token.safeTransfer(owner, balance); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/LimitBalance.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title LimitBalance 6 | * @dev Simple contract to limit the balance of child contract. 7 | * @dev Note this doesn't prevent other contracts to send funds by using selfdestruct(address); 8 | * @dev See: https://github.com/ConsenSys/smart-contract-best-practices#remember-that-ether-can-be-forcibly-sent-to-an-account 9 | */ 10 | contract LimitBalance { 11 | 12 | uint256 public limit; 13 | 14 | /** 15 | * @dev Constructor that sets the passed value as a limit. 16 | * @param _limit uint256 to represent the limit. 17 | */ 18 | constructor(uint256 _limit) public { 19 | limit = _limit; 20 | } 21 | 22 | /** 23 | * @dev Checks if limit was reached. Case true, it throws. 24 | */ 25 | modifier limitedPayable() { 26 | require(address(this).balance <= limit); 27 | _; 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /test/signer-ledger/index.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import SignerLedger from '@browseth/signer-ledger' 3 | import { ab } from '@browseth/utils' 4 | import ETx from 'ethereumjs-tx' 5 | 6 | describe('address()', () => { 7 | it('should return address', async function() { 8 | this.timeout(20000000) 9 | const signer = new SignerLedger(0, 1) 10 | const address = (await signer.address()).address 11 | expect(address).to.equal('0xc3c482d9579C7cce15A9BCcCD7F2A8148Ad0109A') 12 | }) 13 | }) 14 | 15 | describe('signMessage()', () => { 16 | it('should sign message', async function() { 17 | this.timeout(20000000) 18 | const signer = new SignerLedger() 19 | 20 | expect(ab.toHex(await signer.signMessage('testMessage'))).to.equal( 21 | '0xfc18a1ca0a65d4e9e0f87e1d5d126f8d0606e05938379bd11ed1d75bb43bfbb925b400dc7dbf813355f96fb9bc29f174ade96c67bd5072b266f9754932d1bc7600', 22 | ) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/HasNoTokens.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./CanReclaimToken.sol"; 4 | 5 | 6 | /** 7 | * @title Contracts that should not own Tokens 8 | * @author Remco Bloemen 9 | * @dev This blocks incoming ERC223 tokens to prevent accidental loss of tokens. 10 | * Should tokens (any ERC20Basic compatible) end up in the contract, it allows the 11 | * owner to reclaim the tokens. 12 | */ 13 | contract HasNoTokens is CanReclaimToken { 14 | 15 | /** 16 | * @dev Reject all ERC223 compatible tokens 17 | * @param from_ address The address that is transferring the tokens 18 | * @param value_ uint256 the amount of the specified token 19 | * @param data_ Bytes The data passed from the caller. 20 | */ 21 | function tokenFallback(address from_, uint256 value_, bytes data_) external { 22 | from_; 23 | value_; 24 | data_; 25 | revert(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/CappedToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./MintableToken.sol"; 4 | 5 | 6 | /** 7 | * @title Capped token 8 | * @dev Mintable token with a token cap. 9 | */ 10 | contract CappedToken is MintableToken { 11 | 12 | uint256 public cap; 13 | 14 | constructor(uint256 _cap) public { 15 | require(_cap > 0); 16 | cap = _cap; 17 | } 18 | 19 | /** 20 | * @dev Function to mint tokens 21 | * @param _to The address that will receive the minted tokens. 22 | * @param _amount The amount of tokens to mint. 23 | * @return A boolean that indicates if the operation was successful. 24 | */ 25 | function mint( 26 | address _to, 27 | uint256 _amount 28 | ) 29 | onlyOwner 30 | canMint 31 | public 32 | returns (bool) 33 | { 34 | require(totalSupply_.add(_amount) <= cap); 35 | 36 | return super.mint(_to, _amount); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/SafeERC20.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./ERC20Basic.sol"; 4 | import "./ERC20.sol"; 5 | 6 | 7 | /** 8 | * @title SafeERC20 9 | * @dev Wrappers around ERC20 operations that throw on failure. 10 | * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, 11 | * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. 12 | */ 13 | library SafeERC20 { 14 | function safeTransfer(ERC20Basic token, address to, uint256 value) internal { 15 | require(token.transfer(to, value)); 16 | } 17 | 18 | function safeTransferFrom( 19 | ERC20 token, 20 | address from, 21 | address to, 22 | uint256 value 23 | ) 24 | internal 25 | { 26 | require(token.transferFrom(from, to, value)); 27 | } 28 | 29 | function safeApprove(ERC20 token, address spender, uint256 value) internal { 30 | require(token.approve(spender, value)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC827/ERC827.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../ERC20/ERC20.sol"; 5 | 6 | 7 | /** 8 | * @title ERC827 interface, an extension of ERC20 token standard 9 | * 10 | * @dev Interface of a ERC827 token, following the ERC20 standard with extra 11 | * @dev methods to transfer value and data and execute calls in transfers and 12 | * @dev approvals. 13 | */ 14 | contract ERC827 is ERC20 { 15 | function approveAndCall( 16 | address _spender, 17 | uint256 _value, 18 | bytes _data 19 | ) 20 | public 21 | payable 22 | returns (bool); 23 | 24 | function transferAndCall( 25 | address _to, 26 | uint256 _value, 27 | bytes _data 28 | ) 29 | public 30 | payable 31 | returns (bool); 32 | 33 | function transferFromAndCall( 34 | address _from, 35 | address _to, 36 | uint256 _value, 37 | bytes _data 38 | ) 39 | public 40 | payable 41 | returns (bool); 42 | } 43 | -------------------------------------------------------------------------------- /utils/lib/tx-listener.js: -------------------------------------------------------------------------------- 1 | import { setUnrefedInterval, setUnrefedTimeout } from './interval' 2 | export { TxListener as default, TxListener } 3 | 4 | class TxListener { 5 | constructor(ethRef) { 6 | this.ethRef = ethRef 7 | } 8 | 9 | listen = txHash => 10 | new Promise((resolve, reject) => { 11 | this.interval = setUnrefedInterval(() => { 12 | this.ethRef 13 | .request('eth_getTransactionReceipt', txHash) 14 | .then(receipt => { 15 | if (!receipt) { 16 | return 17 | } 18 | clearInterval(this.interval) 19 | if (receipt.status === 0) { 20 | reject('Transaction not found') 21 | } else { 22 | resolve(receipt) 23 | } 24 | }) 25 | }, 5000) 26 | setUnrefedTimeout( 27 | () => clearInterval(interval) && reject('Transaction dropped'), 28 | 18000000, 29 | ) 30 | }) 31 | 32 | cleanup = () => clearInterval(this.interval) 33 | } 34 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/StandardBurnableToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./BurnableToken.sol"; 4 | import "./StandardToken.sol"; 5 | 6 | 7 | /** 8 | * @title Standard Burnable Token 9 | * @dev Adds burnFrom method to ERC20 implementations 10 | */ 11 | contract StandardBurnableToken is BurnableToken, StandardToken { 12 | 13 | /** 14 | * @dev Burns a specific amount of tokens from the target address and decrements allowance 15 | * @param _from address The address which you want to send tokens from 16 | * @param _value uint256 The amount of token to be burned 17 | */ 18 | function burnFrom(address _from, uint256 _value) public { 19 | require(_value <= allowed[_from][msg.sender]); 20 | // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, 21 | // this function needs to emit an event with the updated approval. 22 | allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); 23 | _burn(_from, _value); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ReentrancyGuard.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title Helps contracts guard agains reentrancy attacks. 6 | * @author Remco Bloemen 7 | * @notice If you mark a function `nonReentrant`, you should also 8 | * mark it `external`. 9 | */ 10 | contract ReentrancyGuard { 11 | 12 | /** 13 | * @dev We use a single lock for the whole contract. 14 | */ 15 | bool private reentrancyLock = false; 16 | 17 | /** 18 | * @dev Prevents a contract from calling itself, directly or indirectly. 19 | * @notice If you mark a function `nonReentrant`, you should also 20 | * mark it `external`. Calling one nonReentrant function from 21 | * another is not supported. Instead, you can implement a 22 | * `private` function doing the actual work, and a `external` 23 | * wrapper marked as `nonReentrant`. 24 | */ 25 | modifier nonReentrant() { 26 | require(!reentrancyLock); 27 | reentrancyLock = true; 28 | _; 29 | reentrancyLock = false; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/BurnableToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./BasicToken.sol"; 4 | 5 | 6 | /** 7 | * @title Burnable Token 8 | * @dev Token that can be irreversibly burned (destroyed). 9 | */ 10 | contract BurnableToken is BasicToken { 11 | 12 | event Burn(address indexed burner, uint256 value); 13 | 14 | /** 15 | * @dev Burns a specific amount of tokens. 16 | * @param _value The amount of token to be burned. 17 | */ 18 | function burn(uint256 _value) public { 19 | _burn(msg.sender, _value); 20 | } 21 | 22 | function _burn(address _who, uint256 _value) internal { 23 | require(_value <= balances[_who]); 24 | // no need to require value <= totalSupply, since that would imply the 25 | // sender's balance is greater than the totalSupply, which *should* be an assertion failure 26 | 27 | balances[_who] = balances[_who].sub(_value); 28 | totalSupply_ = totalSupply_.sub(_value); 29 | emit Burn(_who, _value); 30 | emit Transfer(_who, address(0), _value); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /signer-ledger/test/index.js: -------------------------------------------------------------------------------- 1 | const { SignerPrivateKey } = require('..') 2 | const { ec } = require('elliptic') 3 | 4 | const { ab, crypto, rlp, address } = require('@browseth/utils') 5 | 6 | const ETx = require('ethereumjs-tx') 7 | 8 | const secp256k1 = new ec('secp256k1') 9 | 10 | const pk = new SignerPrivateKey( 11 | '0x0000000000000000000000000000000000000000000000000000000000000001', 12 | ) 13 | 14 | const params = { 15 | nonce: 0, 16 | gasPrice: 10 ** 9 * 5, 17 | gas: 21000, 18 | to: Buffer.from(new ArrayBuffer(0)), 19 | value: 5, 20 | chainId: 1332347, 21 | data: Buffer.from(new ArrayBuffer(0)), 22 | } 23 | 24 | const tx = new ETx(params) 25 | 26 | tx.sign( 27 | Buffer.from( 28 | '0000000000000000000000000000000000000000000000000000000000000001', 29 | 'hex', 30 | ), 31 | ) 32 | 33 | console.log('0x' + tx.serialize().toString('hex')) 34 | console.log(ab.toHex(pk.signTransaction(params))) 35 | 36 | const object = pk.sign('kalnfsndlknalsdknflkasdnlkfn', false) 37 | 38 | console.log(object) 39 | 40 | console.log(pk.recover(object)) 41 | -------------------------------------------------------------------------------- /test/contract/testContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.22; 2 | 3 | contract Test { 4 | uint256 a; 5 | uint256 b; 6 | 7 | event ASet(uint256 indexed a, uint256 b, uint256 aPlusB, uint256 indexed aTimesB); 8 | event BSet(uint256 b); 9 | 10 | constructor(uint256 _a, uint256 _b) public { 11 | a = _a; 12 | b = _b; 13 | } 14 | 15 | function getA() public view returns (uint256) { 16 | return a; 17 | } 18 | 19 | function getB() public view returns (uint256) { 20 | return b; 21 | } 22 | 23 | function getATimesB() public view returns (uint256) { 24 | return getA() * getB(); 25 | } 26 | 27 | function setA(uint256 _a) public { 28 | a = _a; 29 | emit ASet(a, b, a + b, a * b); 30 | } 31 | 32 | function setB(uint256 _b) public { 33 | b = _b; 34 | emit BSet(b); 35 | } 36 | 37 | function setAB(uint256 _a, uint256 _b) public { 38 | a = _a; 39 | b = _b; 40 | emit ASet(a, b, a + b, a * b); 41 | emit BSet(b); 42 | } 43 | } -------------------------------------------------------------------------------- /units/index.d.ts: -------------------------------------------------------------------------------- 1 | export = Units 2 | export as namespace Units 3 | 4 | declare namespace Units { 5 | export { convert, etherToWei, gweiToWei, toWei, toEther, weiToEther } 6 | 7 | type Unit = 8 | | 'wei' 9 | | 'kwei' 10 | | 'ada' 11 | | 'femtoether' 12 | | 'mwei' 13 | | 'babbage' 14 | | 'picoether' 15 | | 'gwei' 16 | | 'shannon' 17 | | 'nanoether' 18 | | 'nano' 19 | | 'szabo' 20 | | 'microether' 21 | | 'micro' 22 | | 'finney' 23 | | 'milliether' 24 | | 'milli' 25 | | 'ether' 26 | | 'kether' 27 | | 'grand' 28 | | 'einstein' 29 | | 'mether' 30 | | 'gether' 31 | | 'tether' 32 | 33 | function convert(fromUnit: Unit, value: number | string, toUnit: Unit): string 34 | function etherToWei(value: number | string): string 35 | function gweiToWei(value: number | string): string 36 | function toWei(fromUnit: Unit, value: number | string): string 37 | function toEther(fromUnit: Unit, value: number | string): string 38 | function weiToEther(value: number | string): string 39 | } 40 | -------------------------------------------------------------------------------- /workspace/rollup.node-config.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel' 2 | 3 | const pkg = require(process.cwd() + '/package.json') 4 | 5 | // check out https://github.com/rollup/rollup-plugin-babel/issues/148#issuecomment-399696316 6 | 7 | const external = [ 8 | ...Object.keys(pkg.peerDependencies || {}), 9 | ...Object.keys(pkg.dependencies || {}), 10 | ] 11 | 12 | const makeExternalPredicate = externalArr => { 13 | if (externalArr.length === 0) { 14 | return () => false 15 | } 16 | const pattern = new RegExp(`^(${externalArr.join('|')})($|/)`) 17 | return id => pattern.test(id) 18 | } 19 | 20 | export default { 21 | input: process.cwd() + '/index.js', 22 | external: makeExternalPredicate(external), 23 | output: [ 24 | { 25 | file: pkg.main, 26 | format: 'cjs', 27 | exports: 'named', 28 | }, 29 | { 30 | file: pkg.module, 31 | format: 'es', 32 | exports: 'named', 33 | }, 34 | ], 35 | plugins: [ 36 | babel({ runtimeHelpers: true, exclude: ['node_modules/**', '**/*.json'] }), 37 | ], 38 | } 39 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/examples/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../token/ERC20/StandardToken.sol"; 5 | 6 | 7 | /** 8 | * @title SimpleToken 9 | * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. 10 | * Note they can later distribute these tokens as they wish using `transfer` and other 11 | * `StandardToken` functions. 12 | */ 13 | contract SimpleToken is StandardToken { 14 | 15 | string public constant name = "SimpleToken"; // solium-disable-line uppercase 16 | string public constant symbol = "SIM"; // solium-disable-line uppercase 17 | uint8 public constant decimals = 18; // solium-disable-line uppercase 18 | 19 | uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals)); 20 | 21 | /** 22 | * @dev Constructor that gives msg.sender all of existing tokens. 23 | */ 24 | constructor() public { 25 | totalSupply_ = INITIAL_SUPPLY; 26 | balances[msg.sender] = INITIAL_SUPPLY; 27 | emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/MessageHelper.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | contract MessageHelper { 5 | 6 | event Show(bytes32 b32, uint256 number, string text); 7 | event Buy(bytes32 b32, uint256 number, string text, uint256 value); 8 | 9 | function showMessage( 10 | bytes32 message, 11 | uint256 number, 12 | string text 13 | ) 14 | public 15 | returns (bool) 16 | { 17 | emit Show(message, number, text); 18 | return true; 19 | } 20 | 21 | function buyMessage( 22 | bytes32 message, 23 | uint256 number, 24 | string text 25 | ) 26 | public 27 | payable 28 | returns (bool) 29 | { 30 | emit Buy( 31 | message, 32 | number, 33 | text, 34 | msg.value); 35 | return true; 36 | } 37 | 38 | function fail() public { 39 | require(false); 40 | } 41 | 42 | function call(address to, bytes data) public returns (bool) { 43 | // solium-disable-next-line security/no-low-level-calls 44 | if (to.call(data)) 45 | return true; 46 | else 47 | return false; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ERC223TokenMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../token/ERC20/BasicToken.sol"; 4 | 5 | 6 | contract ERC223ContractInterface { 7 | function tokenFallback(address _from, uint256 _value, bytes _data) external; 8 | } 9 | 10 | 11 | contract ERC223TokenMock is BasicToken { 12 | 13 | constructor(address initialAccount, uint256 initialBalance) public { 14 | balances[initialAccount] = initialBalance; 15 | totalSupply_ = initialBalance; 16 | } 17 | 18 | // ERC223 compatible transfer function (except the name) 19 | function transferERC223(address _to, uint256 _value, bytes _data) public 20 | returns (bool success) 21 | { 22 | transfer(_to, _value); 23 | bool isContract = false; 24 | // solium-disable-next-line security/no-inline-assembly 25 | assembly { 26 | isContract := not(iszero(extcodesize(_to))) 27 | } 28 | if (isContract) { 29 | ERC223ContractInterface receiver = ERC223ContractInterface(_to); 30 | receiver.tokenFallback(msg.sender, _value, _data); 31 | } 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/utils/emitter.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { Emitter } from '@browseth/utils' 3 | import sinon from 'sinon' 4 | 5 | describe('on()', () => { 6 | it('should set and invoke callback on emit', () => { 7 | const spy = sinon.spy() 8 | const emitter = new Emitter() 9 | 10 | emitter.on('test', spy) 11 | emitter.emit('test') 12 | sinon.assert.calledOnce(spy) 13 | }) 14 | }) 15 | 16 | // describe('off()', () => { 17 | // it('should remove callback and not invoke on emit', () => { 18 | // const spy = sinon.spy() 19 | // const emitter = new Emitter() 20 | 21 | // emitter.on('test', spy) 22 | // emitter.off('test', spy) 23 | // // TODO: line eventM[event].delete(fn) not working in off() 24 | // emitter.emit('test') 25 | // sinon.assert.calledOnce(spy) 26 | // }) 27 | // }) 28 | 29 | describe('onEvery()', () => { 30 | it('should trigger callback on any event', () => { 31 | const spy = sinon.spy() 32 | const emitter = new Emitter() 33 | 34 | emitter.onEvery(spy) 35 | emitter.emit('test') 36 | sinon.assert.calledOnce(spy) 37 | }) 38 | }) 39 | -------------------------------------------------------------------------------- /abi/index.d.ts: -------------------------------------------------------------------------------- 1 | export = Abi 2 | export as namespace Abi 3 | 4 | declare namespace Abi { 5 | class AbiFunction { 6 | meta: object 7 | fullName?: string 8 | sig?: ArrayBuffer 9 | canUseNamedInput: boolean 10 | canUseNamedOutput: boolean 11 | 12 | enc(): string 13 | dec(): any 14 | } 15 | 16 | class AbiEvent { 17 | meta: object 18 | isAnonymous: boolean 19 | fullName?: string 20 | sig?: string 21 | canUseNamedInput: boolean 22 | canUseNamedOutput: boolean 23 | 24 | enc(): Array 25 | dec(): any 26 | } 27 | 28 | class AbiCodec { 29 | constructor( 30 | abiJsonInterface: object[], 31 | options?: { bin: string | ArrayBuffer | ArrayBufferView }, 32 | ) 33 | 34 | construct(...args): string 35 | fn: { 36 | [key: string]: { 37 | enc(...args): string 38 | dec: (data: string) => any 39 | } 40 | } 41 | ev: { 42 | [key: string]: { 43 | enc: (...args) => Array 44 | dec: (topics: string[], data: string) => any 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /cli/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | commander@^2.15.1: 6 | version "2.15.1" 7 | resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" 8 | 9 | fs-extra@^6.0.1: 10 | version "6.0.1" 11 | resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b" 12 | dependencies: 13 | graceful-fs "^4.1.2" 14 | jsonfile "^4.0.0" 15 | universalify "^0.1.0" 16 | 17 | graceful-fs@^4.1.2, graceful-fs@^4.1.6: 18 | version "4.1.11" 19 | resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" 20 | 21 | jsonfile@^4.0.0: 22 | version "4.0.0" 23 | resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" 24 | optionalDependencies: 25 | graceful-fs "^4.1.6" 26 | 27 | universalify@^0.1.0: 28 | version "0.1.2" 29 | resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-present, Buyethdomains Inc. 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. -------------------------------------------------------------------------------- /browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/browser", 3 | "version": "2.1.0", 4 | "license": "MIT", 5 | "browser": "build/browser.js", 6 | "main": "build/index.js", 7 | "module": "build/module.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "build-browser": "rollup -c workspace/rollup.browser-config.js", 11 | "build-node": "rollup -c workspace/rollup.node-config.js", 12 | "build": "rollup -c workspace/rollup.config.js", 13 | "start": "rollup -c workspace/rollup.node-config.js -w", 14 | "pretest": "yarn build-node", 15 | "test": "node test" 16 | }, 17 | "dependencies": { 18 | "@browseth/abi": "^2.1.0", 19 | "@browseth/account-online": "^2.1.0", 20 | "@browseth/account-readonly": "^2.1.0", 21 | "@browseth/account-signer": "^2.1.0", 22 | "@browseth/contract": "^2.1.0", 23 | "@browseth/explorer": "^2.1.0", 24 | "@browseth/jsonrpc-request-queue": "^2.1.0", 25 | "@browseth/signer-utils": "^2.1.0", 26 | "@browseth/units": "^2.1.0", 27 | "@browseth/utils": "^2.1.0", 28 | "babel-runtime": "^6.26.0" 29 | }, 30 | "publishConfig": { 31 | "access": "public" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/Claimable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "./Ownable.sol"; 5 | 6 | 7 | /** 8 | * @title Claimable 9 | * @dev Extension for the Ownable contract, where the ownership needs to be claimed. 10 | * This allows the new owner to accept the transfer. 11 | */ 12 | contract Claimable is Ownable { 13 | address public pendingOwner; 14 | 15 | /** 16 | * @dev Modifier throws if called by any account other than the pendingOwner. 17 | */ 18 | modifier onlyPendingOwner() { 19 | require(msg.sender == pendingOwner); 20 | _; 21 | } 22 | 23 | /** 24 | * @dev Allows the current owner to set the pendingOwner address. 25 | * @param newOwner The address to transfer ownership to. 26 | */ 27 | function transferOwnership(address newOwner) onlyOwner public { 28 | pendingOwner = newOwner; 29 | } 30 | 31 | /** 32 | * @dev Allows the pendingOwner address to finalize the transfer. 33 | */ 34 | function claimOwnership() onlyPendingOwner public { 35 | emit OwnershipTransferred(owner, pendingOwner); 36 | owner = pendingOwner; 37 | pendingOwner = address(0); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/RBACMintableToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./MintableToken.sol"; 4 | import "../../ownership/rbac/RBAC.sol"; 5 | 6 | 7 | /** 8 | * @title RBACMintableToken 9 | * @author Vittorio Minacori (@vittominacori) 10 | * @dev Mintable Token, with RBAC minter permissions 11 | */ 12 | contract RBACMintableToken is MintableToken, RBAC { 13 | /** 14 | * A constant role name for indicating minters. 15 | */ 16 | string public constant ROLE_MINTER = "minter"; 17 | 18 | /** 19 | * @dev override the Mintable token modifier to add role based logic 20 | */ 21 | modifier hasMintPermission() { 22 | checkRole(msg.sender, ROLE_MINTER); 23 | _; 24 | } 25 | 26 | /** 27 | * @dev add a minter role to an address 28 | * @param minter address 29 | */ 30 | function addMinter(address minter) onlyOwner public { 31 | addRole(minter, ROLE_MINTER); 32 | } 33 | 34 | /** 35 | * @dev remove a minter role from an address 36 | * @param minter address 37 | */ 38 | function removeMinter(address minter) onlyOwner public { 39 | removeRole(minter, ROLE_MINTER); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/AddressUtils.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * Utility library of inline functions on addresses 6 | */ 7 | library AddressUtils { 8 | 9 | /** 10 | * Returns whether the target address is a contract 11 | * @dev This function will return false if invoked during the constructor of a contract, 12 | * as the code is not actually created until after the constructor finishes. 13 | * @param addr address to check 14 | * @return whether the target address is a contract 15 | */ 16 | function isContract(address addr) internal view returns (bool) { 17 | uint256 size; 18 | // XXX Currently there is no better way to check if there is a contract in an address 19 | // than to check the size of the code at that address. 20 | // See https://ethereum.stackexchange.com/a/14016/36603 21 | // for more details about how this works. 22 | // TODO Check this again before the Serenity release, because all addresses will be 23 | // contracts then. 24 | // solium-disable-next-line security/no-inline-assembly 25 | assembly { size := extcodesize(addr) } 26 | return size > 0; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /docs/source/ens.rst: -------------------------------------------------------------------------------- 1 | .. _ens: 2 | 3 | ENS 4 | *** 5 | 6 | Ethereum Name Service `(ENS) `_ library for name lookup and standard 7 | resolver interface reading. 8 | 9 | .. code-block:: javascript 10 | 11 | import EnsLookup from '@browseth/units'; 12 | 13 | 14 | Creating Instances 15 | ------------------ 16 | 17 | new :sup:`EnsLookup` ( ethRef ) 18 | Initialize EnsLookup object with browseth instance 19 | 20 | Prototype 21 | --------- 22 | 23 | :sup:`prototype` . resolverAddress ( node ) 24 | Returns the address of the node's resolver 25 | 26 | :sup:`prototype` . address ( node ) 27 | Returns the address field set in the node's resolver 28 | 29 | :sup:`prototype` . name ( node ) 30 | Returns the name set in the node's resolver 31 | 32 | :sup:`prototype` . text ( node, key ) 33 | Returns the text of a key in the node's resolver 34 | 35 | :sup:`prototype` . allTexts ( node, key ) 36 | Returns all the text changes of a key in the node's resolver 37 | 38 | :sup:`prototype` . supportsInterface ( node, interfaceId ) 39 | Checks if the interfaceId is supported by the node's resolver 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/lifecycle/Pausable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../ownership/Ownable.sol"; 5 | 6 | 7 | /** 8 | * @title Pausable 9 | * @dev Base contract which allows children to implement an emergency stop mechanism. 10 | */ 11 | contract Pausable is Ownable { 12 | event Pause(); 13 | event Unpause(); 14 | 15 | bool public paused = false; 16 | 17 | 18 | /** 19 | * @dev Modifier to make a function callable only when the contract is not paused. 20 | */ 21 | modifier whenNotPaused() { 22 | require(!paused); 23 | _; 24 | } 25 | 26 | /** 27 | * @dev Modifier to make a function callable only when the contract is paused. 28 | */ 29 | modifier whenPaused() { 30 | require(paused); 31 | _; 32 | } 33 | 34 | /** 35 | * @dev called by the owner to pause, triggers stopped state 36 | */ 37 | function pause() onlyOwner whenNotPaused public { 38 | paused = true; 39 | emit Pause(); 40 | } 41 | 42 | /** 43 | * @dev called by the owner to unpause, returns to normal state 44 | */ 45 | function unpause() onlyOwner whenPaused public { 46 | paused = false; 47 | emit Unpause(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /utils/lib/rlp.js: -------------------------------------------------------------------------------- 1 | // Basicly an ArrayBuffer version of encode from https://github.com/ethereumjs/rlp 2 | 3 | import * as ab from './ab' 4 | 5 | export { encode } 6 | 7 | function encode(value) { 8 | if (Array.isArray(value)) { 9 | const buf = ab.concat(value.map(encode)) 10 | return ab.concat([encodeLength(buf.byteLength, 192), buf]) 11 | } else { 12 | const buf = new Uint8Array( 13 | typeof value === 'number' 14 | ? ab.fromUInt(value) 15 | : ab.isBytes(value) 16 | ? ab.fromBytes(value) 17 | : ab.fromUtf8(value), 18 | ) 19 | if (buf.length === 1 && buf[0] < 128) { 20 | return buf 21 | } else { 22 | return ab.concat([encodeLength(buf.length, 128), buf]) 23 | } 24 | } 25 | } 26 | 27 | function encodeLength(len, offset) { 28 | if (len < 56) { 29 | return new Uint8Array([len + offset]) 30 | } else { 31 | const hexLength = new Uint8Array(ab.fromUInt(len)) 32 | if (hexLength[hexLength.length] > 127) { 33 | throw new RangeError('odd number of nibbles') 34 | } 35 | const firstByte = ab.fromUInt(offset + 55 + hexLength.length) 36 | 37 | return ab.concat([firstByte, hexLength]) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /docs/source/units.rst: -------------------------------------------------------------------------------- 1 | .. _units: 2 | 3 | Units 4 | ***** 5 | 6 | Unit conversion library 7 | 8 | .. code-block:: javascript 9 | 10 | import * as units from '@browseth/units'; 11 | 12 | You can also import specific functions 13 | 14 | .. code-block:: javascript 15 | 16 | import {etherToWei, conversion} from '@browseth/units'; 17 | 18 | ----- 19 | 20 | :sup:`units` . convert ( fromUnit, value, toUnit ) 21 | convert unit of value to unit 22 | 23 | :sup:`units` . etherToWei ( value ) 24 | convert value in ether to wei 25 | 26 | :sup:`units` . gweiToWei ( value ) 27 | convert value in gwei to wei 28 | 29 | :sup:`units` . weiToEther ( value ) 30 | convert value in wei to ether 31 | 32 | :sup:`units` . toWei ( fromUnit, value ) 33 | convert unit of value to wei 34 | 35 | :sup:`units` . toEther ( fromUnit, value ) 36 | convert unit of value to ether 37 | 38 | :sup:`units` . unitToPow ( unit ) 39 | returns the power of the unit relative to wei 40 | 41 | Supported Units: 42 | wei, kwei, ada, femtoether, mwei, babbage, picoether, gwei, shannon, nanoether, nano, szabo, microether, micro, finney, milliether, milli, ether, kether, grand, einstein, mether, gether, tether -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/crowdsale/distribution/FinalizableCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../../math/SafeMath.sol"; 4 | import "../../ownership/Ownable.sol"; 5 | import "../validation/TimedCrowdsale.sol"; 6 | 7 | 8 | /** 9 | * @title FinalizableCrowdsale 10 | * @dev Extension of Crowdsale where an owner can do extra work 11 | * after finishing. 12 | */ 13 | contract FinalizableCrowdsale is TimedCrowdsale, Ownable { 14 | using SafeMath for uint256; 15 | 16 | bool public isFinalized = false; 17 | 18 | event Finalized(); 19 | 20 | /** 21 | * @dev Must be called after crowdsale ends, to do some extra finalization 22 | * work. Calls the contract's finalization function. 23 | */ 24 | function finalize() onlyOwner public { 25 | require(!isFinalized); 26 | require(hasClosed()); 27 | 28 | finalization(); 29 | emit Finalized(); 30 | 31 | isFinalized = true; 32 | } 33 | 34 | /** 35 | * @dev Can be overridden to add finalization logic. The overriding function 36 | * should call super.finalization() to ensure the chain of finalization is 37 | * executed entirely. 38 | */ 39 | function finalization() internal { 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/ReentrancyMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../ReentrancyGuard.sol"; 4 | import "./ReentrancyAttack.sol"; 5 | 6 | 7 | contract ReentrancyMock is ReentrancyGuard { 8 | 9 | uint256 public counter; 10 | 11 | constructor() public { 12 | counter = 0; 13 | } 14 | 15 | function callback() external nonReentrant { 16 | count(); 17 | } 18 | 19 | function countLocalRecursive(uint256 n) public nonReentrant { 20 | if (n > 0) { 21 | count(); 22 | countLocalRecursive(n - 1); 23 | } 24 | } 25 | 26 | function countThisRecursive(uint256 n) public nonReentrant { 27 | bytes4 func = bytes4(keccak256("countThisRecursive(uint256)")); 28 | if (n > 0) { 29 | count(); 30 | // solium-disable-next-line security/no-low-level-calls 31 | bool result = address(this).call(func, n - 1); 32 | require(result == true); 33 | } 34 | } 35 | 36 | function countAndCall(ReentrancyAttack attacker) public nonReentrant { 37 | count(); 38 | bytes4 func = bytes4(keccak256("callback()")); 39 | attacker.callSender(func); 40 | } 41 | 42 | function count() private { 43 | counter += 1; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /workspace/rollup.browser-config.js: -------------------------------------------------------------------------------- 1 | import resolve from 'rollup-plugin-node-resolve' 2 | import commonjs from 'rollup-plugin-commonjs' 3 | import babel from 'rollup-plugin-babel' 4 | import json from 'rollup-plugin-json' 5 | 6 | const pkg = require(process.cwd() + '/package.json') 7 | 8 | // console.log(require.resolve('babel-runtime')) 9 | 10 | export default { 11 | input: process.cwd() + '/index.js', 12 | output: { 13 | name: pkg.name 14 | .match(/[a-z]+/gi) 15 | .map(word => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase()) 16 | .join(''), 17 | file: pkg.browser, 18 | format: 'umd', 19 | exports: 'named', 20 | }, 21 | plugins: [ 22 | babel({ 23 | runtimeHelpers: true, 24 | exclude: ['../**/node_modules/**', '**/*.json'], 25 | }), 26 | resolve(), 27 | commonjs({ 28 | include: ['../**/node_modules/**'], 29 | namedExports: { 30 | 'text-encoding-shim': ['TextEncoder', 'TextDecoder'], 31 | // [require.resolve('mipher/dist/sha3.js')]: ['Keccak'], 32 | elliptic: ['ec'], 33 | // '../node_modules/babel-runtime/helpers/typeof.js': ['default'], 34 | }, 35 | }), 36 | json(), 37 | ], 38 | } 39 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/lifecycle/TokenDestructible.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../ownership/Ownable.sol"; 4 | import "../token/ERC20/ERC20Basic.sol"; 5 | 6 | 7 | /** 8 | * @title TokenDestructible: 9 | * @author Remco Bloemen 10 | * @dev Base contract that can be destroyed by owner. All funds in contract including 11 | * listed tokens will be sent to the owner. 12 | */ 13 | contract TokenDestructible is Ownable { 14 | 15 | constructor() public payable { } 16 | 17 | /** 18 | * @notice Terminate contract and refund to owner 19 | * @param tokens List of addresses of ERC20 or ERC20Basic token contracts to 20 | refund. 21 | * @notice The called token contracts could try to re-enter this contract. Only 22 | supply token contracts you trust. 23 | */ 24 | function destroy(address[] tokens) onlyOwner public { 25 | 26 | // Transfer tokens to owner 27 | for (uint256 i = 0; i < tokens.length; i++) { 28 | ERC20Basic token = ERC20Basic(tokens[i]); 29 | uint256 balance = token.balanceOf(this); 30 | token.transfer(owner, balance); 31 | } 32 | 33 | // Transfer Eth to owner and terminate contract 34 | selfdestruct(owner); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/rbac/Roles.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title Roles 6 | * @author Francisco Giordano (@frangio) 7 | * @dev Library for managing addresses assigned to a Role. 8 | * See RBAC.sol for example usage. 9 | */ 10 | library Roles { 11 | struct Role { 12 | mapping (address => bool) bearer; 13 | } 14 | 15 | /** 16 | * @dev give an address access to this role 17 | */ 18 | function add(Role storage role, address addr) 19 | internal 20 | { 21 | role.bearer[addr] = true; 22 | } 23 | 24 | /** 25 | * @dev remove an address' access to this role 26 | */ 27 | function remove(Role storage role, address addr) 28 | internal 29 | { 30 | role.bearer[addr] = false; 31 | } 32 | 33 | /** 34 | * @dev check if an address has this role 35 | * // reverts 36 | */ 37 | function check(Role storage role, address addr) 38 | view 39 | internal 40 | { 41 | require(has(role, addr)); 42 | } 43 | 44 | /** 45 | * @dev check if an address has this role 46 | * @return bool 47 | */ 48 | function has(Role storage role, address addr) 49 | view 50 | internal 51 | returns (bool) 52 | { 53 | return role.bearer[addr]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /signer-private-key/test/index.js: -------------------------------------------------------------------------------- 1 | const { SignerPrivateKey } = require('..') 2 | const { ec } = require('elliptic') 3 | 4 | const { ab, crypto, rlp, address } = require('@browseth/utils') 5 | 6 | const ETx = require('ethereumjs-tx') 7 | 8 | const secp256k1 = new ec('secp256k1') 9 | 10 | const pk = new SignerPrivateKey( 11 | '72307ba0c2225b6ad2f307f1c9449478a358589b83e19dcc562de189518e102d', 12 | ) 13 | 14 | //0x0 1000000 0x5208 0x89a8f5f337304eaa7caed7aa1d88b791f3d8b51d 10000000 0x 3 15 | // console.log(nonce, gasPrice, gas, to, value, ab.toHex(data), chainId) 16 | 17 | const params = { 18 | nonce: 0x0, 19 | gasPrice: 1000000, 20 | gas: 0x5208, 21 | to: Buffer.from(new ArrayBuffer(0)), 22 | value: 10000000, 23 | chainId: 3, 24 | data: Buffer.from(new ArrayBuffer(0)), 25 | } 26 | 27 | const tx = new ETx(params) 28 | 29 | tx.sign( 30 | Buffer.from( 31 | '72307ba0c2225b6ad2f307f1c9449478a358589b83e19dcc562de189518e102d', 32 | 'hex', 33 | ), 34 | ) 35 | 36 | console.log('0x' + tx.serialize().toString('hex')) 37 | console.log(ab.toHex(pk.signTransaction(params))) 38 | 39 | const object = pk.signMessage('kalnfsndlknalsdknflkasdnlkfn', false) 40 | 41 | console.log(object) 42 | 43 | console.log({ ...new ETx(ab.toHex(pk.signTransaction(params))) }) 44 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/crowdsale/distribution/PostDeliveryCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../validation/TimedCrowdsale.sol"; 4 | import "../../token/ERC20/ERC20.sol"; 5 | import "../../math/SafeMath.sol"; 6 | 7 | 8 | /** 9 | * @title PostDeliveryCrowdsale 10 | * @dev Crowdsale that locks tokens from withdrawal until it ends. 11 | */ 12 | contract PostDeliveryCrowdsale is TimedCrowdsale { 13 | using SafeMath for uint256; 14 | 15 | mapping(address => uint256) public balances; 16 | 17 | /** 18 | * @dev Withdraw tokens only after crowdsale ends. 19 | */ 20 | function withdrawTokens() public { 21 | require(hasClosed()); 22 | uint256 amount = balances[msg.sender]; 23 | require(amount > 0); 24 | balances[msg.sender] = 0; 25 | _deliverTokens(msg.sender, amount); 26 | } 27 | 28 | /** 29 | * @dev Overrides parent by storing balances instead of issuing tokens right away. 30 | * @param _beneficiary Token purchaser 31 | * @param _tokenAmount Amount of tokens purchased 32 | */ 33 | function _processPurchase( 34 | address _beneficiary, 35 | uint256 _tokenAmount 36 | ) 37 | internal 38 | { 39 | balances[_beneficiary] = balances[_beneficiary].add(_tokenAmount); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /test/utils/tx-listener.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { address } from '@browseth/utils' 3 | import { TxListener } from '@browseth/utils' 4 | import Browseth from '@browseth/browser' 5 | import Contract from '@browseth/contract' 6 | import PrivateKeySigner from '@browseth/signer-private-key' 7 | import * as units from '@browseth/units' 8 | 9 | const beth = new Browseth() 10 | 11 | beth.useOnlineAccount() 12 | 13 | describe('listen()', () => { 14 | it('should resolve txHash with receipt', async function() { 15 | this.timeout(317250) 16 | const txHash = await beth.send({ 17 | to: '0x89a8f5f337304EaA7caEd7AA1D88b791f3d8B51D', 18 | value: 124, 19 | gasPrice: units.gweiToWei(12), 20 | }) 21 | const txListener = new TxListener(beth) 22 | const receipt = await txListener.listen(txHash) 23 | expect(receipt.status).to.equal('0x1') 24 | }) 25 | 26 | it('should reject with not transaction found', function(done) { 27 | this.timeout(20000) 28 | const txListener = new TxListener(beth) 29 | txListener 30 | .listen( 31 | '0x6685ba3188f5181ccf90e95ba6e38d154ddcfdfba7835e75780e30ef6fa90dc3', 32 | ) 33 | .then(() => done('Should not have found transaction')) 34 | setTimeout(done, 6000) 35 | }) 36 | }) 37 | -------------------------------------------------------------------------------- /utils/lib/crypto.js: -------------------------------------------------------------------------------- 1 | import { Keccak } from 'mipher/dist/sha3' 2 | import { UUID } from 'mipher/dist/uuid' 3 | import { fromBytes, fromUtf8, bytesRegex, toHex } from './ab' 4 | export { keccak256, uuid, namehash } 5 | 6 | const mipherKeccak256 = new Keccak(256, 1) 7 | function keccak256(value) { 8 | return mipherKeccak256.hash(new Uint8Array(value ? fromBytes(value) : 0)) 9 | } 10 | 11 | function namehash(name) { 12 | const labels = name.split('.') 13 | if (labels[labels.length - 1] === '') { 14 | labels.pop() 15 | } 16 | if (labels[0] === '') { 17 | labels.shift() 18 | } 19 | return labels.reverse().reduce( 20 | (a, v) => 21 | toHex( 22 | keccak256( 23 | Buffer.from( 24 | a.replace('0x', '') + 25 | toHex(keccak256(fromUtf8(v))).replace('0x', ''), 26 | 'hex', 27 | ), 28 | ), 29 | ), 30 | 31 | `0x${'0'.repeat(64)}`, 32 | ) 33 | } 34 | 35 | const mipherUuid = new UUID() 36 | function uuid() { 37 | if (global.crypto && global.crypto.getRandomValues) { 38 | return mipherUuid.toString( 39 | mipherUuid.v4(global.crypto.getRandomValues(new Uint8Array(16))), 40 | ) 41 | } 42 | return mipherUuid.toString(mipherUuid.v4(require('crypto').randomBytes(16))) 43 | } 44 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/DelayedClaimable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./Claimable.sol"; 4 | 5 | 6 | /** 7 | * @title DelayedClaimable 8 | * @dev Extension for the Claimable contract, where the ownership needs to be claimed before/after 9 | * a certain block number. 10 | */ 11 | contract DelayedClaimable is Claimable { 12 | 13 | uint256 public end; 14 | uint256 public start; 15 | 16 | /** 17 | * @dev Used to specify the time period during which a pending 18 | * owner can claim ownership. 19 | * @param _start The earliest time ownership can be claimed. 20 | * @param _end The latest time ownership can be claimed. 21 | */ 22 | function setLimits(uint256 _start, uint256 _end) onlyOwner public { 23 | require(_start <= _end); 24 | end = _end; 25 | start = _start; 26 | } 27 | 28 | /** 29 | * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within 30 | * the specified start and end time. 31 | */ 32 | function claimOwnership() onlyPendingOwner public { 33 | require((block.number <= end) && (block.number >= start)); 34 | emit OwnershipTransferred(owner, pendingOwner); 35 | owner = pendingOwner; 36 | pendingOwner = address(0); 37 | end = 0; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /utils/lib/address.js: -------------------------------------------------------------------------------- 1 | import { keccak256 } from './crypto' 2 | import { fromBytes, toHex, fromUInt } from './ab' 3 | import { encode } from './rlp' 4 | // // import * as rlp from './rlp' 5 | 6 | export { isValid, from, fromAddressAndNonce } 7 | 8 | const addressLowerRegex = /^0x[\da-f]{40}$/ 9 | const addressUpperRegex = /^0x[\dA-F]{40}$/ 10 | 11 | function isValid(value) { 12 | try { 13 | return addressLowerRegex.test(value) || addressUpperRegex.test(value) 14 | } catch (e) { 15 | try { 16 | return value === from(value) 17 | } catch (e) { 18 | return false 19 | } 20 | } 21 | } 22 | 23 | function from(value) { 24 | if (value == null) { 25 | return '0x0000000000000000000000000000000000000000' 26 | } 27 | 28 | const buf = fromBytes(value) 29 | 30 | let address = toHex(buf).substring(2) 31 | const hash = toHex(keccak256(buf)).substring(2) 32 | let ret = '0x' 33 | 34 | for (let i = 0; i < address.length; i++) { 35 | if (parseInt(hash[i], 16) >= 8) { 36 | ret += address[i].toUpperCase() 37 | } else { 38 | ret += address[i] 39 | } 40 | } 41 | 42 | return ret 43 | } 44 | 45 | function fromAddressAndNonce(address, nonce) { 46 | return from( 47 | keccak256(encode([fromBytes(address), fromUInt(nonce)]).slice(12)), 48 | ) 49 | } 50 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/payment/PullPayment.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "../math/SafeMath.sol"; 5 | 6 | 7 | /** 8 | * @title PullPayment 9 | * @dev Base contract supporting async send for pull payments. Inherit from this 10 | * contract and use asyncSend instead of send or transfer. 11 | */ 12 | contract PullPayment { 13 | using SafeMath for uint256; 14 | 15 | mapping(address => uint256) public payments; 16 | uint256 public totalPayments; 17 | 18 | /** 19 | * @dev Withdraw accumulated balance, called by payee. 20 | */ 21 | function withdrawPayments() public { 22 | address payee = msg.sender; 23 | uint256 payment = payments[payee]; 24 | 25 | require(payment != 0); 26 | require(address(this).balance >= payment); 27 | 28 | totalPayments = totalPayments.sub(payment); 29 | payments[payee] = 0; 30 | 31 | payee.transfer(payment); 32 | } 33 | 34 | /** 35 | * @dev Called by the payer to store the sent amount as credit to be pulled. 36 | * @param dest The destination address of the funds. 37 | * @param amount The amount to transfer. 38 | */ 39 | function asyncSend(address dest, uint256 amount) internal { 40 | payments[dest] = payments[dest].add(amount); 41 | totalPayments = totalPayments.add(amount); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /docs/source/signers.rst: -------------------------------------------------------------------------------- 1 | .. _signers: 2 | 3 | Signers 4 | ******* 5 | 6 | A **Signer** manages a private/public key pair which is used to cryptographically sign 7 | transactions and prove ownership on the Ethereum network. 8 | 9 | ----- 10 | 11 | .. _private-key: 12 | 13 | Private Key Signer 14 | ================== 15 | 16 | .. code-block:: javascript 17 | 18 | const PrivateKeySigner = require('@browseth/signer-private-key') 19 | 20 | or 21 | 22 | .. code-block:: javascript 23 | 24 | import PrivateKeySigner from '@browseth/signer-private-key' 25 | 26 | Creating Instances 27 | ------------------ 28 | 29 | new :sup:`PrivateKeySigner` ( privateKey ) 30 | Creates a private key signer object from *privateKey* 31 | 32 | Prototype 33 | --------- 34 | 35 | :sup:`prototype` . address ( ) 36 | Returns the address of the signer generated from the privateKey 37 | 38 | :sup:`prototype` . signMessage ( message ) 39 | Returns a signed message 40 | 41 | :sup:`prototype` . signTransaction ( [params] ) 42 | Returns a signed transaction 43 | 44 | Parameters may include: 45 | 46 | - **to** 47 | 48 | - **gasPrice** 49 | 50 | - **gasLimit** 51 | 52 | - **nonce** 53 | 54 | - **data** 55 | 56 | - **value** 57 | 58 | - **chainId** 59 | 60 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC721/ERC721.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./ERC721Basic.sol"; 4 | 5 | 6 | /** 7 | * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension 8 | * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md 9 | */ 10 | contract ERC721Enumerable is ERC721Basic { 11 | function totalSupply() public view returns (uint256); 12 | function tokenOfOwnerByIndex( 13 | address _owner, 14 | uint256 _index 15 | ) 16 | public 17 | view 18 | returns (uint256 _tokenId); 19 | 20 | function tokenByIndex(uint256 _index) public view returns (uint256); 21 | } 22 | 23 | 24 | /** 25 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension 26 | * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md 27 | */ 28 | contract ERC721Metadata is ERC721Basic { 29 | function name() public view returns (string _name); 30 | function symbol() public view returns (string _symbol); 31 | function tokenURI(uint256 _tokenId) public view returns (string); 32 | } 33 | 34 | 35 | /** 36 | * @title ERC-721 Non-Fungible Token Standard, full implementation interface 37 | * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md 38 | */ 39 | contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { 40 | } 41 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/crowdsale/validation/CappedCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../../math/SafeMath.sol"; 4 | import "../Crowdsale.sol"; 5 | 6 | 7 | /** 8 | * @title CappedCrowdsale 9 | * @dev Crowdsale with a limit for total contributions. 10 | */ 11 | contract CappedCrowdsale is Crowdsale { 12 | using SafeMath for uint256; 13 | 14 | uint256 public cap; 15 | 16 | /** 17 | * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. 18 | * @param _cap Max amount of wei to be contributed 19 | */ 20 | constructor(uint256 _cap) public { 21 | require(_cap > 0); 22 | cap = _cap; 23 | } 24 | 25 | /** 26 | * @dev Checks whether the cap has been reached. 27 | * @return Whether the cap was reached 28 | */ 29 | function capReached() public view returns (bool) { 30 | return weiRaised >= cap; 31 | } 32 | 33 | /** 34 | * @dev Extend parent behavior requiring purchase to respect the funding cap. 35 | * @param _beneficiary Token purchaser 36 | * @param _weiAmount Amount of wei contributed 37 | */ 38 | function _preValidatePurchase( 39 | address _beneficiary, 40 | uint256 _weiAmount 41 | ) 42 | internal 43 | { 44 | super._preValidatePurchase(_beneficiary, _weiAmount); 45 | require(weiRaised.add(_weiAmount) <= cap); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /test/utils/observable.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { Observable } from '@browseth/utils' 3 | import sinon from 'sinon' 4 | 5 | describe('constructor()', () => { 6 | it('should set value in constructor', () => { 7 | const observable = new Observable('123') 8 | expect(observable.get()).to.equal('123') 9 | }) 10 | }) 11 | 12 | describe('set()', () => { 13 | it('should set value on set', () => { 14 | const observable = new Observable('123') 15 | observable.set('333') 16 | expect(observable.get()).to.equal('333') 17 | }) 18 | }) 19 | 20 | describe('subscribe()', () => { 21 | it('should invoke callback on set', done => { 22 | const spy = sinon.spy() 23 | const observable = new Observable('123') 24 | const unsubscribe = observable.subscribe(() => spy()) 25 | observable.set('333') 26 | setTimeout(() => { 27 | sinon.assert.calledOnce(spy) 28 | done() 29 | }, 300) 30 | }).timeout(500) 31 | }) 32 | 33 | describe('unsubscribe()', () => { 34 | it('should not invoke callback on set', done => { 35 | const spy = sinon.spy() 36 | const observable = new Observable('123') 37 | const unsubscribe = observable.subscribe(spy) 38 | unsubscribe() 39 | observable.set('333') 40 | setTimeout(() => { 41 | sinon.assert.notCalled(spy) 42 | done() 43 | }, 300) 44 | }).timeout(500) 45 | }) 46 | -------------------------------------------------------------------------------- /contract/index.d.ts: -------------------------------------------------------------------------------- 1 | export = ContractNamespace 2 | export as namespace ContractNamespace 3 | 4 | declare namespace ContractNamespace { 5 | export { Contract as default, Contract } 6 | 7 | class Contract { 8 | constructor( 9 | ethRef, 10 | abiJsonInterface: object[], 11 | options: { 12 | bin: string | ArrayBuffer | ArrayBufferView 13 | address: string | ArrayBuffer | ArrayBufferView 14 | }, 15 | ) 16 | 17 | construct( 18 | ...args 19 | ): { 20 | send(params?): Promise 21 | gas(params?): Promise 22 | abi: ArrayBuffer 23 | } 24 | 25 | fallback(): { 26 | send(params?): Promise 27 | gas(params?): Promise 28 | } 29 | 30 | fn: { 31 | [key: string]: ( 32 | ...args 33 | ) => { 34 | send(params?): Promise 35 | gas(params?): Promise 36 | call(params?, block?): Promise 37 | abi: ArrayBuffer 38 | } 39 | } 40 | 41 | ev: { 42 | [key: string]: ( 43 | ...args 44 | ) => { 45 | logs(from?, to?, ...addresses): Promise 46 | subscribe( 47 | from?, 48 | ...addresses 49 | ): { 50 | on(fn: Function): void 51 | off(fn?: Function): void 52 | dispose(): void 53 | } 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /utils/lib/emitter.js: -------------------------------------------------------------------------------- 1 | export { emit, off, on, onEvery, Emitter, Emitter as default } 2 | 3 | const emitterWM = new WeakMap() 4 | 5 | class Emitter { 6 | static EVERY = Symbol('EVERY') 7 | EVERY = this.constructor.EVERY 8 | 9 | constructor() { 10 | emitterWM.set(this, new Map().set(this.EVERY, new Set())) 11 | } 12 | 13 | on = (event, fn) => { 14 | let eventM = emitterWM.get(this) 15 | 16 | if (eventM.has(event)) { 17 | eventM.get(event).add(fn) 18 | } else { 19 | eventM.set(event, new Set().add(fn)) 20 | } 21 | } 22 | 23 | onEvery = fn => this.on(this.EVERY, fn) 24 | 25 | off = (event, fn) => { 26 | const eventM = emitterWM.get(this) 27 | 28 | if (fn) { 29 | if (eventM.has(event)) { 30 | eventM[event].delete(fn) 31 | } 32 | } else if (event) { 33 | eventM.delete(event) 34 | } else { 35 | emitterWM.set(this, new Map()) 36 | } 37 | } 38 | 39 | emit = (event, ...params) => { 40 | const eventM = emitterWM.get(this) 41 | 42 | for (const fn of eventM.get(Emitter.EVERY)) { 43 | fn.call(this, { event, params }) 44 | } 45 | 46 | if (eventM.has(event)) { 47 | for (const fn of eventM.get(event)) { 48 | fn.apply(this, params) 49 | } 50 | } 51 | } 52 | } 53 | 54 | const globalEmitter = new Emitter() 55 | const { on, off, emit, onEvery } = globalEmitter 56 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/TokenTimelock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./SafeERC20.sol"; 4 | 5 | 6 | /** 7 | * @title TokenTimelock 8 | * @dev TokenTimelock is a token holder contract that will allow a 9 | * beneficiary to extract the tokens after a given release time 10 | */ 11 | contract TokenTimelock { 12 | using SafeERC20 for ERC20Basic; 13 | 14 | // ERC20 basic token contract being held 15 | ERC20Basic public token; 16 | 17 | // beneficiary of tokens after they are released 18 | address public beneficiary; 19 | 20 | // timestamp when token release is enabled 21 | uint256 public releaseTime; 22 | 23 | constructor( 24 | ERC20Basic _token, 25 | address _beneficiary, 26 | uint256 _releaseTime 27 | ) 28 | public 29 | { 30 | // solium-disable-next-line security/no-block-members 31 | require(_releaseTime > block.timestamp); 32 | token = _token; 33 | beneficiary = _beneficiary; 34 | releaseTime = _releaseTime; 35 | } 36 | 37 | /** 38 | * @notice Transfers tokens held by timelock to beneficiary. 39 | */ 40 | function release() public { 41 | // solium-disable-next-line security/no-block-members 42 | require(block.timestamp >= releaseTime); 43 | 44 | uint256 amount = token.balanceOf(this); 45 | require(amount > 0); 46 | 47 | token.safeTransfer(beneficiary, amount); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /cli/subscription/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Browseth from 'browseth'; 3 | import SubscriptionPage from './components/SubscriptionPage'; 4 | import './App.css'; 5 | import * as config from './config.json'; 6 | import * as SubscriptionAbi from './components/NFTSubscription.json'; 7 | 8 | class App extends React.PureComponent { 9 | render() { 10 | const beth = new Browseth(); 11 | beth.wallet = new Browseth.Wallets.Online( 12 | // new Browseth.Rpcs.Web3(window.web3.currentProvider), 13 | beth.rpc, 14 | ); 15 | beth.addContract('freeSubscription', SubscriptionAbi, { 16 | address: config.freeAddress, 17 | }); 18 | beth.addContract('paidSubscription', SubscriptionAbi, { 19 | address: config.paidAddress, 20 | }); 21 | 22 | return ( 23 |
24 |
25 |

Example Subscription

26 |
27 | {window.web3 ? ( 28 | 29 | ) : ( 30 |
31 |

Error!

32 |

33 | No Web3!! Try installing/enabling the{' '} 34 | Metamask extension, then 35 | refresh the page. 36 |

37 |
38 | )} 39 |
40 | ); 41 | } 42 | } 43 | 44 | export default App; 45 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/examples/SimpleSavingsWallet.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../ownership/Heritable.sol"; 4 | 5 | 6 | /** 7 | * @title SimpleSavingsWallet 8 | * @dev Simplest form of savings wallet whose ownership can be claimed by a heir 9 | * if owner dies. 10 | * In this example, we take a very simple savings wallet providing two operations 11 | * (to send and receive funds) and extend its capabilities by making it Heritable. 12 | * The account that creates the contract is set as owner, who has the authority to 13 | * choose an heir account. Heir account can reclaim the contract ownership in the 14 | * case that the owner dies. 15 | */ 16 | contract SimpleSavingsWallet is Heritable { 17 | 18 | event Sent(address indexed payee, uint256 amount, uint256 balance); 19 | event Received(address indexed payer, uint256 amount, uint256 balance); 20 | 21 | 22 | constructor(uint256 _heartbeatTimeout) Heritable(_heartbeatTimeout) public {} 23 | 24 | /** 25 | * @dev wallet can receive funds. 26 | */ 27 | function () public payable { 28 | emit Received(msg.sender, msg.value, address(this).balance); 29 | } 30 | 31 | /** 32 | * @dev wallet can send funds 33 | */ 34 | function sendTo(address payee, uint256 amount) public onlyOwner { 35 | require(payee != 0 && payee != address(this)); 36 | require(amount > 0); 37 | payee.transfer(amount); 38 | emit Sent(payee, amount, address(this).balance); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC721/ERC721Receiver.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title ERC721 token receiver interface 6 | * @dev Interface for any contract that wants to support safeTransfers 7 | * from ERC721 asset contracts. 8 | */ 9 | contract ERC721Receiver { 10 | /** 11 | * @dev Magic value to be returned upon successful reception of an NFT 12 | * Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`, 13 | * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` 14 | */ 15 | bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba; 16 | 17 | /** 18 | * @notice Handle the receipt of an NFT 19 | * @dev The ERC721 smart contract calls this function on the recipient 20 | * after a `safetransfer`. This function MAY throw to revert and reject the 21 | * transfer. This function MUST use 50,000 gas or less. Return of other 22 | * than the magic value MUST result in the transaction being reverted. 23 | * Note: the contract address is always the message sender. 24 | * @param _from The sending address 25 | * @param _tokenId The NFT identifier which is being transfered 26 | * @param _data Additional data with no specified format 27 | * @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))` 28 | */ 29 | function onERC721Received( 30 | address _from, 31 | uint256 _tokenId, 32 | bytes _data 33 | ) 34 | public 35 | returns(bytes4); 36 | } 37 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/MerkleProof.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /* 5 | * @title MerkleProof 6 | * @dev Merkle proof verification 7 | * @note Based on https://github.com/ameensol/merkle-tree-solidity/blob/master/src/MerkleProof.sol 8 | */ 9 | library MerkleProof { 10 | /* 11 | * @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves 12 | * and each pair of pre-images is sorted. 13 | * @param _proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree 14 | * @param _root Merkle root 15 | * @param _leaf Leaf of Merkle tree 16 | */ 17 | function verifyProof( 18 | bytes32[] _proof, 19 | bytes32 _root, 20 | bytes32 _leaf 21 | ) 22 | internal 23 | pure 24 | returns (bool) 25 | { 26 | bytes32 computedHash = _leaf; 27 | 28 | for (uint256 i = 0; i < _proof.length; i++) { 29 | bytes32 proofElement = _proof[i]; 30 | 31 | if (computedHash < proofElement) { 32 | // Hash(current computed hash + current element of the proof) 33 | computedHash = keccak256(computedHash, proofElement); 34 | } else { 35 | // Hash(current element of the proof + current computed hash) 36 | computedHash = keccak256(proofElement, computedHash); 37 | } 38 | } 39 | 40 | // Check if the computed hash (root) is equal to the provided root 41 | return computedHash == _root; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/BasicToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | import "./ERC20Basic.sol"; 5 | import "../../math/SafeMath.sol"; 6 | 7 | 8 | /** 9 | * @title Basic token 10 | * @dev Basic version of StandardToken, with no allowances. 11 | */ 12 | contract BasicToken is ERC20Basic { 13 | using SafeMath for uint256; 14 | 15 | mapping(address => uint256) balances; 16 | 17 | uint256 totalSupply_; 18 | 19 | /** 20 | * @dev total number of tokens in existence 21 | */ 22 | function totalSupply() public view returns (uint256) { 23 | return totalSupply_; 24 | } 25 | 26 | /** 27 | * @dev transfer token for a specified address 28 | * @param _to The address to transfer to. 29 | * @param _value The amount to be transferred. 30 | */ 31 | function transfer(address _to, uint256 _value) public returns (bool) { 32 | require(_to != address(0)); 33 | require(_value <= balances[msg.sender]); 34 | 35 | balances[msg.sender] = balances[msg.sender].sub(_value); 36 | balances[_to] = balances[_to].add(_value); 37 | emit Transfer(msg.sender, _to, _value); 38 | return true; 39 | } 40 | 41 | /** 42 | * @dev Gets the balance of the specified address. 43 | * @param _owner The address to query the the balance of. 44 | * @return An uint256 representing the amount owned by the passed address. 45 | */ 46 | function balanceOf(address _owner) public view returns (uint256) { 47 | return balances[_owner]; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /test/ens/index.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { crypto } from '@browseth/utils' 3 | import EnsLookup from '@browseth/ens' 4 | import Browseth from '@browseth/browser' 5 | 6 | const beth = new Browseth('https://mainnet.infura.io/mew') 7 | const ensLookup = new EnsLookup(beth) 8 | 9 | const node = 10 | '0xd22199aae12a9820651b06cb6da9f5d4cccc53f925d7f1ec7e07682f8847ec41' 11 | 12 | describe('address()', () => { 13 | it('should return address set in resolver', async function() { 14 | this.timeout(20000) 15 | 16 | expect(await ensLookup.address(node)).to.equal( 17 | '0x89a8f5f337304eaa7caed7aa1d88b791f3d8b51d', 18 | ) 19 | }) 20 | }) 21 | 22 | describe('resolverAddress()', () => { 23 | it('should return resolver address', async function() { 24 | this.timeout(20000) 25 | 26 | expect(await ensLookup.resolverAddress(node)).to.equal( 27 | '0x63821ad02f2149977b1f362cdc2f0cd7705efe2a', 28 | ) 29 | }) 30 | }) 31 | 32 | describe('allTexts()', () => { 33 | it('should return all text changes on key', async function() { 34 | this.timeout(20000) 35 | 36 | console.log(await ensLookup.allTexts(node, 'twitter')) 37 | // ens events not working 38 | // abi codec for events is broken in @browseth/ens 39 | }) 40 | }) 41 | 42 | describe('text()', () => { 43 | it('should return current twitter text', async function() { 44 | this.timeout(20000) 45 | 46 | expect(await ensLookup.text(node, 'twitter')).to.equal('ryan_cle') 47 | }) 48 | }) 49 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/HasNoEther.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./Ownable.sol"; 4 | 5 | 6 | /** 7 | * @title Contracts that should not own Ether 8 | * @author Remco Bloemen 9 | * @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up 10 | * in the contract, it will allow the owner to reclaim this ether. 11 | * @notice Ether can still be sent to this contract by: 12 | * calling functions labeled `payable` 13 | * `selfdestruct(contract_address)` 14 | * mining directly to the contract address 15 | */ 16 | contract HasNoEther is Ownable { 17 | 18 | /** 19 | * @dev Constructor that rejects incoming Ether 20 | * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we 21 | * leave out payable, then Solidity will allow inheriting contracts to implement a payable 22 | * constructor. By doing it this way we prevent a payable constructor from working. Alternatively 23 | * we could use assembly to access msg.value. 24 | */ 25 | constructor() public payable { 26 | require(msg.value == 0); 27 | } 28 | 29 | /** 30 | * @dev Disallows direct send by settings a default function without the `payable` flag. 31 | */ 32 | function() external { 33 | } 34 | 35 | /** 36 | * @dev Transfer all Ether held by the contract to the owner. 37 | */ 38 | function reclaimEther() external onlyOwner { 39 | owner.transfer(address(this).balance); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/crowdsale/emission/AllowanceCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../Crowdsale.sol"; 4 | import "../../token/ERC20/ERC20.sol"; 5 | import "../../math/SafeMath.sol"; 6 | 7 | 8 | /** 9 | * @title AllowanceCrowdsale 10 | * @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale. 11 | */ 12 | contract AllowanceCrowdsale is Crowdsale { 13 | using SafeMath for uint256; 14 | 15 | address public tokenWallet; 16 | 17 | /** 18 | * @dev Constructor, takes token wallet address. 19 | * @param _tokenWallet Address holding the tokens, which has approved allowance to the crowdsale 20 | */ 21 | constructor(address _tokenWallet) public { 22 | require(_tokenWallet != address(0)); 23 | tokenWallet = _tokenWallet; 24 | } 25 | 26 | /** 27 | * @dev Checks the amount of tokens left in the allowance. 28 | * @return Amount of tokens left in the allowance 29 | */ 30 | function remainingTokens() public view returns (uint256) { 31 | return token.allowance(tokenWallet, this); 32 | } 33 | 34 | /** 35 | * @dev Overrides parent behavior by transferring tokens from wallet. 36 | * @param _beneficiary Token purchaser 37 | * @param _tokenAmount Amount of tokens purchased 38 | */ 39 | function _deliverTokens( 40 | address _beneficiary, 41 | uint256 _tokenAmount 42 | ) 43 | internal 44 | { 45 | token.transferFrom(tokenWallet, _beneficiary, _tokenAmount); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/mocks/RBACMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "../examples/RBACWithAdmin.sol"; 4 | 5 | 6 | contract RBACMock is RBACWithAdmin { 7 | 8 | string constant ROLE_ADVISOR = "advisor"; 9 | 10 | modifier onlyAdminOrAdvisor() 11 | { 12 | require( 13 | hasRole(msg.sender, ROLE_ADMIN) || 14 | hasRole(msg.sender, ROLE_ADVISOR) 15 | ); 16 | _; 17 | } 18 | 19 | constructor(address[] _advisors) 20 | public 21 | { 22 | addRole(msg.sender, ROLE_ADVISOR); 23 | 24 | for (uint256 i = 0; i < _advisors.length; i++) { 25 | addRole(_advisors[i], ROLE_ADVISOR); 26 | } 27 | } 28 | 29 | function onlyAdminsCanDoThis() 30 | onlyAdmin 31 | view 32 | external 33 | { 34 | } 35 | 36 | function onlyAdvisorsCanDoThis() 37 | onlyRole(ROLE_ADVISOR) 38 | view 39 | external 40 | { 41 | } 42 | 43 | function eitherAdminOrAdvisorCanDoThis() 44 | onlyAdminOrAdvisor 45 | view 46 | external 47 | { 48 | } 49 | 50 | function nobodyCanDoThis() 51 | onlyRole("unknown") 52 | view 53 | external 54 | { 55 | } 56 | 57 | // admins can remove advisor's role 58 | function removeAdvisor(address _addr) 59 | onlyAdmin 60 | public 61 | { 62 | // revert if the user isn't an advisor 63 | // (perhaps you want to soft-fail here instead?) 64 | checkRole(_addr, ROLE_ADVISOR); 65 | 66 | // remove the advisor's role 67 | removeRole(_addr, ROLE_ADVISOR); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/PausableToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./StandardToken.sol"; 4 | import "../../lifecycle/Pausable.sol"; 5 | 6 | 7 | /** 8 | * @title Pausable token 9 | * @dev StandardToken modified with pausable transfers. 10 | **/ 11 | contract PausableToken is StandardToken, Pausable { 12 | 13 | function transfer( 14 | address _to, 15 | uint256 _value 16 | ) 17 | public 18 | whenNotPaused 19 | returns (bool) 20 | { 21 | return super.transfer(_to, _value); 22 | } 23 | 24 | function transferFrom( 25 | address _from, 26 | address _to, 27 | uint256 _value 28 | ) 29 | public 30 | whenNotPaused 31 | returns (bool) 32 | { 33 | return super.transferFrom(_from, _to, _value); 34 | } 35 | 36 | function approve( 37 | address _spender, 38 | uint256 _value 39 | ) 40 | public 41 | whenNotPaused 42 | returns (bool) 43 | { 44 | return super.approve(_spender, _value); 45 | } 46 | 47 | function increaseApproval( 48 | address _spender, 49 | uint _addedValue 50 | ) 51 | public 52 | whenNotPaused 53 | returns (bool success) 54 | { 55 | return super.increaseApproval(_spender, _addedValue); 56 | } 57 | 58 | function decreaseApproval( 59 | address _spender, 60 | uint _subtractedValue 61 | ) 62 | public 63 | whenNotPaused 64 | returns (bool success) 65 | { 66 | return super.decreaseApproval(_spender, _subtractedValue); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC721/ERC721Basic.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title ERC721 Non-Fungible Token Standard basic interface 6 | * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md 7 | */ 8 | contract ERC721Basic { 9 | event Transfer( 10 | address indexed _from, 11 | address indexed _to, 12 | uint256 _tokenId 13 | ); 14 | event Approval( 15 | address indexed _owner, 16 | address indexed _approved, 17 | uint256 _tokenId 18 | ); 19 | event ApprovalForAll( 20 | address indexed _owner, 21 | address indexed _operator, 22 | bool _approved 23 | ); 24 | 25 | function balanceOf(address _owner) public view returns (uint256 _balance); 26 | function ownerOf(uint256 _tokenId) public view returns (address _owner); 27 | function exists(uint256 _tokenId) public view returns (bool _exists); 28 | 29 | function approve(address _to, uint256 _tokenId) public; 30 | function getApproved(uint256 _tokenId) 31 | public view returns (address _operator); 32 | 33 | function setApprovalForAll(address _operator, bool _approved) public; 34 | function isApprovedForAll(address _owner, address _operator) 35 | public view returns (bool); 36 | 37 | function transferFrom(address _from, address _to, uint256 _tokenId) public; 38 | function safeTransferFrom(address _from, address _to, uint256 _tokenId) 39 | public; 40 | 41 | function safeTransferFrom( 42 | address _from, 43 | address _to, 44 | uint256 _tokenId, 45 | bytes _data 46 | ) 47 | public; 48 | } 49 | -------------------------------------------------------------------------------- /cli/wallet_gen/src/components/EnableWallet.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import '../App.css'; 3 | import EnablePrivateKey from './EnablePrivateKey'; 4 | import EnableLedger from './EnableLedger'; 5 | import EnableMetaMask from './EnableMetaMask'; 6 | import EnableKeystore from './EnableKeystore'; 7 | 8 | class EnableWallet extends React.Component { 9 | state = { 10 | privateKey: '', 11 | }; 12 | 13 | auth = () => { 14 | this.props.enable(); 15 | }; 16 | 17 | render() { 18 | switch (this.props.state) { 19 | case 'privateKey': 20 | return ( 21 | 26 | ); 27 | case 'ledger': 28 | return ( 29 | 34 | ); 35 | case 'keystore': 36 | return ( 37 | 42 | ); 43 | case 'metamask': 44 | return ( 45 | 50 | ); 51 | default: 52 | return
Error!
; 53 | } 54 | } 55 | } 56 | 57 | export default EnableWallet; 58 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/math/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title SafeMath 6 | * @dev Math operations with safety checks that throw on error 7 | */ 8 | library SafeMath { 9 | 10 | /** 11 | * @dev Multiplies two numbers, throws on overflow. 12 | */ 13 | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { 14 | // Gas optimization: this is cheaper than asserting 'a' not being zero, but the 15 | // benefit is lost if 'b' is also tested. 16 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 17 | if (a == 0) { 18 | return 0; 19 | } 20 | 21 | c = a * b; 22 | assert(c / a == b); 23 | return c; 24 | } 25 | 26 | /** 27 | * @dev Integer division of two numbers, truncating the quotient. 28 | */ 29 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 30 | // assert(b > 0); // Solidity automatically throws when dividing by 0 31 | // uint256 c = a / b; 32 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 33 | return a / b; 34 | } 35 | 36 | /** 37 | * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). 38 | */ 39 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 40 | assert(b <= a); 41 | return a - b; 42 | } 43 | 44 | /** 45 | * @dev Adds two numbers, throws on overflow. 46 | */ 47 | function add(uint256 a, uint256 b) internal pure returns (uint256 c) { 48 | c = a + b; 49 | assert(c >= a); 50 | return c; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@browseth/workspace", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "private": true, 6 | "workspaces": [ 7 | "*" 8 | ], 9 | "devDependencies": { 10 | "babel-core": "^6.26.3", 11 | "babel-plugin-external-helpers": "^6.22.0", 12 | "babel-plugin-transform-async-to-generator": "^6.24.1", 13 | "babel-plugin-transform-class-properties": "^6.24.1", 14 | "babel-plugin-transform-decorators-legacy": "^1.3.5", 15 | "babel-plugin-transform-object-rest-spread": "^6.26.0", 16 | "babel-plugin-transform-react-jsx": "^6.24.1", 17 | "babel-plugin-transform-runtime": "^6.23.0", 18 | "babel-preset-env": "^1.7.0", 19 | "babel-preset-es2015": "^6.24.1", 20 | "babel-register": "^6.26.0", 21 | "chai": "^4.1.2", 22 | "ethereumjs-tx": "^1.3.7", 23 | "isomorphic-fetch": "^2.2.1", 24 | "lerna": "^3.0.0-rc.0", 25 | "mocha": "^5.2.0", 26 | "prettier": "^1.14.2", 27 | "rollup": "^0.63.4", 28 | "rollup-plugin-babel": "^3.0.7", 29 | "rollup-plugin-commonjs": "^9.1.4", 30 | "rollup-plugin-json": "^3.0.0", 31 | "rollup-plugin-node-resolve": "^3.3.0", 32 | "sinon": "^6.3.4" 33 | }, 34 | "scripts": { 35 | "format": "prettier --write -l **/*.{js,json,d.ts}", 36 | "prebuild-safe": "yarn --force", 37 | "build-safe": "lerna exec --concurrency 1 'yarn build-node' && lerna exec --concurrency 1 'yarn build-browser'", 38 | "build": "lerna exec --concurrency 100 'yarn build'", 39 | "start": "lerna exec --concurrency 100 'yarn start'", 40 | "test": "./node_modules/.bin/mocha --require test/babel-hook.js test/index.js" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /cli/sample_site/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 23 | Browseth App 24 | 25 | 26 | 27 | 30 |
31 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ens/test/index.js: -------------------------------------------------------------------------------- 1 | require('isomorphic-fetch') 2 | const { EnsLookup } = require('..') 3 | const { JsonRpcRequestBatchQueue } = require('@browseth/jsonrpc-request-queue') 4 | 5 | process.on('unhandledRejection', console.error) 6 | 7 | const ens = new EnsLookup( 8 | new JsonRpcRequestBatchQueue('https://mainnet.infura.io/mew'), 9 | ) 10 | const interval = setInterval(() => {}, 10000) 11 | Promise.resolve() 12 | .then(async () => { 13 | console.time('req') 14 | await Promise.all([ 15 | ens.info( 16 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 17 | ), 18 | ens.info( 19 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 20 | ), 21 | ens.info( 22 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 23 | ), 24 | ens.info( 25 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 26 | ), 27 | ens.info( 28 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 29 | ), 30 | ens.info( 31 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 32 | ), 33 | ens.info( 34 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 35 | ), 36 | ens.info( 37 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 38 | ), 39 | ens.info( 40 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 41 | ), 42 | ens.info( 43 | '0xfdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5', 44 | ), 45 | ]) 46 | console.timeEnd('req') 47 | }) 48 | .catch(console.error) 49 | .then(() => clearInterval(interval)) 50 | -------------------------------------------------------------------------------- /test/utils/address.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { address } from '@browseth/utils' 3 | 4 | describe('isValid', () => { 5 | it('should return false', () => { 6 | expect(address.isValid('0x0')).to.be.false 7 | expect(address.isValid('0x0112222222222222')).to.be.false 8 | expect(address.isValid('0xffffffffffffffffffffff')).to.be.false 9 | expect(address.isValid('0xfffffffffffffffffffffffffffffffffffgffff')).to.be 10 | .false 11 | expect(address.isValid('ffffffffffffffffffffffffffffffffffffffff')).to.be 12 | .false 13 | }) 14 | it('should return true', () => { 15 | expect(address.isValid('0x0000000000000000000000000000000000000000')).to.be 16 | .true 17 | expect(address.isValid('0xffffffffffffffffffffffffffffffffffffffff')).to.be 18 | .true 19 | }) 20 | }) 21 | 22 | describe('from', () => { 23 | it('should throw TypeError', () => { 24 | const val = 'asdfasdfasdf' 25 | expect(() => address.from(val)).to.throw(`invalid value '${val}'`) 26 | }) 27 | it("should return 0x${'0'.repeat(40)}", () => { 28 | expect(address.from(null)).to.equal( 29 | '0x0000000000000000000000000000000000000000', 30 | ) 31 | }) 32 | it('should convert bytes to hex', () => { 33 | expect(address.from(new Buffer('asdfasdf'))).to.equal('0x6173646661736466') 34 | expect(address.from(new Buffer('0x6173646661736466'))).to.equal( 35 | '0x307836313733363436363631373336343636', 36 | ) 37 | }) 38 | }) 39 | 40 | describe('fromAddressAndNonce', () => { 41 | it('should encode address and nonce', () => { 42 | expect(address.fromAddressAndNonce(new Buffer('asdf'), 12)).to.equal( 43 | '0xc5D2460186F7233c927E7DB2Dcc703C0E500B653ca82273b7BfAd8045D85a470', 44 | ) 45 | }) 46 | }) 47 | -------------------------------------------------------------------------------- /cli/wallet_gen/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 22 | React App 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /cli/subscription/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 22 | React App 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /utils/lib/param.js: -------------------------------------------------------------------------------- 1 | import * as ab from './ab' 2 | 3 | export { 4 | toData, 5 | toQuantity, 6 | toTag, 7 | isData, 8 | isQuantity, 9 | isTag, 10 | fromData, 11 | fromQuantity, 12 | fromTag, 13 | } 14 | 15 | function toData(value, length) { 16 | return ab.toHex(ab.fromBytes(value, length)) 17 | } 18 | 19 | function toQuantity(value) { 20 | const hexStr = ab.toHex(ab.fromUInt(value)) 21 | 22 | if (hexStr[2] === '0') return '0x' + hexStr.slice(3) 23 | return hexStr 24 | } 25 | 26 | function toTag(value) { 27 | if (value === 'pending' || value === 'latest' || value === 'earliest') { 28 | return value 29 | } 30 | return toQuantity(value) 31 | } 32 | 33 | function isData(value, length = -1) { 34 | if (typeof value === 'string' && ab.bytesRegex.test(value)) return true 35 | else if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) 36 | return length === -1 || length === value.byteLength 37 | return false 38 | } 39 | 40 | function isQuantity(value) { 41 | if (typeof value === 'number' && Number.isInteger(value) && value >= 0) 42 | return true 43 | else if (typeof value === 'string' && ab.hexNumberRegex.test(value)) 44 | return true 45 | return false 46 | } 47 | 48 | function isTag(value) { 49 | if (value === 'pending' || value === 'latest' || value === 'earliest') { 50 | return true 51 | } 52 | return isQuantity(value) 53 | } 54 | 55 | function fromData(value, length) { 56 | return new Uint8Array(ab.fromBytes(value, length)) 57 | } 58 | 59 | function fromQuantity(value) { 60 | // change to BigNumber 61 | return BigInt(value) 62 | } 63 | 64 | function fromTag(value) { 65 | if (value === 'pending' || value === 'latest' || value === 'earliest') { 66 | return value 67 | } 68 | return fromQuantity(value) 69 | } 70 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/ownership/Ownable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address public owner; 11 | 12 | 13 | event OwnershipRenounced(address indexed previousOwner); 14 | event OwnershipTransferred( 15 | address indexed previousOwner, 16 | address indexed newOwner 17 | ); 18 | 19 | 20 | /** 21 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 22 | * account. 23 | */ 24 | constructor() public { 25 | owner = msg.sender; 26 | } 27 | 28 | /** 29 | * @dev Throws if called by any account other than the owner. 30 | */ 31 | modifier onlyOwner() { 32 | require(msg.sender == owner); 33 | _; 34 | } 35 | 36 | /** 37 | * @dev Allows the current owner to relinquish control of the contract. 38 | */ 39 | function renounceOwnership() public onlyOwner { 40 | emit OwnershipRenounced(owner); 41 | owner = address(0); 42 | } 43 | 44 | /** 45 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 46 | * @param _newOwner The address to transfer ownership to. 47 | */ 48 | function transferOwnership(address _newOwner) public onlyOwner { 49 | _transferOwnership(_newOwner); 50 | } 51 | 52 | /** 53 | * @dev Transfers control of the contract to a newOwner. 54 | * @param _newOwner The address to transfer ownership to. 55 | */ 56 | function _transferOwnership(address _newOwner) internal { 57 | require(_newOwner != address(0)); 58 | emit OwnershipTransferred(owner, _newOwner); 59 | owner = _newOwner; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /cli/subscription/contracts/zeppelin/token/ERC20/MintableToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import "./StandardToken.sol"; 4 | import "../../ownership/Ownable.sol"; 5 | 6 | 7 | /** 8 | * @title Mintable token 9 | * @dev Simple ERC20 Token example, with mintable token creation 10 | * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 11 | * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol 12 | */ 13 | contract MintableToken is StandardToken, Ownable { 14 | event Mint(address indexed to, uint256 amount); 15 | event MintFinished(); 16 | 17 | bool public mintingFinished = false; 18 | 19 | 20 | modifier canMint() { 21 | require(!mintingFinished); 22 | _; 23 | } 24 | 25 | modifier hasMintPermission() { 26 | require(msg.sender == owner); 27 | _; 28 | } 29 | 30 | /** 31 | * @dev Function to mint tokens 32 | * @param _to The address that will receive the minted tokens. 33 | * @param _amount The amount of tokens to mint. 34 | * @return A boolean that indicates if the operation was successful. 35 | */ 36 | function mint( 37 | address _to, 38 | uint256 _amount 39 | ) 40 | hasMintPermission 41 | canMint 42 | public 43 | returns (bool) 44 | { 45 | totalSupply_ = totalSupply_.add(_amount); 46 | balances[_to] = balances[_to].add(_amount); 47 | emit Mint(_to, _amount); 48 | emit Transfer(address(0), _to, _amount); 49 | return true; 50 | } 51 | 52 | /** 53 | * @dev Function to stop minting new tokens. 54 | * @return True if the operation was successful. 55 | */ 56 | function finishMinting() onlyOwner canMint public returns (bool) { 57 | mintingFinished = true; 58 | emit MintFinished(); 59 | return true; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /units/index.js: -------------------------------------------------------------------------------- 1 | import { BigNumber } from 'bignumber.js' 2 | 3 | export { unitToPow, convert, etherToWei, gweiToWei, toWei, toEther, weiToEther } 4 | 5 | BigNumber.config({ DECIMAL_PLACES: 1000, EXPONENTIAL_AT: [-1000, 1000] }) 6 | 7 | const units = { 8 | wei: 0, 9 | kwei: 3, 10 | ada: 3, 11 | femtoether: 3, 12 | mwei: 6, 13 | babbage: 6, 14 | picoether: 6, 15 | gwei: 9, 16 | shannon: 9, 17 | nanoether: 9, 18 | nano: 9, 19 | szabo: 12, 20 | microether: 12, 21 | micro: 12, 22 | finney: 15, 23 | milliether: 15, 24 | milli: 15, 25 | ether: 18, 26 | kether: 21, 27 | grand: 24, 28 | einstein: 24, 29 | mether: 27, 30 | gether: 30, 31 | tether: 33, 32 | } 33 | 34 | function unitToPow(unit) { 35 | const lowercasedUnit = unit[0].toLowerCase() + unit.slice(1) 36 | 37 | if (lowercasedUnit in units) return units[lowercasedUnit] 38 | 39 | throw new TypeError('invalid unit ' + unit) 40 | } 41 | 42 | function convert(fromUnit, value, toUnit) { 43 | let fromPow = unitToPow(fromUnit) 44 | let toPow = unitToPow(toUnit) 45 | const isSmallerizing = fromPow < toPow 46 | const scaler = new BigNumber(10).pow(new BigNumber(Math.abs(toPow - fromPow))) 47 | const result = new BigNumber(value)[isSmallerizing ? 'div' : 'times'](scaler) 48 | 49 | if (toPow === 0) return '0x' + result.toString(16) 50 | 51 | return result.toString() 52 | } 53 | 54 | function etherToWei(value) { 55 | return convert('ether', value, 'wei') 56 | } 57 | 58 | function gweiToWei(value) { 59 | return convert('gwei', value, 'wei') 60 | } 61 | 62 | function toWei(fromUnit, value) { 63 | return convert(fromUnit, value, 'wei') 64 | } 65 | 66 | function toEther(fromUnit, value) { 67 | return convert(fromUnit, value, 'ether') 68 | } 69 | 70 | function weiToEther(value) { 71 | return convert('wei', value, 'ether') 72 | } 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Browseth 2 | 3 | Browseth is a complete Ethereum development solution for web and server 4 | applications. Most popular solutions don't carry the full spectrum of features needed in every Ethereum application. Browseth supports external wallets, passive request batching, ABIv2 codec, and many other features needed to build robust web applications along with templates to help you get up and running quickly. 5 | 6 | ##### [Browseth documentation](https://browseth.readthedocs.io/en/public/index.html) 7 | 8 | ## Installation 9 | 10 | You can use Browseth in a `