aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/token_transfer_proxy_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-08-22 17:28:26 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-08-22 19:28:05 +0800
commitb2b5abadb22420650334041f9560e3ac4e5b7e41 (patch)
treeaddd32fe30c217f07b4251828c224df265a10d5e /src/contract_wrappers/token_transfer_proxy_wrapper.ts
parent0bc9083bff341cc7841fb1ccd84fa50e6749151d (diff)
downloaddexon-sol-tools-b2b5abadb22420650334041f9560e3ac4e5b7e41.tar
dexon-sol-tools-b2b5abadb22420650334041f9560e3ac4e5b7e41.tar.gz
dexon-sol-tools-b2b5abadb22420650334041f9560e3ac4e5b7e41.tar.bz2
dexon-sol-tools-b2b5abadb22420650334041f9560e3ac4e5b7e41.tar.lz
dexon-sol-tools-b2b5abadb22420650334041f9560e3ac4e5b7e41.tar.xz
dexon-sol-tools-b2b5abadb22420650334041f9560e3ac4e5b7e41.tar.zst
dexon-sol-tools-b2b5abadb22420650334041f9560e3ac4e5b7e41.zip
Rename internally Proxy to TokenTransferProxy
Diffstat (limited to 'src/contract_wrappers/token_transfer_proxy_wrapper.ts')
-rw-r--r--src/contract_wrappers/token_transfer_proxy_wrapper.ts41
1 files changed, 41 insertions, 0 deletions
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;
+ }
+}