diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/0x.ts | 10 | ||||
-rw-r--r-- | src/contract_wrappers/proxy_wrapper.ts | 41 | ||||
-rw-r--r-- | src/contract_wrappers/token_transfer_proxy_wrapper.ts | 41 | ||||
-rw-r--r-- | src/types.ts | 2 |
4 files changed, 47 insertions, 47 deletions
@@ -15,7 +15,7 @@ import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper'; import {EtherTokenWrapper} from './contract_wrappers/ether_token_wrapper'; import {ecSignatureSchema} from './schemas/ec_signature_schema'; import {TokenWrapper} from './contract_wrappers/token_wrapper'; -import {ProxyWrapper} from './contract_wrappers/proxy_wrapper'; +import {TokenTransferProxyWrapper} from './contract_wrappers/token_transfer_proxy_wrapper'; import {ECSignature, ZeroExError, Order, SignedOrder, Web3Provider} from './types'; import {orderHashSchema} from './schemas/order_hash_schema'; import {orderSchema} from './schemas/order_schemas'; @@ -55,10 +55,10 @@ export class ZeroEx { */ public etherToken: EtherTokenWrapper; /** - * An instance of the ProxyWrapper class containing methods for interacting with the - * proxy smart contract. + * An instance of the TokenTransferProxyWrapper class containing methods for interacting with the + * tokenTransferProxy smart contract. */ - public proxy: ProxyWrapper; + public proxy: TokenTransferProxyWrapper; private _web3Wrapper: Web3Wrapper; /** * Verifies that the elliptic curve signature `signature` was generated @@ -167,7 +167,7 @@ export class ZeroEx { constructor(provider: Web3Provider) { this._web3Wrapper = new Web3Wrapper(provider); this.token = new TokenWrapper(this._web3Wrapper); - this.proxy = new ProxyWrapper(this._web3Wrapper); + this.proxy = new TokenTransferProxyWrapper(this._web3Wrapper); this.exchange = new ExchangeWrapper(this._web3Wrapper, this.token); this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper); this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token); diff --git a/src/contract_wrappers/proxy_wrapper.ts b/src/contract_wrappers/proxy_wrapper.ts deleted file mode 100644 index c69ca7017..000000000 --- a/src/contract_wrappers/proxy_wrapper.ts +++ /dev/null @@ -1,41 +0,0 @@ -import * as _ from 'lodash'; -import {ContractWrapper} from './contract_wrapper'; -import * as TokenTransferProxyArtifacts from '../artifacts/TokenTransferProxy.json'; -import {ProxyContract} from '../types'; - -/** - * This class includes the functionality related to interacting with the Proxy contract. - */ -export class ProxyWrapper extends ContractWrapper { - private _proxyContractIfExists?: ProxyContract; - /** - * Check if the Exchange contract address is authorized by the Proxy contract. - * @param exchangeContractAddress The hex encoded address of the Exchange contract to call. - * @return Whether the exchangeContractAddress is authorized. - */ - public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> { - const proxyContractInstance = await this._getProxyContractAsync(); - const isAuthorized = await proxyContractInstance.authorized.call(exchangeContractAddress); - return isAuthorized; - } - /** - * Get the list of all Exchange contract addresses authorized by the Proxy contract. - * @return The list of authorized addresses. - */ - public async getAuthorizedAddressesAsync(): Promise<string[]> { - const proxyContractInstance = await this._getProxyContractAsync(); - const authorizedAddresses = await proxyContractInstance.getAuthorizedAddresses.call(); - return authorizedAddresses; - } - private _invalidateContractInstance(): void { - delete this._proxyContractIfExists; - } - private async _getProxyContractAsync(): Promise<ProxyContract> { - if (!_.isUndefined(this._proxyContractIfExists)) { - return this._proxyContractIfExists; - } - const contractInstance = await this._instantiateContractIfExistsAsync((TokenTransferProxyArtifacts as any)); - this._proxyContractIfExists = contractInstance as ProxyContract; - return this._proxyContractIfExists; - } -} diff --git a/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/src/contract_wrappers/token_transfer_proxy_wrapper.ts new file mode 100644 index 000000000..39263efac --- /dev/null +++ b/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -0,0 +1,41 @@ +import * as _ from 'lodash'; +import {ContractWrapper} from './contract_wrapper'; +import * as TokenTransferProxyArtifacts from '../artifacts/TokenTransferProxy.json'; +import {TokenTransferProxyContract} from '../types'; + +/** + * This class includes the functionality related to interacting with the TokenTransferProxy contract. + */ +export class TokenTransferProxyWrapper extends ContractWrapper { + private _tokenTransferProxyContractIfExists?: TokenTransferProxyContract; + /** + * Check if the Exchange contract address is authorized by the TokenTransferProxy contract. + * @param exchangeContractAddress The hex encoded address of the Exchange contract to call. + * @return Whether the exchangeContractAddress is authorized. + */ + public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> { + const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync(); + const isAuthorized = await tokenTransferProxyContractInstance.authorized.call(exchangeContractAddress); + return isAuthorized; + } + /** + * Get the list of all Exchange contract addresses authorized by the TokenTransferProxy contract. + * @return The list of authorized addresses. + */ + public async getAuthorizedAddressesAsync(): Promise<string[]> { + const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync(); + const authorizedAddresses = await tokenTransferProxyContractInstance.getAuthorizedAddresses.call(); + return authorizedAddresses; + } + private _invalidateContractInstance(): void { + delete this._tokenTransferProxyContractIfExists; + } + private async _getTokenTransferProxyContractAsync(): Promise<TokenTransferProxyContract> { + if (!_.isUndefined(this._tokenTransferProxyContractIfExists)) { + return this._tokenTransferProxyContractIfExists; + } + const contractInstance = await this._instantiateContractIfExistsAsync((TokenTransferProxyArtifacts as any)); + this._tokenTransferProxyContractIfExists = contractInstance as TokenTransferProxyContract; + return this._tokenTransferProxyContractIfExists; + } +} diff --git a/src/types.ts b/src/types.ts index 81ff30dc5..0de87ca71 100644 --- a/src/types.ts +++ b/src/types.ts @@ -152,7 +152,7 @@ export interface EtherTokenContract extends ContractInstance { withdraw: (amount: BigNumber.BigNumber, txOpts: TxOpts) => Promise<void>; } -export interface ProxyContract extends ContractInstance { +export interface TokenTransferProxyContract extends ContractInstance { getAuthorizedAddresses: { call: () => Promise<string[]>; }; |