aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/proxy_wrapper.ts
blob: 9deed5231549baff4b401b6e1030945068d798fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as _ from 'lodash';
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;
    /**
     * 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((ProxyArtifacts as any));
        this._proxyContractIfExists = contractInstance as ProxyContract;
        return this._proxyContractIfExists;
    }
}
a4dca2c5'>Update libzpaq and zpaqd to 6.33, and zpaq to 6.41bf2013-08-082-4/+6 * - Convert to new perl frameworkaz2013-08-071-1/+2 * Relieve Maxim Andreev's from port maintainership. Repeated timeouts on lua-lgi;mandree2013-08-061-1/+1 * - Convert to new perl frameworkmat2013-08-0316-57/+40 * For all my portsnaddy2013-08-022-3/+1 * Fix build without gccbapt2013-08-011-6/+3 * Fix build with clangbapt2013-08-011-5/+2 * Fix build with clang by forcing gnu89bapt2013-07-301-1/+7 * Update to 3.09.fjoe2013-07-282-3/+3 * KDE3 and QT3 expired on 2013-07-01, remove these ports.rene2013-07-2711-155/+0 * - switch simple inline replacement from perl to sedaz2013-07-252-12/+5 * Remove MAKE_JOBS_SAFE which is now default.ehaupt2013-07-248-15/+0 * Mark as broken: does not buildbapt2013-07-241-0/+2 * Use GNU versions of tar, md5sum, sha1sum, sha256sum during runtimepawel2013-07-231-3/+8 * Horde package update:mm2013-07-174-10/+6 * - Update devel/automake to 1.14ade2013-07-162-0/+6 * qpress is a portable file archiver using QuickLZ and designed to utilize fastpawel2013-07-154-0/+35 * Update RPM to 4.11.1johans2013-07-15