Compare commits
26 Commits
web3-types
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
7603cef308 | ||
|
be370c4e19 | ||
|
c6dece6bd1 | ||
|
93a5b3f457 | ||
|
4242176d29 | ||
|
1cadbeed88 | ||
|
ad52a82190 | ||
|
60b6ed514f | ||
|
ef32822b31 | ||
|
e588f6f8c3 | ||
|
d227f2ad7c | ||
|
97c228031a | ||
|
ad85011d62 | ||
|
a70379625d | ||
|
7350333129 | ||
|
216420fdc5 | ||
|
c559fbbe8c | ||
|
390534497e | ||
|
3f0ec89f11 | ||
|
d3aa4f2bc7 | ||
|
f58f0ddb67 | ||
|
b08bd0f9ab | ||
|
3998b47d84 | ||
|
d965fdb11d | ||
|
ddb64b3ec1 | ||
|
5055ec8617 |
62
ISSUE_TEMPLATE.md
Normal file
62
ISSUE_TEMPLATE.md
Normal file
@@ -0,0 +1,62 @@
|
||||
<!--- Thank you for taking the time to file an Issue -->
|
||||
|
||||
<!--- Before submitting please check to see if this issue was already reported -->
|
||||
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
|
||||
<!--- If you're suggesting a package change/improvement, tell us how it should work -->
|
||||
|
||||
<!--- If you're suggesting a contract or protocol change/improvement, visit our ZEIPs repo -->
|
||||
|
||||
## Current Behavior
|
||||
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||
|
||||
## Possible Solution
|
||||
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
|
||||
<!--- or ideas how to implement the addition or change -->
|
||||
|
||||
## Steps to Reproduce (for bugs)
|
||||
|
||||
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
||||
|
||||
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
||||
|
||||
```
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
```
|
||||
|
||||
## Context
|
||||
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
|
||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||
|
||||
## Your Environment
|
||||
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
|
||||
| Package | Version |
|
||||
| ------------------: | :------ |
|
||||
| `0x.js` | 0.25.0 |
|
||||
| `Exchange Contract` | v1 |
|
||||
|
||||
| Network |
|
||||
| ------- |
|
||||
| NAME |
|
||||
|
||||
<!-- For example:
|
||||
| mainnet |
|
||||
| kovan |
|
||||
| testrpc |
|
||||
-->
|
@@ -1,3 +1,36 @@
|
||||
This PR:
|
||||
<!--- Thank you for taking the time to submit a Pull Request -->
|
||||
|
||||
\*
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
|
||||
## Description
|
||||
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Motivation and Context
|
||||
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
## How Has This Been Tested?
|
||||
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
|
||||
## Types of changes
|
||||
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply:
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
|
||||
## Checklist:
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
|
||||
* [ ] Change requires a change to the documentation.
|
||||
* [ ] Added tests to cover my changes.
|
||||
|
@@ -40,8 +40,8 @@ This repository contains all the 0x developer tools written in TypeScript. Our h
|
||||
| Package | Description |
|
||||
| ----------------------------------------------------------- | ---------------------------------------------------------------- |
|
||||
| [`@0xproject/contracts`](/packages/contracts) | 0x solidity smart contracts & tests |
|
||||
| [`@0xproject/kovan_faucets`](/packages/kovan-faucets) | A faucet micro-service that dispenses test ERC20 tokens or Ether |
|
||||
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | Shared monorepo scripts |
|
||||
| [`@0xproject/testnet-faucets`](/packages/testnet-faucets) | A faucet micro-service that dispenses test ERC20 tokens or Ether |
|
||||
| [`@0xproject/website`](/packages/website) | 0x website & Portal DApp |
|
||||
|
||||
## Usage
|
||||
|
@@ -4,8 +4,8 @@
|
||||
"workspaces": ["packages/*"],
|
||||
"scripts": {
|
||||
"testrpc": "testrpc -p 8545 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
|
||||
"prettier": "prettier --write '**/*.{ts,tsx,json,md}'",
|
||||
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}'",
|
||||
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||
"lerna:run": "lerna run",
|
||||
"lerna:rebuild": "lerna run clean; lerna run build;",
|
||||
"lerna:publish":
|
||||
|
@@ -1,6 +1,18 @@
|
||||
# CHANGELOG
|
||||
|
||||
## v0.30.1 - _January 18, 2018_
|
||||
## v0.31.0 - _January 30, 2018_
|
||||
|
||||
* Add the `shouldAddPersonalMessagePrefix` parameter to `signOrderHashAsync` so that the
|
||||
caller can decide on whether to add the personalMessage prefix before relaying the request
|
||||
to the signer. Parity Signer, Ledger and TestRPC add the prefix themselves, Metamask expects
|
||||
it to have already been added. (#349)
|
||||
|
||||
## v0.30.2 - _January 29, 2018_
|
||||
|
||||
* Add Rinkeby testnet addresses to artifacts (#337)
|
||||
* Move @0xproject/types to dependencies from devDependencies fixing missing type errors
|
||||
|
||||
## v0.30.1 - _January 24, 2018_
|
||||
|
||||
* Fix a bug allowing negative fill values (#212)
|
||||
* Fix a bug that made it impossible to pass a custom ZRX address (#341)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "0x.js",
|
||||
"version": "0.30.0",
|
||||
"version": "0.30.2",
|
||||
"description": "A javascript library for interacting with the 0x protocol",
|
||||
"keywords": ["0x.js", "0xproject", "ethereum", "tokens", "exchange"],
|
||||
"main": "lib/src/index.js",
|
||||
@@ -38,10 +38,9 @@
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.1.2",
|
||||
"@0xproject/dev-utils": "^0.0.5",
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/types": "^0.1.4",
|
||||
"@0xproject/abi-gen": "^0.1.4",
|
||||
"@0xproject/dev-utils": "^0.0.7",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/bintrees": "^1.0.2",
|
||||
"@types/jsonschema": "^1.1.1",
|
||||
"@types/lodash": "^4.14.86",
|
||||
@@ -52,7 +51,7 @@
|
||||
"awesome-typescript-loader": "^3.1.3",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-as-promised-typescript-typings": "^0.0.4",
|
||||
"chai-as-promised-typescript-typings": "^0.0.6",
|
||||
"chai-bignumber": "^2.0.1",
|
||||
"chai-typescript-typings": "^0.0.2",
|
||||
"copyfiles": "^1.2.0",
|
||||
@@ -73,14 +72,15 @@
|
||||
"typedoc": "~0.8.0",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-provider-engine": "^13.0.1",
|
||||
"web3-typescript-typings": "^0.9.4",
|
||||
"web3-typescript-typings": "^0.9.6",
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.0.11",
|
||||
"@0xproject/json-schemas": "^0.7.3",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/web3-wrapper": "^0.1.5",
|
||||
"@0xproject/assert": "^0.0.13",
|
||||
"@0xproject/json-schemas": "^0.7.5",
|
||||
"@0xproject/types": "^0.1.6",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"@0xproject/web3-wrapper": "^0.1.7",
|
||||
"bintrees": "^1.0.2",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
|
@@ -240,20 +240,22 @@ export class ZeroEx {
|
||||
* @param orderHash Hex encoded orderHash to sign.
|
||||
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
|
||||
* must be available via the Web3.Provider supplied to 0x.js.
|
||||
* @param shouldAddPersonalMessagePrefix Some signers add the personal message prefix `\x19Ethereum Signed Message`
|
||||
* themselves (e.g Parity Signer, Ledger, TestRPC) and others expect it to already be done by the client
|
||||
* (e.g Metamask). Depending on which signer this request is going to, decide on whether to add the prefix
|
||||
* before sending the request.
|
||||
* @return An object containing the Elliptic curve signature parameters generated by signing the orderHash.
|
||||
*/
|
||||
public async signOrderHashAsync(orderHash: string, signerAddress: string): Promise<ECSignature> {
|
||||
public async signOrderHashAsync(
|
||||
orderHash: string,
|
||||
signerAddress: string,
|
||||
shouldAddPersonalMessagePrefix: boolean,
|
||||
): Promise<ECSignature> {
|
||||
assert.isHexString('orderHash', orderHash);
|
||||
await assert.isSenderAddressAsync('signerAddress', signerAddress, this._web3Wrapper);
|
||||
|
||||
let msgHashHex;
|
||||
const nodeVersion = await this._web3Wrapper.getNodeVersionAsync();
|
||||
const isParityNode = utils.isParityNode(nodeVersion);
|
||||
const isTestRpc = utils.isTestRpc(nodeVersion);
|
||||
if (isParityNode || isTestRpc) {
|
||||
// Parity and TestRpc nodes add the personalMessage prefix itself
|
||||
msgHashHex = orderHash;
|
||||
} else {
|
||||
let msgHashHex = orderHash;
|
||||
if (shouldAddPersonalMessagePrefix) {
|
||||
const orderHashBuff = ethUtil.toBuffer(orderHash);
|
||||
const msgHashBuff = ethUtil.hashPersonalMessage(orderHashBuff);
|
||||
msgHashHex = ethUtil.bufferToHex(msgHashBuff);
|
||||
|
@@ -274,6 +274,9 @@
|
||||
"3": {
|
||||
"address": "0xc00fd9820cd2898cc4c054b7bf142de637ad129a"
|
||||
},
|
||||
"4": {
|
||||
"address": "0xc778417e063141139fce010982780140aa0cd5ab"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x653e49e301e508a13237c0ddc98ae7d4cd2667a1"
|
||||
},
|
||||
|
@@ -597,6 +597,9 @@
|
||||
"3": {
|
||||
"address": "0x479cc461fecd078f766ecc58533d6f69580cf3ac"
|
||||
},
|
||||
"4": {
|
||||
"address": "0x1d16ef40fac01cec8adac2ac49427b9384192c05"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
|
||||
},
|
||||
|
@@ -534,6 +534,9 @@
|
||||
"3": {
|
||||
"address": "0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed"
|
||||
},
|
||||
"4": {
|
||||
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
|
||||
},
|
||||
"42": {
|
||||
"address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
|
||||
},
|
||||
|
@@ -174,6 +174,9 @@
|
||||
"3": {
|
||||
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
|
||||
},
|
||||
"4": {
|
||||
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
|
||||
},
|
||||
|
@@ -7,6 +7,9 @@
|
||||
"3": {
|
||||
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
|
||||
},
|
||||
"4": {
|
||||
"address": "0x00f58d6d585f84b2d7267940cede30ce2fe6eae8"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
|
||||
},
|
||||
|
@@ -20,12 +20,6 @@ export const utils = {
|
||||
// tslint:disable-next-line: no-console
|
||||
console.log(message);
|
||||
},
|
||||
isParityNode(nodeVersion: string): boolean {
|
||||
return _.includes(nodeVersion, 'Parity');
|
||||
},
|
||||
isTestRpc(nodeVersion: string): boolean {
|
||||
return _.includes(nodeVersion, 'TestRPC');
|
||||
},
|
||||
spawnSwitchErr(name: string, value: any): Error {
|
||||
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
|
||||
},
|
||||
|
@@ -16,6 +16,8 @@ const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
|
||||
|
||||
describe('ZeroEx library', () => {
|
||||
const web3 = web3Factory.create();
|
||||
const config = {
|
||||
@@ -198,7 +200,11 @@ describe('ZeroEx library', () => {
|
||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
||||
};
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress);
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
||||
orderHash,
|
||||
makerAddress,
|
||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
||||
);
|
||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
||||
});
|
||||
it('should return the correct ECSignature for signatureHex concatenated as R + S + V', async () => {
|
||||
@@ -215,7 +221,11 @@ describe('ZeroEx library', () => {
|
||||
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
|
||||
];
|
||||
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress);
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
||||
orderHash,
|
||||
makerAddress,
|
||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
||||
);
|
||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
||||
});
|
||||
it('should return the correct ECSignature for signatureHex concatenated as V + R + S', async () => {
|
||||
@@ -232,7 +242,11 @@ describe('ZeroEx library', () => {
|
||||
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
|
||||
];
|
||||
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress);
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
||||
orderHash,
|
||||
makerAddress,
|
||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
||||
);
|
||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
||||
});
|
||||
});
|
||||
|
@@ -3,6 +3,8 @@ import * as _ from 'lodash';
|
||||
|
||||
import { SignedOrder, ZeroEx } from '../../src';
|
||||
|
||||
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
|
||||
|
||||
export const orderFactory = {
|
||||
async createSignedOrderAsync(
|
||||
zeroEx: ZeroEx,
|
||||
@@ -37,7 +39,7 @@ export const orderFactory = {
|
||||
expirationUnixTimestampSec,
|
||||
};
|
||||
const orderHash = ZeroEx.getOrderHashHex(order);
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker);
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker, SHOULD_ADD_PERSONAL_MESSAGE_PREFIX);
|
||||
const signedOrder: SignedOrder = _.assign(order, { ecSignature });
|
||||
return signedOrder;
|
||||
},
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/abi-gen",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.4",
|
||||
"description": "Generate contract wrappers from ABI and handlebars templates",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"chalk": "^2.3.0",
|
||||
"glob": "^7.1.2",
|
||||
"handlebars": "^4.0.11",
|
||||
@@ -33,7 +33,7 @@
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/glob": "^5.0.33",
|
||||
"@types/handlebars": "^4.0.36",
|
||||
"@types/mkdirp": "^0.5.1",
|
||||
@@ -43,6 +43,6 @@
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-typescript-typings": "^0.9.4"
|
||||
"web3-typescript-typings": "^0.9.6"
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/assert",
|
||||
"version": "0.0.11",
|
||||
"version": "0.0.13",
|
||||
"description": "Provides a standard way of performing type and schema validation across 0x projects",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/lodash": "^4.14.86",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/valid-url": "^1.0.2",
|
||||
@@ -37,8 +37,8 @@
|
||||
"typescript": "~2.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/json-schemas": "^0.7.3",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/json-schemas": "^0.7.5",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"lodash": "^4.17.4",
|
||||
"valid-url": "^1.0.9"
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chai-as-promised-typescript-typings",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.6",
|
||||
"description": "Typescript type definitions for chai-as-promised",
|
||||
"main": "index.d.ts",
|
||||
"types": "index.d.ts",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/connect",
|
||||
"version": "0.5.0",
|
||||
"version": "0.5.2",
|
||||
"description": "A javascript library for interacting with the standard relayer api",
|
||||
"keywords": ["connect", "0xproject", "ethereum", "tokens", "exchange"],
|
||||
"main": "lib/src/index.js",
|
||||
@@ -31,16 +31,16 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.0.11",
|
||||
"@0xproject/json-schemas": "^0.7.3",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/assert": "^0.0.13",
|
||||
"@0xproject/json-schemas": "^0.7.5",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"lodash": "^4.17.4",
|
||||
"query-string": "^5.0.1",
|
||||
"websocket": "^1.0.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/fetch-mock": "^5.12.1",
|
||||
"@types/lodash": "^4.14.86",
|
||||
"@types/mocha": "^2.2.42",
|
||||
@@ -48,7 +48,7 @@
|
||||
"@types/websocket": "^0.0.34",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-as-promised-typescript-typings": "^0.0.4",
|
||||
"chai-as-promised-typescript-typings": "^0.0.6",
|
||||
"chai-typescript-typings": "^0.0.2",
|
||||
"copyfiles": "^1.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
@@ -59,6 +59,6 @@
|
||||
"tslint": "5.8.0",
|
||||
"typedoc": "~0.8.0",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-typescript-typings": "^0.9.4"
|
||||
"web3-typescript-typings": "^0.9.6"
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "contracts",
|
||||
"version": "2.1.4",
|
||||
"version": "2.1.6",
|
||||
"description": "Smart contract components of 0x protocol",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
@@ -30,9 +30,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/dev-utils": "^0.0.5",
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/types": "^0.1.4",
|
||||
"@0xproject/dev-utils": "^0.0.7",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@0xproject/types": "^0.1.6",
|
||||
"@types/bluebird": "^3.5.3",
|
||||
"@types/lodash": "^4.14.86",
|
||||
"@types/node": "^8.0.53",
|
||||
@@ -40,7 +40,7 @@
|
||||
"@types/yargs": "^10.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-as-promised-typescript-typings": "^0.0.4",
|
||||
"chai-as-promised-typescript-typings": "^0.0.6",
|
||||
"chai-bignumber": "^2.0.1",
|
||||
"chai-typescript-typings": "^0.0.2",
|
||||
"copyfiles": "^1.2.0",
|
||||
@@ -52,15 +52,15 @@
|
||||
"types-bn": "^0.0.1",
|
||||
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-typescript-typings": "^0.9.4",
|
||||
"web3-typescript-typings": "^0.9.6",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"0x.js": "^0.30.0",
|
||||
"@0xproject/deployer": "*",
|
||||
"@0xproject/json-schemas": "^0.7.3",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/web3-wrapper": "^0.1.5",
|
||||
"0x.js": "^0.30.2",
|
||||
"@0xproject/deployer": "^0.0.3",
|
||||
"@0xproject/json-schemas": "^0.7.5",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"@0xproject/web3-wrapper": "^0.1.7",
|
||||
"bluebird": "^3.5.0",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/deployer",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.3",
|
||||
"description": "Smart contract deployer of 0x protocol",
|
||||
"main": "lib/src/cli.js",
|
||||
"scripts": {
|
||||
@@ -27,17 +27,17 @@
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md",
|
||||
"devDependencies": {
|
||||
"copyfiles": "^1.2.0",
|
||||
"web3-typescript-typings": "^0.9.3",
|
||||
"types-bn": "^0.0.1",
|
||||
"typescript": "~2.6.1"
|
||||
"typescript": "~2.6.1",
|
||||
"web3-typescript-typings": "^0.9.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/utils": "^0.1.3",
|
||||
"@0xproject/web3-wrapper": "^0.1.4",
|
||||
"@0xproject/web3-wrapper": "^0.1.7",
|
||||
"lodash": "^4.17.4",
|
||||
"solc": "^0.4.18",
|
||||
"yargs": "^10.0.3",
|
||||
"web3": "^0.20.0",
|
||||
"web3-eth-abi": "^1.0.0-beta.24",
|
||||
"web3": "^0.20.0"
|
||||
"yargs": "^10.0.3"
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/dev-utils",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.7",
|
||||
"description": "0x dev TS utils",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/lodash": "^4.14.86",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
@@ -29,7 +29,7 @@
|
||||
"typescript": "~2.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"ethereumjs-util": "^5.1.2",
|
||||
"lodash": "^4.17.4",
|
||||
"request-promise-native": "^1.0.5"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/json-schemas",
|
||||
"version": "0.7.3",
|
||||
"version": "0.7.5",
|
||||
"description": "0x-related json schemas",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -27,8 +27,8 @@
|
||||
"lodash.values": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"@types/lodash.foreach": "^4.5.3",
|
||||
"@types/lodash.values": "^4.3.3",
|
||||
"@types/mocha": "^2.2.42",
|
||||
|
@@ -1,93 +0,0 @@
|
||||
import * as express from 'express';
|
||||
import * as _ from 'lodash';
|
||||
import ProviderEngine = require('web3-provider-engine');
|
||||
import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet');
|
||||
import NonceSubprovider = require('web3-provider-engine/subproviders/nonce-tracker');
|
||||
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
|
||||
|
||||
import { configs } from './configs';
|
||||
import { EtherRequestQueue } from './ether_request_queue';
|
||||
import { idManagement } from './id_management';
|
||||
import { utils } from './utils';
|
||||
import { ZRXRequestQueue } from './zrx_request_queue';
|
||||
|
||||
// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
|
||||
// because they are using the wrong XHR package.
|
||||
// Filed issue: https://github.com/ethereum/web3.js/issues/844
|
||||
// tslint:disable-next-line:ordered-imports
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
export class Handler {
|
||||
private _etherRequestQueue: EtherRequestQueue;
|
||||
private _zrxRequestQueue: ZRXRequestQueue;
|
||||
private _web3: Web3;
|
||||
constructor() {
|
||||
// Setup provider engine to talk with RPC node
|
||||
const providerObj = this._createProviderEngine(configs.RPC_URL);
|
||||
this._web3 = new Web3(providerObj);
|
||||
|
||||
this._etherRequestQueue = new EtherRequestQueue(this._web3);
|
||||
this._zrxRequestQueue = new ZRXRequestQueue(this._web3);
|
||||
}
|
||||
public dispenseEther(req: express.Request, res: express.Response) {
|
||||
const recipientAddress = req.params.recipient;
|
||||
if (_.isUndefined(recipientAddress) || !this._isValidEthereumAddress(recipientAddress)) {
|
||||
res.status(400).send('INVALID_REQUEST');
|
||||
return;
|
||||
}
|
||||
const lowerCaseRecipientAddress = recipientAddress.toLowerCase();
|
||||
const didAddToQueue = this._etherRequestQueue.add(lowerCaseRecipientAddress);
|
||||
if (!didAddToQueue) {
|
||||
res.status(503).send('QUEUE_IS_FULL');
|
||||
return;
|
||||
}
|
||||
utils.consoleLog(`Added ${lowerCaseRecipientAddress} to the ETH queue`);
|
||||
res.status(200).end();
|
||||
}
|
||||
public dispenseZRX(req: express.Request, res: express.Response) {
|
||||
const recipientAddress = req.params.recipient;
|
||||
if (_.isUndefined(recipientAddress) || !this._isValidEthereumAddress(recipientAddress)) {
|
||||
res.status(400).send('INVALID_REQUEST');
|
||||
return;
|
||||
}
|
||||
const lowerCaseRecipientAddress = recipientAddress.toLowerCase();
|
||||
const didAddToQueue = this._zrxRequestQueue.add(lowerCaseRecipientAddress);
|
||||
if (!didAddToQueue) {
|
||||
res.status(503).send('QUEUE_IS_FULL');
|
||||
return;
|
||||
}
|
||||
utils.consoleLog(`Added ${lowerCaseRecipientAddress} to the ZRX queue`);
|
||||
res.status(200).end();
|
||||
}
|
||||
public getQueueInfo(req: express.Request, res: express.Response) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
const payload = JSON.stringify({
|
||||
ether: {
|
||||
full: this._etherRequestQueue.isFull(),
|
||||
size: this._etherRequestQueue.size(),
|
||||
},
|
||||
zrx: {
|
||||
full: this._zrxRequestQueue.isFull(),
|
||||
size: this._zrxRequestQueue.size(),
|
||||
},
|
||||
});
|
||||
res.status(200).send(payload);
|
||||
}
|
||||
// tslint:disable-next-line:prefer-function-over-method
|
||||
private _createProviderEngine(rpcUrl: string) {
|
||||
const engine = new ProviderEngine();
|
||||
engine.addProvider(new NonceSubprovider());
|
||||
engine.addProvider(new HookedWalletSubprovider(idManagement));
|
||||
engine.addProvider(
|
||||
new RpcSubprovider({
|
||||
rpcUrl,
|
||||
}),
|
||||
);
|
||||
engine.start();
|
||||
return engine;
|
||||
}
|
||||
private _isValidEthereumAddress(address: string): boolean {
|
||||
const lowercaseAddress = address.toLowerCase();
|
||||
return this._web3.isAddress(lowercaseAddress);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/monorepo-scripts",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.6",
|
||||
"private": true,
|
||||
"description": "Helper scripts for the monorepo",
|
||||
"scripts": {
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/monorepo-scripts/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/glob": "^5.0.33",
|
||||
"@types/node": "^8.0.53",
|
||||
"shx": "^0.2.2",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/subproviders",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.3",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"license": "Apache-2.0",
|
||||
@@ -17,8 +17,8 @@
|
||||
"test:integration": "run-s clean build run_mocha_integration"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.0.11",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/assert": "^0.0.13",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"bn.js": "^4.11.8",
|
||||
"es6-promisify": "^5.0.0",
|
||||
"ethereumjs-tx": "^1.3.3",
|
||||
@@ -31,15 +31,15 @@
|
||||
"web3-provider-engine": "^13.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"@types/lodash": "^4.14.86",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^8.0.53",
|
||||
"awesome-typescript-loader": "^3.1.3",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-as-promised-typescript-typings": "^0.0.4",
|
||||
"chai-as-promised-typescript-typings": "^0.0.6",
|
||||
"chai-typescript-typings": "^0.0.2",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"mocha": "^4.0.1",
|
||||
|
@@ -1,4 +1,4 @@
|
||||
## @0xproject/kovan_faucets
|
||||
## @0xproject/testnet-faucets
|
||||
|
||||
This faucet dispenses 0.1 test ether to one recipient per second and 0.1 test ZRX every 5 seconds. It has a max queue size of 1000.
|
||||
|
||||
@@ -31,14 +31,19 @@ yarn install
|
||||
Set the following environment variables:
|
||||
|
||||
```bash
|
||||
export FAUCET_ENVIRONMENT=development
|
||||
export DISPENSER_ADDRESS=0x5409ed021d9299bf6814279a6a1411a7e866a631
|
||||
export DISPENSER_PRIVATE_KEY=f2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d
|
||||
export FAUCET_ROLLBAR_ACCESS_KEY={GET_THIS_FROM_ROLLBAR_ACCOUNT_SETTINGS}
|
||||
export INFURA_API_KEY={GET_THIS_FROM_INFURA}
|
||||
```
|
||||
|
||||
Infura API Key can be requested here: https://infura.io/register.html
|
||||
If you want to talk to testrpc, set the following environment variable:
|
||||
|
||||
```bash
|
||||
export FAUCET_ENVIRONMENT=development
|
||||
```
|
||||
|
||||
Infura API Key can be requested here: https://infura.io/signup
|
||||
|
||||
Note: The above public/private keys exist when running `testrpc` with the following option `--mnemonic concert load couple harbor equip island argue ramp clarify fence smart topic`.
|
||||
|
||||
@@ -48,27 +53,73 @@ yarn dev
|
||||
|
||||
### Endpoints
|
||||
|
||||
`GET /ping`
|
||||
|
||||
Returns `pong`
|
||||
|
||||
`GET /info`
|
||||
|
||||
Returns a JSON payload describing the state of the queues for each network. For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"3": {
|
||||
"ether": {
|
||||
"full": false,
|
||||
"size": 4
|
||||
},
|
||||
"zrx": {
|
||||
"full": false,
|
||||
"size": 6
|
||||
}
|
||||
},
|
||||
"42": {
|
||||
"ether": {
|
||||
"full": false,
|
||||
"size": 8
|
||||
},
|
||||
"zrx": {
|
||||
"full": false,
|
||||
"size": 20
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`GET /ether/:recipient`
|
||||
|
||||
Where recipient_address is a hex encoded Ethereum address prefixed with `0x`.
|
||||
Where recipient is a hex encoded Ethereum address prefixed with `0x`.
|
||||
|
||||
`GET /zrx/:recipient`
|
||||
|
||||
Where recipient_address is a hex encoded Ethereum address prefixed with `0x`.
|
||||
Where recipient is a hex encoded Ethereum address prefixed with `0x`.
|
||||
|
||||
#### Parameters
|
||||
|
||||
The endpoints `/ether` and `/zrx` take a query parameter named `networkId` to specify the desired network where you would like to receive the ETH or ZRX. For example:
|
||||
|
||||
```bash
|
||||
curl -i http://localhost:3000/ether/0x14e2F1F157E7DD4057D02817436D628A37120FD1\?networkId=3
|
||||
```
|
||||
|
||||
This command will request the local server to initiate a transfer of 0.1 ETH from the dispensing address to `0x14e2F1F157E7DD4057D02817436D628A37120FD1` on the Ropsten testnet.
|
||||
|
||||
If no `networkId` is provided via query parameters the faucet will default to network 42 (Kovan)
|
||||
|
||||
### Docker configs
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
-p 80:3000 \
|
||||
--name kovan-faucets \
|
||||
--name testnet-faucets \
|
||||
--log-opt max-size=100m \
|
||||
--log-opt max-file=20 \
|
||||
-e DISPENSER_ADDRESS=$DISPENSER_ADDRESS \
|
||||
-e DISPENSER_PRIVATE_KEY=$DISPENSER_PRIVATE_KEY \
|
||||
-e FAUCET_ROLLBAR_ACCESS_KEY=$FAUCET_ROLLBAR_ACCESS_KEY \
|
||||
-e FAUCET_ENVIRONMENT=production \
|
||||
kovan-faucets
|
||||
-e INFURA_API_KEY=$INFURA_API_KEY \
|
||||
testnet-faucets
|
||||
```
|
||||
|
||||
### Lint
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@0xproject/kovan_faucets",
|
||||
"version": "1.0.5",
|
||||
"name": "@0xproject/testnet-faucets",
|
||||
"version": "1.0.7",
|
||||
"description": "A faucet micro-service that dispenses test ERC20 tokens or Ether",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
@@ -14,8 +14,8 @@
|
||||
"author": "Fabio Berger",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"0x.js": "^0.30.0",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"0x.js": "^0.30.2",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"body-parser": "^1.17.1",
|
||||
"ethereumjs-tx": "^1.3.3",
|
||||
"express": "^4.15.2",
|
||||
@@ -25,7 +25,7 @@
|
||||
"web3-provider-engine": "^13.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/body-parser": "^1.16.1",
|
||||
"@types/express": "^4.0.35",
|
||||
"@types/lodash": "^4.14.86",
|
||||
@@ -36,7 +36,7 @@
|
||||
"source-map-loader": "^0.1.6",
|
||||
"tslint": "5.8.0",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-typescript-typings": "^0.9.4",
|
||||
"web3-typescript-typings": "^0.9.6",
|
||||
"webpack": "^3.1.0",
|
||||
"webpack-node-externals": "^1.6.0"
|
||||
}
|
@@ -2,11 +2,6 @@ export const configs = {
|
||||
DISPENSER_ADDRESS: (process.env.DISPENSER_ADDRESS as string).toLowerCase(),
|
||||
DISPENSER_PRIVATE_KEY: process.env.DISPENSER_PRIVATE_KEY,
|
||||
ENVIRONMENT: process.env.FAUCET_ENVIRONMENT,
|
||||
INFURA_API_KEY: process.env.INFURA_API_KEY,
|
||||
ROLLBAR_ACCESS_KEY: process.env.FAUCET_ROLLBAR_ACCESS_KEY,
|
||||
RPC_URL:
|
||||
process.env.FAUCET_ENVIRONMENT === 'development'
|
||||
? 'http://127.0.0.1:8545'
|
||||
: `https://kovan.infura.io/${process.env.INFURA_API_KEY}`,
|
||||
ZRX_TOKEN_ADDRESS: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570',
|
||||
KOVAN_NETWORK_ID: 42,
|
||||
};
|
114
packages/testnet-faucets/src/ts/handler.ts
Normal file
114
packages/testnet-faucets/src/ts/handler.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import { addressUtils } from '@0xproject/utils';
|
||||
import * as express from 'express';
|
||||
import * as _ from 'lodash';
|
||||
import ProviderEngine = require('web3-provider-engine');
|
||||
import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet');
|
||||
import NonceSubprovider = require('web3-provider-engine/subproviders/nonce-tracker');
|
||||
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
|
||||
|
||||
import { EtherRequestQueue } from './ether_request_queue';
|
||||
import { idManagement } from './id_management';
|
||||
import { RequestQueue } from './request_queue';
|
||||
import { rpcUrls } from './rpc_urls';
|
||||
import { utils } from './utils';
|
||||
import { ZRXRequestQueue } from './zrx_request_queue';
|
||||
|
||||
// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
|
||||
// because they are using the wrong XHR package.
|
||||
// Filed issue: https://github.com/ethereum/web3.js/issues/844
|
||||
// tslint:disable-next-line:ordered-imports
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
interface RequestQueueByNetworkId {
|
||||
[networkId: string]: RequestQueue;
|
||||
}
|
||||
|
||||
enum QueueType {
|
||||
ETH = 'ETH',
|
||||
ZRX = 'ZRX',
|
||||
}
|
||||
|
||||
const DEFAULT_NETWORK_ID = 42; // kovan
|
||||
|
||||
export class Handler {
|
||||
private _etherRequestQueueByNetworkId: RequestQueueByNetworkId = {};
|
||||
private _zrxRequestQueueByNetworkId: RequestQueueByNetworkId = {};
|
||||
constructor() {
|
||||
_.forIn(rpcUrls, (rpcUrl: string, networkId: string) => {
|
||||
const providerObj = this._createProviderEngine(rpcUrl);
|
||||
const web3 = new Web3(providerObj);
|
||||
this._etherRequestQueueByNetworkId[networkId] = new EtherRequestQueue(web3);
|
||||
this._zrxRequestQueueByNetworkId[networkId] = new ZRXRequestQueue(web3, +networkId);
|
||||
});
|
||||
}
|
||||
public getQueueInfo(req: express.Request, res: express.Response) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
const queueInfo = _.mapValues(rpcUrls, (rpcUrl: string, networkId: string) => {
|
||||
utils.consoleLog(networkId);
|
||||
const etherRequestQueue = this._etherRequestQueueByNetworkId[networkId];
|
||||
const zrxRequestQueue = this._zrxRequestQueueByNetworkId[networkId];
|
||||
return {
|
||||
ether: {
|
||||
full: etherRequestQueue.isFull(),
|
||||
size: etherRequestQueue.size(),
|
||||
},
|
||||
zrx: {
|
||||
full: zrxRequestQueue.isFull(),
|
||||
size: zrxRequestQueue.size(),
|
||||
},
|
||||
};
|
||||
});
|
||||
const payload = JSON.stringify(queueInfo);
|
||||
res.status(200).send(payload);
|
||||
}
|
||||
public dispenseEther(req: express.Request, res: express.Response) {
|
||||
this._dispense(req, res, this._etherRequestQueueByNetworkId, QueueType.ETH);
|
||||
}
|
||||
public dispenseZRX(req: express.Request, res: express.Response) {
|
||||
this._dispense(req, res, this._zrxRequestQueueByNetworkId, QueueType.ZRX);
|
||||
}
|
||||
private _dispense(
|
||||
req: express.Request,
|
||||
res: express.Response,
|
||||
requestQueueByNetworkId: RequestQueueByNetworkId,
|
||||
queueType: QueueType,
|
||||
) {
|
||||
const recipientAddress = req.params.recipient;
|
||||
if (_.isUndefined(recipientAddress) || !this._isValidEthereumAddress(recipientAddress)) {
|
||||
res.status(400).send('INVALID_RECIPIENT_ADDRESS');
|
||||
return;
|
||||
}
|
||||
const networkId = _.get(req.query, 'networkId', DEFAULT_NETWORK_ID);
|
||||
const requestQueue = _.get(requestQueueByNetworkId, networkId);
|
||||
if (_.isUndefined(requestQueue)) {
|
||||
res.status(400).send('INVALID_NETWORK_ID');
|
||||
return;
|
||||
}
|
||||
const lowerCaseRecipientAddress = recipientAddress.toLowerCase();
|
||||
const didAddToQueue = requestQueue.add(lowerCaseRecipientAddress);
|
||||
if (!didAddToQueue) {
|
||||
res.status(503).send('QUEUE_IS_FULL');
|
||||
return;
|
||||
}
|
||||
utils.consoleLog(`Added ${lowerCaseRecipientAddress} to queue: ${queueType} networkId: ${networkId}`);
|
||||
res.status(200).end();
|
||||
}
|
||||
// tslint:disable-next-line:prefer-function-over-method
|
||||
private _createProviderEngine(rpcUrl: string) {
|
||||
const engine = new ProviderEngine();
|
||||
engine.addProvider(new NonceSubprovider());
|
||||
engine.addProvider(new HookedWalletSubprovider(idManagement));
|
||||
engine.addProvider(
|
||||
new RpcSubprovider({
|
||||
rpcUrl,
|
||||
}),
|
||||
);
|
||||
engine.start();
|
||||
return engine;
|
||||
}
|
||||
// tslint:disable-next-line:prefer-function-over-method
|
||||
private _isValidEthereumAddress(address: string): boolean {
|
||||
const lowercaseAddress = address.toLowerCase();
|
||||
return addressUtils.isAddress(lowercaseAddress);
|
||||
}
|
||||
}
|
@@ -1,13 +1,11 @@
|
||||
import EthereumTx = require('ethereumjs-tx');
|
||||
|
||||
import { configs } from './configs';
|
||||
import { utils } from './utils';
|
||||
|
||||
type Callback = (err: Error | null, accounts: any) => void;
|
||||
|
||||
export const idManagement = {
|
||||
getAccounts(callback: Callback) {
|
||||
utils.consoleLog(`configs.DISPENSER_ADDRESS: ${configs.DISPENSER_ADDRESS}`);
|
||||
callback(null, [configs.DISPENSER_ADDRESS]);
|
||||
},
|
||||
approveTransaction(txData: object, callback: Callback) {
|
@@ -51,6 +51,6 @@ export class RequestQueue {
|
||||
}
|
||||
// tslint:disable-next-line:prefer-function-over-method
|
||||
protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
|
||||
throw new Error('Expected processNextRequestFireAndForgetAsync to be implemented by a superclass');
|
||||
throw new Error('Expected processNextRequestFireAndForgetAsync to be implemented by a subclass');
|
||||
}
|
||||
}
|
13
packages/testnet-faucets/src/ts/rpc_urls.ts
Normal file
13
packages/testnet-faucets/src/ts/rpc_urls.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { configs } from './configs';
|
||||
|
||||
const productionRpcUrls = {
|
||||
'2': `https://ropsten.infura.io/${configs.INFURA_API_KEY}`,
|
||||
'3': `https://rinkeby.infura.io/${configs.INFURA_API_KEY}`,
|
||||
'42': `https://kovan.infura.io/${configs.INFURA_API_KEY}`,
|
||||
};
|
||||
|
||||
const developmentRpcUrls = {
|
||||
'50': 'http://127.0.0.1:8545',
|
||||
};
|
||||
|
||||
export const rpcUrls = configs.ENVIRONMENT === 'development' ? developmentRpcUrls : productionRpcUrls;
|
@@ -19,6 +19,7 @@ const handler = new Handler();
|
||||
app.get('/ping', (req: express.Request, res: express.Response) => {
|
||||
res.status(200).send('pong');
|
||||
});
|
||||
app.get('/info', handler.getQueueInfo.bind(handler));
|
||||
app.get('/ether/:recipient', handler.dispenseEther.bind(handler));
|
||||
app.get('/zrx/:recipient', handler.dispenseZRX.bind(handler));
|
||||
|
@@ -18,11 +18,11 @@ const QUEUE_INTERVAL_MS = 5000;
|
||||
|
||||
export class ZRXRequestQueue extends RequestQueue {
|
||||
private _zeroEx: ZeroEx;
|
||||
constructor(web3: Web3) {
|
||||
constructor(web3: Web3, networkId: number) {
|
||||
super(web3);
|
||||
this.queueIntervalMs = QUEUE_INTERVAL_MS;
|
||||
const zeroExConfig = {
|
||||
networkId: configs.KOVAN_NETWORK_ID,
|
||||
networkId,
|
||||
};
|
||||
this._zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||
}
|
||||
@@ -30,13 +30,14 @@ export class ZRXRequestQueue extends RequestQueue {
|
||||
utils.consoleLog(`Processing ZRX ${recipientAddress}`);
|
||||
const baseUnitAmount = ZeroEx.toBaseUnitAmount(DISPENSE_AMOUNT_ZRX, 18);
|
||||
try {
|
||||
await this._zeroEx.token.transferAsync(
|
||||
configs.ZRX_TOKEN_ADDRESS,
|
||||
const zrxTokenAddress = this._zeroEx.exchange.getZRXTokenAddress();
|
||||
const txHash = await this._zeroEx.token.transferAsync(
|
||||
zrxTokenAddress,
|
||||
configs.DISPENSER_ADDRESS,
|
||||
recipientAddress,
|
||||
baseUnitAmount,
|
||||
);
|
||||
utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ZRX} ZRX to ${recipientAddress}`);
|
||||
utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ZRX} ZRX to ${recipientAddress} tx: ${txHash}`);
|
||||
} catch (err) {
|
||||
utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`);
|
||||
await errorReporter.reportAsync(err);
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/tslint-config",
|
||||
"version": "0.4.2",
|
||||
"version": "0.4.4",
|
||||
"description": "Lint rules related to 0xProject for TSLint",
|
||||
"main": "tslint.json",
|
||||
"scripts": {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/types",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.6",
|
||||
"description": "0x types",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -19,13 +19,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/types/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"typescript": "~2.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"web3": "^0.20.0"
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/utils",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"description": "0x TS utils",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@types/lodash": "^4.14.86",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
|
@@ -2,5 +2,6 @@
|
||||
|
||||
## v0.9.3 - _January 11, 2018_
|
||||
|
||||
* Fix `getTransactionReceipt` not returning null (#338)
|
||||
* Add type for getData on a contract
|
||||
* Fixed the `defaultAccount` not allowing for `undefined` value (#320)
|
||||
|
4
packages/web3-typescript-typings/index.d.ts
vendored
4
packages/web3-typescript-typings/index.d.ts
vendored
@@ -257,10 +257,10 @@ declare module 'web3' {
|
||||
sign(address: string, data: string): string;
|
||||
sign(address: string, data: string, callback: (err: Error, signature: string) => void): void;
|
||||
|
||||
getTransactionReceipt(txHash: string): Web3.TransactionReceipt;
|
||||
getTransactionReceipt(txHash: string): Web3.TransactionReceipt | null;
|
||||
getTransactionReceipt(
|
||||
txHash: string,
|
||||
callback: (err: Error, receipt: Web3.TransactionReceipt) => void,
|
||||
callback: (err: Error, receipt: Web3.TransactionReceipt | null) => void,
|
||||
): void;
|
||||
|
||||
// TODO block param
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "web3-typescript-typings",
|
||||
"version": "0.9.4",
|
||||
"version": "0.9.6",
|
||||
"description": "Typescript type definitions for web3",
|
||||
"main": "index.d.ts",
|
||||
"types": "index.d.ts",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/web3-wrapper",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.7",
|
||||
"description": "Wraps around web3 and gives a nicer interface",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -19,17 +19,17 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x.js/packages/web3-wrapper/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^0.4.2",
|
||||
"@0xproject/types": "^0.1.4",
|
||||
"@0xproject/tslint-config": "^0.4.4",
|
||||
"@0xproject/types": "^0.1.6",
|
||||
"@types/lodash": "^4.14.86",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-typescript-typings": "^0.9.4"
|
||||
"web3-typescript-typings": "^0.9.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"lodash": "^4.17.4",
|
||||
"web3": "^0.20.0"
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/website",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.9",
|
||||
"private": true,
|
||||
"description": "Website and 0x portal dapp",
|
||||
"scripts": {
|
||||
@@ -21,9 +21,9 @@
|
||||
"author": "Fabio Berger",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"0x.js": "^0.30.0",
|
||||
"@0xproject/subproviders": "^0.3.1",
|
||||
"@0xproject/utils": "^0.2.0",
|
||||
"0x.js": "^0.30.2",
|
||||
"@0xproject/subproviders": "^0.3.3",
|
||||
"@0xproject/utils": "^0.2.2",
|
||||
"accounting": "^0.4.1",
|
||||
"basscss": "^8.0.3",
|
||||
"blockies": "^0.0.2",
|
||||
@@ -101,7 +101,7 @@
|
||||
"style-loader": "0.13.x",
|
||||
"tslint": "5.8.0",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-typescript-typings": "^0.9.4",
|
||||
"web3-typescript-typings": "^0.9.6",
|
||||
"webpack": "^3.1.0",
|
||||
"webpack-dev-middleware": "^1.10.0",
|
||||
"webpack-dev-server": "^2.5.0"
|
||||
|
Reference in New Issue
Block a user