aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-04-03 21:19:38 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-04-04 16:56:32 +0800
commit249bf0163d8ee71b7329fd58b72e554c0324279c (patch)
tree5bfb30b082236bd089e35186220bdb02913ba128 /packages/website
parent674e56cea69fe96ddd0071d3c4c5b5ea8ae299bf (diff)
downloaddexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar
dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.gz
dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.bz2
dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.lz
dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.xz
dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.zst
dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.zip
Move our contract templates to accept Provider instead of Web3Wrapper
Diffstat (limited to 'packages/website')
-rw-r--r--packages/website/ts/blockchain.ts7
-rw-r--r--packages/website/ts/globals.d.ts113
-rw-r--r--packages/website/ts/utils/utils.ts6
3 files changed, 7 insertions, 119 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 72cb94c02..fd34ab82d 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -23,6 +23,7 @@ import {
LedgerWalletSubprovider,
RedundantRPCSubprovider,
} from '@0xproject/subproviders';
+import { Provider } from '@0xproject/types';
import { BigNumber, intervalUtils, logUtils, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -73,11 +74,11 @@ export class Blockchain {
private _web3Wrapper?: Web3Wrapper;
private _blockchainWatcher?: BlockchainWatcher;
private _userAddressIfExists: string;
- private _cachedProvider: Web3.Provider;
+ private _cachedProvider: Provider;
private _cachedProviderNetworkId: number;
private _ledgerSubprovider: LedgerWalletSubprovider;
private _defaultGasPrice: BigNumber;
- private static _getNameGivenProvider(provider: Web3.Provider): string {
+ private static _getNameGivenProvider(provider: Provider): string {
const providerType = utils.getProviderType(provider);
const providerNameIfExists = providerToName[providerType];
if (_.isUndefined(providerNameIfExists)) {
@@ -377,7 +378,7 @@ export class Blockchain {
}
public isValidAddress(address: string): boolean {
const lowercaseAddress = address.toLowerCase();
- return this._web3Wrapper.isAddress(lowercaseAddress);
+ return Web3Wrapper.isAddress(lowercaseAddress);
}
public async pollTokenBalanceAsync(token: Token) {
utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
diff --git a/packages/website/ts/globals.d.ts b/packages/website/ts/globals.d.ts
index 2c2140485..719c2708a 100644
--- a/packages/website/ts/globals.d.ts
+++ b/packages/website/ts/globals.d.ts
@@ -1,8 +1,5 @@
-declare module 'react-tooltip';
declare module 'truffle-contract';
-declare module 'keccak';
declare module 'whatwg-fetch';
-declare module 'web3-provider-engine/subproviders/filters';
declare module 'thenby';
declare module 'react-document-title';
declare module 'react-ga';
@@ -14,119 +11,9 @@ declare module '*.json' {
/* tslint:enable */
}
-// tslint:disable:max-classes-per-file
-
-// find-version declarations
-declare function findVersions(version: string): string[];
-declare module 'find-versions' {
- export = findVersions;
-}
-
-// semver-sort declarations
-declare module 'semver-sort' {
- const desc: (versions: string[]) => string[];
-}
-
-// xml-js declarations
-declare interface XML2JSONOpts {
- compact?: boolean;
- spaces?: number;
-}
-declare module 'xml-js' {
- const xml2json: (xml: string, opts: XML2JSONOpts) => string;
-}
-
// This will be defined by default in TS 2.4
// Source: https://github.com/Microsoft/TypeScript/issues/12364
interface System {
import<T>(module: string): Promise<T>;
}
declare var System: System;
-
-// jsonschema declarations
-// Source: https://github.com/tdegrunt/jsonschema/blob/master/lib/index.d.ts
-declare interface Schema {
- id?: string;
- $schema?: string;
- title?: string;
- description?: string;
- multipleOf?: number;
- maximum?: number;
- exclusiveMaximum?: boolean;
- minimum?: number;
- exclusiveMinimum?: boolean;
- maxLength?: number;
- minLength?: number;
- pattern?: string;
- additionalItems?: boolean | Schema;
- items?: Schema | Schema[];
- maxItems?: number;
- minItems?: number;
- uniqueItems?: boolean;
- maxProperties?: number;
- minProperties?: number;
- required?: string[];
- additionalProperties?: boolean | Schema;
- definitions?: {
- [name: string]: Schema;
- };
- properties?: {
- [name: string]: Schema;
- };
- patternProperties?: {
- [name: string]: Schema;
- };
- dependencies?: {
- [name: string]: Schema | string[];
- };
- enum?: any[];
- type?: string | string[];
- allOf?: Schema[];
- anyOf?: Schema[];
- oneOf?: Schema[];
- not?: Schema;
- // This is the only property that's not defined in https://github.com/tdegrunt/jsonschema/blob/master/lib/index.d.ts
- // There is an open issue for that: https://github.com/tdegrunt/jsonschema/issues/194
- // There is also an opened PR: https://github.com/tdegrunt/jsonschema/pull/218/files
- // As soon as it gets merged we should be good to use types from 'jsonschema' package
- $ref?: string;
-}
-
-// blockies declarations
-declare interface BlockiesIcon {
- toDataURL(): string;
-}
-declare interface BlockiesConfig {
- seed: string;
-}
-declare function blockies(config: BlockiesConfig): BlockiesIcon;
-declare module 'blockies' {
- export = blockies;
-}
-
-// web3-provider-engine declarations
-declare class Subprovider {}
-declare module 'web3-provider-engine/subproviders/subprovider' {
- export = Subprovider;
-}
-declare module 'web3-provider-engine/subproviders/rpc' {
- import { JSONRPCRequestPayload } from '@0xproject/types';
- class RpcSubprovider {
- constructor(options: { rpcUrl: string });
- public handleRequest(
- payload: JSONRPCRequestPayload,
- next: () => void,
- end: (err: Error | null, data?: any) => void,
- ): void;
- }
- export = RpcSubprovider;
-}
-
-declare interface Artifact {
- abi: any;
- networks: {
- [networkId: number]: {
- address: string;
- };
- };
-}
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 75597a7e2..afe159beb 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -1,5 +1,6 @@
-import { ECSignature, ExchangeContractErrs, Web3Provider, ZeroEx, ZeroExError } from '0x.js';
+import { ECSignature, ExchangeContractErrs, ZeroEx, ZeroExError } from '0x.js';
import { constants as sharedConstants, EtherscanLinkSuffixes, Networks } from '@0xproject/react-shared';
+import { Provider } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import deepEqual = require('deep-equal');
import * as _ from 'lodash';
@@ -8,7 +9,6 @@ import { Order, Providers, ScreenWidths, Side, SideToAssetToken, Token, TokenByA
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
import * as u2f from 'ts/vendor/u2f_api';
-import Web3 = require('web3');
const LG_MIN_EM = 64;
const MD_MIN_EM = 52;
@@ -273,7 +273,7 @@ export const utils = {
window.onload = () => resolve();
});
},
- getProviderType(provider: Web3.Provider): Providers | string {
+ getProviderType(provider: Provider): Providers | string {
const constructorName = provider.constructor.name;
let parsedProviderName = constructorName;
switch (constructorName) {