diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-30 03:14:49 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-30 03:14:49 +0800 |
commit | 889410d605fd83aa00518332ad3e26e230cf769d (patch) | |
tree | b762418ecd5e1c077cf2419d1a8223df9c6462f1 | |
parent | 82cceb86059ef6b4eb67898ae1640a5b66bafda9 (diff) | |
download | dexon-sol-tools-889410d605fd83aa00518332ad3e26e230cf769d.tar dexon-sol-tools-889410d605fd83aa00518332ad3e26e230cf769d.tar.gz dexon-sol-tools-889410d605fd83aa00518332ad3e26e230cf769d.tar.bz2 dexon-sol-tools-889410d605fd83aa00518332ad3e26e230cf769d.tar.lz dexon-sol-tools-889410d605fd83aa00518332ad3e26e230cf769d.tar.xz dexon-sol-tools-889410d605fd83aa00518332ad3e26e230cf769d.tar.zst dexon-sol-tools-889410d605fd83aa00518332ad3e26e230cf769d.zip |
Add Proxy wrapper
-rw-r--r-- | src/contract_wrappers/proxy_wrapper.ts | 36 |
1 files changed, 36 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..18c6fdd23 --- /dev/null +++ b/src/contract_wrappers/proxy_wrapper.ts @@ -0,0 +1,36 @@ +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 Proxy contract. + */ +export class ProxyWrapper extends ContractWrapper { + private _proxyContractIfExists?: ProxyContract; + constructor(web3Wrapper: Web3Wrapper) { + super(web3Wrapper); + } + public invalidateContractInstance(): void { + delete this._proxyContractIfExists; + } + /** + * Check if the Exchange contract address is authorized within the Proxy contract. + * @param exchangeContractAddress The hex encoded address of the Exchange contract to use. + * @return If the exchangeContractAddress is authorized. + */ + public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> { + const proxyContractInstance = await this._getTokenRegistryContractAsync(); + const isAuthorized = await proxyContractInstance.authrized.call(exchangeContractAddress); + return isAuthorized; + } + private async _getTokenRegistryContractAsync(): 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; + } +} |