aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/proxy_wrapper.ts
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-07-04 03:28:34 +0800
committerGitHub <noreply@github.com>2017-07-04 03:28:34 +0800
commitd4cef89587ef8ea0f7fbab1146c4524e8f588eac (patch)
tree93dcf602b5a738bad03c121384707fcf19518310 /src/contract_wrappers/proxy_wrapper.ts
parentd506a1f98562dd11ecff5e936a93fce6d14e48a9 (diff)
parent8204409c6d6bf773aa8ebb38006a3975ed43a684 (diff)
downloaddexon-sol-tools-d4cef89587ef8ea0f7fbab1146c4524e8f588eac.tar
dexon-sol-tools-d4cef89587ef8ea0f7fbab1146c4524e8f588eac.tar.gz
dexon-sol-tools-d4cef89587ef8ea0f7fbab1146c4524e8f588eac.tar.bz2
dexon-sol-tools-d4cef89587ef8ea0f7fbab1146c4524e8f588eac.tar.lz
dexon-sol-tools-d4cef89587ef8ea0f7fbab1146c4524e8f588eac.tar.xz
dexon-sol-tools-d4cef89587ef8ea0f7fbab1146c4524e8f588eac.tar.zst
dexon-sol-tools-d4cef89587ef8ea0f7fbab1146c4524e8f588eac.zip
Merge pull request #82 from 0xProject/add-exchange-address-to-order-struct
Allow multiple Exchange contracts and multiple artifacts
Diffstat (limited to 'src/contract_wrappers/proxy_wrapper.ts')
-rw-r--r--src/contract_wrappers/proxy_wrapper.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/contract_wrappers/proxy_wrapper.ts b/src/contract_wrappers/proxy_wrapper.ts
new file mode 100644
index 000000000..862bce131
--- /dev/null
+++ b/src/contract_wrappers/proxy_wrapper.ts
@@ -0,0 +1,33 @@
+import * as _ from 'lodash';
+import {Web3Wrapper} from '../web3_wrapper';
+import {ContractWrapper} from './contract_wrapper';
+import * as ProxyArtifacts from '../artifacts/Proxy.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;
+ public invalidateContractInstance(): void {
+ delete this._proxyContractIfExists;
+ }
+ /**
+ * Check if the Exchange contract address is authorized by the Proxy contract.
+ * @param exchangeContractAddress The hex encoded address of the Exchange contract to use.
+ * @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;
+ }
+ private async _getProxyContractAsync(): Promise<ProxyContract> {
+ if (!_.isUndefined(this._proxyContractIfExists)) {
+ return this._proxyContractIfExists;
+ }
+ const contractInstance = await this._instantiateContractIfExistsAsync((ProxyArtifacts as any));
+ this._proxyContractIfExists = contractInstance as ProxyContract;
+ return this._proxyContractIfExists;
+ }
+}