cuz
This commit is contained in:
parent
4853ca2a14
commit
368405c283
|
@ -14,6 +14,7 @@ import SendTransaction from 'containers/Tabs/SendTransaction';
|
|||
import Swap from 'containers/Tabs/Swap';
|
||||
import SignAndVerifyMessage from 'containers/Tabs/SignAndVerifyMessage';
|
||||
import BroadcastTx from 'containers/Tabs/BroadcastTx';
|
||||
import Exchange from 'containers/Tabs/Exchange';
|
||||
import CheckTransaction from 'containers/Tabs/CheckTransaction';
|
||||
import SupportPage from 'containers/Tabs/SupportPage';
|
||||
import ErrorScreen from 'components/ErrorScreen';
|
||||
|
@ -88,6 +89,7 @@ class RootClass extends Component<Props, State> {
|
|||
<Route path="/sign-and-verify-message" component={SignAndVerifyMessage} />
|
||||
<Route path="/tx-status" component={CheckTransaction} exact={true} />
|
||||
<Route path="/pushTx" component={BroadcastTx} />
|
||||
<Route path="/exchange" component={Exchange} />
|
||||
<Route path="/support-us" component={SupportPage} exact={true} />
|
||||
{process.env.NODE_ENV !== 'production' && (
|
||||
<Route path="/dev/palette" component={PalettePage} exact={true} />
|
||||
|
|
|
@ -45,6 +45,10 @@ export const navigationLinks: NavigationLink[] = [
|
|||
to: '/support-us',
|
||||
disabled: !process.env.BUILD_ELECTRON
|
||||
},
|
||||
{
|
||||
name: 'Exchange',
|
||||
to: '/exchange'
|
||||
},
|
||||
{
|
||||
name: 'NAV_HELP',
|
||||
to: knowledgeBaseURL,
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
import React, { Component } from 'react';
|
||||
import { ZeroEx } from '0x.js';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
|
||||
import { shepherdProvider } from 'libs/nodes';
|
||||
import TabSection from 'containers/TabSection';
|
||||
|
||||
BigNumber.config({
|
||||
EXPONENTIAL_AT: 1000
|
||||
});
|
||||
|
||||
class Exchanger {
|
||||
provider = window.web3.currentProvider;
|
||||
configs = { networkId: 1 };
|
||||
decimals = 18;
|
||||
instance = new ZeroEx(this.provider, this.configs);
|
||||
}
|
||||
|
||||
export default class Exchange extends Component {
|
||||
exchanger = new Exchanger();
|
||||
|
||||
exchange = async () => {
|
||||
try {
|
||||
const wethAddress = this.exchanger.instance.etherToken.getContractAddressIfExists() as string;
|
||||
const zrxAddress = this.exchanger.instance.exchange.getZRXTokenAddress();
|
||||
const exchangeAddress = this.exchanger.instance.exchange.getContractAddress();
|
||||
|
||||
const accounts = await this.exchanger.instance.getAvailableAddressesAsync();
|
||||
|
||||
const makerAddress = accounts[0];
|
||||
// const takerAddress = "0x65bF70cd1fAd35fCb422Ee4bD4d2d8633D79c43E";
|
||||
|
||||
// const setMakerAllowTxHash = await this.exchanger.instance.token.setUnlimitedProxyAllowanceAsync(
|
||||
// zrxAddress,
|
||||
// makerAddress,
|
||||
// { gasPrice: new BigNumber('12000000000') }
|
||||
// );
|
||||
// await this.exchanger.instance.awaitTransactionMinedAsync(setMakerAllowTxHash);
|
||||
|
||||
// Deposit WETH
|
||||
// const ethAmount = new BigNumber(0.001);
|
||||
// const ethToConvert = ZeroEx.toBaseUnitAmount(ethAmount, 18);
|
||||
// const convertEthTxHash = await this.exchanger.instance.etherToken.depositAsync(
|
||||
// wethAddress,
|
||||
// ethToConvert,
|
||||
// makerAddress,
|
||||
// { gasPrice: new BigNumber('12000000000') }
|
||||
// );
|
||||
// await this.exchanger.instance.awaitTransactionMinedAsync(convertEthTxHash);
|
||||
|
||||
console.log('c');
|
||||
|
||||
// Make order
|
||||
const order = {
|
||||
maker: '0xc9af17853600357bc89005291b85fab4ccd2f198',
|
||||
taker: ZeroEx.NULL_ADDRESS,
|
||||
feeRecipient: ZeroEx.NULL_ADDRESS,
|
||||
makerTokenAddress: wethAddress,
|
||||
takerTokenAddress: zrxAddress,
|
||||
exchangeContractAddress: exchangeAddress,
|
||||
salt: ZeroEx.generatePseudoRandomSalt(),
|
||||
makerFee: new BigNumber(0),
|
||||
takerFee: new BigNumber(0),
|
||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(0.000001), 18),
|
||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(0.000001), 18),
|
||||
expirationUnixTimestampSec: new BigNumber(Date.now() + 3600000)
|
||||
};
|
||||
|
||||
const foo = {
|
||||
address: wethAddress,
|
||||
symbol: 'WETH',
|
||||
decimal: 18
|
||||
};
|
||||
|
||||
const balance = await shepherdProvider.getTokenBalance(
|
||||
'0xC9aF17853600357BC89005291b85fAb4CCd2F198',
|
||||
foo
|
||||
);
|
||||
|
||||
// MM
|
||||
// 0xc9af17853600357bc89005291b85fab4ccd2f198
|
||||
|
||||
console.log('\n\n\n', 'order.makerTokenAmount', order.makerTokenAmount.toString(), '\n\n\n');
|
||||
console.log('\n\n\n', 'balance', balance.balance.toString(), '\n\n\n');
|
||||
console.log('\n\n\n', 'wethAddress', wethAddress, '\n\n\n');
|
||||
console.log('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2');
|
||||
|
||||
// Sign order
|
||||
const orderHash = ZeroEx.getOrderHashHex(order);
|
||||
|
||||
const shouldAddPersonalMessagePrefix = true;
|
||||
console.log('d');
|
||||
const ecSignature = await this.exchanger.instance.signOrderHashAsync(
|
||||
orderHash,
|
||||
makerAddress,
|
||||
shouldAddPersonalMessagePrefix
|
||||
);
|
||||
const signedOrder = {
|
||||
...order,
|
||||
ecSignature
|
||||
};
|
||||
console.log('e');
|
||||
await this.exchanger.instance.exchange.validateOrderFillableOrThrowAsync(signedOrder);
|
||||
|
||||
console.log('We good.');
|
||||
} catch (e) {
|
||||
console.log('We bad.');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<TabSection>
|
||||
<h1>Exchange</h1>
|
||||
<button onClick={this.exchange}>Go!</button>
|
||||
</TabSection>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export { default } from './Exchange';
|
|
@ -3,11 +3,13 @@ import { default as GenerateWallet } from './GenerateWallet';
|
|||
import { default as SendTransaction } from './SendTransaction';
|
||||
import { default as Swap } from './Swap';
|
||||
import { default as SignAndVerifyMessage } from './SignAndVerifyMessage';
|
||||
import { default as Exchange } from './Exchange';
|
||||
|
||||
export default {
|
||||
ENS,
|
||||
GenerateWallet,
|
||||
SendTransaction,
|
||||
Swap,
|
||||
SignAndVerifyMessage
|
||||
SignAndVerifyMessage,
|
||||
Exchange
|
||||
};
|
||||
|
|
34
package.json
34
package.json
|
@ -10,18 +10,21 @@
|
|||
"npm": ">= 5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@parity/qr-signer": "0.3.1",
|
||||
"0x.js": "^0.38.6",
|
||||
"@ledgerhq/hw-app-eth": "4.7.3",
|
||||
"@ledgerhq/hw-transport-node-hid": "4.7.6",
|
||||
"@ledgerhq/hw-transport-u2f": "4.12.0",
|
||||
"@parity/qr-signer": "0.3.1",
|
||||
"babel-polyfill": "6.26.0",
|
||||
"bignumber.js": "~4.1.0",
|
||||
"bip39": "2.5.0",
|
||||
"bn.js": "4.11.8",
|
||||
"bootstrap-sass": "3.3.7",
|
||||
"classnames": "2.2.5",
|
||||
"electron-updater": "2.21.10",
|
||||
"ethereum-blockies-base64": "1.0.2",
|
||||
"ethereumjs-abi": "git://github.com/ethereumjs/ethereumjs-abi.git#09c3c48fd3bed143df7fa8f36f6f164205e23796",
|
||||
"ethereumjs-abi":
|
||||
"git://github.com/ethereumjs/ethereumjs-abi.git#09c3c48fd3bed143df7fa8f36f6f164205e23796",
|
||||
"ethereumjs-tx": "1.3.4",
|
||||
"ethereumjs-util": "5.1.5",
|
||||
"ethereumjs-wallet": "0.6.0",
|
||||
|
@ -166,13 +169,19 @@
|
|||
"prebuild": "check-node-version --package",
|
||||
"build:downloadable": "webpack --mode=production --config webpack_config/webpack.html.js",
|
||||
"prebuild:downloadable": "check-node-version --package",
|
||||
"build:electron": "webpack --config webpack_config/webpack.electron-prod.js && node webpack_config/buildElectron.js",
|
||||
"build:electron:osx": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=osx node webpack_config/buildElectron.js",
|
||||
"build:electron:windows": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=windows node webpack_config/buildElectron.js",
|
||||
"build:electron:linux": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=linux node webpack_config/buildElectron.js",
|
||||
"build:electron":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && node webpack_config/buildElectron.js",
|
||||
"build:electron:osx":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=osx node webpack_config/buildElectron.js",
|
||||
"build:electron:windows":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=windows node webpack_config/buildElectron.js",
|
||||
"build:electron:linux":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=linux node webpack_config/buildElectron.js",
|
||||
"prebuild:electron": "check-node-version --package",
|
||||
"jenkins:build:linux": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=JENKINS_LINUX node webpack_config/buildElectron.js",
|
||||
"jenkins:build:mac": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=JENKINS_MAC node webpack_config/buildElectron.js",
|
||||
"jenkins:build:linux":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=JENKINS_LINUX node webpack_config/buildElectron.js",
|
||||
"jenkins:build:mac":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=JENKINS_MAC node webpack_config/buildElectron.js",
|
||||
"jenkins:upload": "node jenkins/upload",
|
||||
"test:coverage": "jest --config=jest_config/jest.config.json --coverage",
|
||||
"test": "jest --config=jest_config/jest.config.json",
|
||||
|
@ -185,13 +194,16 @@
|
|||
"predev": "check-node-version --package",
|
||||
"dev:https": "HTTPS=true node webpack_config/devServer.js",
|
||||
"predev:https": "check-node-version --package",
|
||||
"dev:electron": "concurrently --kill-others --names 'webpack,electron' 'BUILD_ELECTRON=true node webpack_config/devServer.js' 'webpack --config webpack_config/webpack.electron-dev.js && electron dist/electron-js/main.js'",
|
||||
"dev:electron":
|
||||
"concurrently --kill-others --names 'webpack,electron' 'BUILD_ELECTRON=true node webpack_config/devServer.js' 'webpack --config webpack_config/webpack.electron-dev.js && electron dist/electron-js/main.js'",
|
||||
"tslint": "tslint --project . --exclude common/vendor/**/*",
|
||||
"tscheck": "tsc --noEmit",
|
||||
"start": "npm run dev",
|
||||
"precommit": "lint-staged",
|
||||
"formatAll": "find ./common/ -name '*.ts*' | xargs prettier --write --config ./.prettierrc --config-precedence file-override",
|
||||
"prettier:diff": "prettier --write --config ./.prettierrc --list-different \"common/**/*.ts\" \"common/**/*.tsx\"",
|
||||
"formatAll":
|
||||
"find ./common/ -name '*.ts*' | xargs prettier --write --config ./.prettierrc --config-precedence file-override",
|
||||
"prettier:diff":
|
||||
"prettier --write --config ./.prettierrc --list-different \"common/**/*.ts\" \"common/**/*.tsx\"",
|
||||
"prepush": "npm run tslint && npm run tscheck",
|
||||
"update:tokens": "ts-node scripts/update-tokens",
|
||||
"postinstall": "electron-rebuild --force"
|
||||
|
|
Loading…
Reference in New Issue