aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-26 02:43:53 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-26 02:43:53 +0800
commit2a1c2a55eda0f3d279aa1145b6157892d03001ae (patch)
tree812b5eb19248c021e8e1f9231e52f884a4683803
parent46a8aad87a978567026881d8c1db998ac14eab4e (diff)
downloaddexon-sol-tools-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar
dexon-sol-tools-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.gz
dexon-sol-tools-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.bz2
dexon-sol-tools-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.lz
dexon-sol-tools-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.xz
dexon-sol-tools-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.zst
dexon-sol-tools-2a1c2a55eda0f3d279aa1145b6157892d03001ae.zip
feat: supply render options from URL
-rw-r--r--packages/contract-addresses/src/index.ts2
-rw-r--r--packages/instant/public/index.html43
-rw-r--r--packages/instant/src/components/zero_ex_instant.tsx21
-rw-r--r--packages/instant/src/util/error.ts1
-rw-r--r--yarn.lock48
5 files changed, 60 insertions, 55 deletions
diff --git a/packages/contract-addresses/src/index.ts b/packages/contract-addresses/src/index.ts
index 1ea8c61dd..8af7cd8ab 100644
--- a/packages/contract-addresses/src/index.ts
+++ b/packages/contract-addresses/src/index.ts
@@ -45,7 +45,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
etherToken: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
exchange: '0x35dd2932454449b14cee11a94d3674a936d5d7b2',
assetProxyOwner: '0x2c824d2882baa668e0d5202b1e7f2922278703f8',
- forwarder: '0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8',
+ forwarder: '0x4859339a70a63f5e32497d865ce793c38ce9c004',
orderValidator: '0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d',
},
};
diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html
index 14555fc64..4c1c52afd 100644
--- a/packages/instant/public/index.html
+++ b/packages/instant/public/index.html
@@ -6,6 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>0x Instant Dev Environment</title>
<script type="text/javascript" src="/main.bundle.js" charset="utf-8"></script>
+ <script type="text/javascript" src="https://unpkg.com/jsuri@1.3.1/Uri.js" charset="utf-8"></script>
+ <script type="text/javascript" src="https://unpkg.com/bignumber.js@4.1.0/bignumber.js" charset="utf-8"></script>
<style>
#zeroExInstantContainer {
display: flex;
@@ -24,10 +26,47 @@
<body>
<div id="zeroExInstantContainer"></div>
<script>
- zeroExInstant.render({
+ const removeUndefined = (obj) => {
+ for (let k in obj) if (obj[k] === undefined) delete obj[k];
+ return obj;
+ }
+ BigNumber.config({
+ EXPONENTIAL_AT: 1000,
+ DECIMAL_PLACES: 78,
+ });
+ const providedOrder = {
+ senderAddress: '0x0000000000000000000000000000000000000000',
+ makerAddress: '0x14e2f1f157e7dd4057d02817436d628a37120fd1',
+ takerAddress: '0x0000000000000000000000000000000000000000',
+ makerFee: new BigNumber('0'),
+ takerFee: new BigNumber('0'),
+ makerAssetAmount: new BigNumber('100000000000000000000'),
+ takerAssetAmount: new BigNumber('10000000000000000'),
+ makerAssetData: '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa',
+ takerAssetData: '0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c',
+ expirationTimeSeconds: new BigNumber('1591858800'),
+ feeRecipientAddress: '0x0000000000000000000000000000000000000000',
+ salt: new BigNumber(
+ '54983920541892966634674340965984367456810207583416050222519063020710969340046',
+ ),
+ signature:
+ '0x1b949656218421c845995457303569a656764afa2b979d41dcefff0009d57ce15001490268bc7caa4269894fd83b741465fc5a7a53eda6ece17eb91fb32655d83703',
+ exchangeAddress: '0x35dd2932454449b14cee11a94d3674a936d5d7b2',
+ };
+ const queryParams = new Uri(window.location.search);
+ const renderOptionsDefaults = {
liquiditySource: 'https://api.radarrelay.com/0x/v2/',
assetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
- });
+ }
+ const liquiditySourceOverride = queryParams.getQueryParamValue('liquiditySource');
+ const renderOptionsOverrides = {
+ liquiditySource: liquiditySourceOverride === 'provided' ? [providedOrder] : liquiditySourceOverride,
+ assetData: queryParams.getQueryParamValue('assetData'),
+ network: +queryParams.getQueryParamValue('network'),
+ }
+ const renderOptions = Object.assign({}, renderOptionsDefaults, removeUndefined(renderOptionsOverrides));
+ console.log(renderOptions)
+ zeroExInstant.render(renderOptions);
</script>
</body>
diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx
index ffa5a8250..0fe494726 100644
--- a/packages/instant/src/components/zero_ex_instant.tsx
+++ b/packages/instant/src/components/zero_ex_instant.tsx
@@ -1,5 +1,6 @@
import { AssetBuyer } from '@0x/asset-buyer';
-import { ObjectMap } from '@0x/types';
+import { ObjectMap, SignedOrder } from '@0x/types';
+import * as _ from 'lodash';
import * as React from 'react';
import { Provider } from 'react-redux';
@@ -21,8 +22,7 @@ export type ZeroExInstantProps = ZeroExInstantRequiredProps & Partial<ZeroExInst
export interface ZeroExInstantRequiredProps {
// TODO: Change API when we allow the selection of different assetDatas
assetData: string;
- // TODO: Allow for a function that returns orders
- liquiditySource: string;
+ liquiditySource: string | SignedOrder[];
}
export interface ZeroExInstantOptionalProps {
@@ -40,9 +40,20 @@ export class ZeroExInstant extends React.Component<ZeroExInstantProps> {
};
const { network } = optionalPropsWithDefaults;
// TODO: Provider needs to not be hard-coded to injected web3.
- const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(getProvider(), props.liquiditySource, {
+ const provider = getProvider();
+ const assetBuyerOptions = {
networkId: network,
- });
+ };
+ let assetBuyer;
+ if (_.isString(props.liquiditySource)) {
+ assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(
+ provider,
+ props.liquiditySource,
+ assetBuyerOptions,
+ );
+ } else {
+ assetBuyer = AssetBuyer.getAssetBuyerForProvidedOrders(provider, props.liquiditySource, assetBuyerOptions);
+ }
const completeAssetMetaDataMap = {
...props.additionalAssetMetaDataMap,
...state.assetMetaDataMap,
diff --git a/packages/instant/src/util/error.ts b/packages/instant/src/util/error.ts
index 40fd24c7e..f5a3d2cb8 100644
--- a/packages/instant/src/util/error.ts
+++ b/packages/instant/src/util/error.ts
@@ -10,7 +10,6 @@ class ErrorFlasher {
private _timeoutId?: number;
public flashNewError(dispatch: Dispatch<Action>, error: any, delayMs: number = 7000): void {
this._clearTimeout();
-
// dispatch new message
dispatch(actions.setError(error));
diff --git a/yarn.lock b/yarn.lock
index 95650a2d7..6b3219ed6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1869,10 +1869,6 @@ aes-js@^0.2.3:
version "0.2.4"
resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d"
-aes-js@^3.1.1:
- version "3.1.1"
- resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072"
-
agent-base@4, agent-base@^4.1.0, agent-base@~4.2.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9"
@@ -3303,7 +3299,7 @@ bs-logger@0.x:
dependencies:
fast-json-stable-stringify "^2.0.0"
-bs58@=4.0.1, bs58@^4.0.0:
+bs58@=4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a"
dependencies:
@@ -3326,14 +3322,6 @@ bs58check@^1.0.8:
bs58 "^3.1.0"
create-hash "^1.1.0"
-bs58check@^2.1.2:
- version "2.1.2"
- resolved "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc"
- dependencies:
- bs58 "^4.0.0"
- create-hash "^1.1.0"
- safe-buffer "^5.1.2"
-
bser@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719"
@@ -5913,19 +5901,6 @@ ethereumjs-wallet@0.6.0:
utf8 "^2.1.1"
uuid "^2.0.1"
-ethereumjs-wallet@~0.6.0:
- version "0.6.2"
- resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda"
- dependencies:
- aes-js "^3.1.1"
- bs58check "^2.1.2"
- ethereumjs-util "^5.2.0"
- hdkey "^1.0.0"
- safe-buffer "^5.1.2"
- scrypt.js "^0.2.0"
- utf8 "^3.0.0"
- uuid "^3.3.2"
-
ethers@~4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.4.tgz#d3f85e8b27f4b59537e06526439b0fb15b44dc65"
@@ -6730,7 +6705,7 @@ ganache-core@0xProject/ganache-core#monorepo-dep:
ethereumjs-tx "0xProject/ethereumjs-tx#fake-tx-include-signature-by-default"
ethereumjs-util "^5.2.0"
ethereumjs-vm "2.3.5"
- ethereumjs-wallet "0.6.0"
+ ethereumjs-wallet "~0.6.0"
fake-merkle-patricia-tree "~1.0.1"
heap "~0.2.6"
js-scrypt "^0.2.0"
@@ -7455,14 +7430,6 @@ hdkey@^0.7.0, hdkey@^0.7.1:
coinstring "^2.0.0"
secp256k1 "^3.0.1"
-hdkey@^1.0.0:
- version "1.1.0"
- resolved "https://registry.npmjs.org/hdkey/-/hdkey-1.1.0.tgz#e74e7b01d2c47f797fa65d1d839adb7a44639f29"
- dependencies:
- coinstring "^2.0.0"
- safe-buffer "^5.1.1"
- secp256k1 "^3.0.1"
-
he@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
@@ -12533,13 +12500,6 @@ react-scroll@0xproject/react-scroll#pr-330-and-replace-state:
lodash.throttle "^4.1.1"
prop-types "^15.5.8"
-react-scroll@0xproject/react-scroll#similar-to-pr-330-but-with-replace-state:
- version "1.7.10"
- resolved "https://codeload.github.com/0xproject/react-scroll/tar.gz/0f625b270d7e966313cac8b811c0ae807b37e170"
- dependencies:
- lodash.throttle "^4.1.1"
- prop-types "^15.5.8"
-
react-side-effect@^1.0.2, react-side-effect@^1.1.0:
version "1.1.5"
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-1.1.5.tgz#f26059e50ed9c626d91d661b9f3c8bb38cd0ff2d"
@@ -15553,10 +15513,6 @@ utf8@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/utf8/-/utf8-2.1.2.tgz#1fa0d9270e9be850d9b05027f63519bf46457d96"
-utf8@^3.0.0:
- version "3.0.0"
- resolved "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1"
-
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"