diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-04 07:21:17 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-16 04:36:59 +0800 |
commit | 3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd (patch) | |
tree | 15d4c7df95fd96d6aedb712738cd18bfb213b1f1 /packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts | |
parent | 2aa73fc83962d421eae4447108a07a5d952b569d (diff) | |
download | dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar.gz dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar.zst dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.zip |
Remove artifacts from migrations package and update contract-wrappers accordingly
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts index 6ba162213..2472d512b 100644 --- a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts @@ -13,25 +13,25 @@ import { ContractWrapper } from './contract_wrapper'; */ export class ERC721ProxyWrapper extends ContractWrapper { public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi; + public address: string; private _erc721ProxyContractIfExists?: wrappers.ERC721ProxyContract; - private _contractAddressIfExists?: string; /** * Instantiate ERC721ProxyWrapper * @param web3Wrapper Web3Wrapper instance to use - * @param networkId Desired networkId - * @param contractAddressIfExists The contract address to use. This is usually pulled from - * the artifacts but needs to be specified when using with your own custom testnet. + * @param address The address of the ERC721Proxy contract */ - constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) { - super(web3Wrapper, networkId); - this._contractAddressIfExists = contractAddressIfExists; + // TODO(albrow): Make address optional and default to looking up the address + // based in a hard-coded mapping based on web3Wrapper network id. + constructor(web3Wrapper: Web3Wrapper, address: string) { + super(web3Wrapper); + this.address = address; } /** * Get the 4 bytes ID of this asset proxy * @return Proxy id */ public async getProxyIdAsync(): Promise<AssetProxyId> { - const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync(); + const ERC721ProxyContractInstance = await this._getERC721ProxyContract(); const proxyId = (await ERC721ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId; return proxyId; } @@ -43,7 +43,7 @@ export class ERC721ProxyWrapper extends ContractWrapper { public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> { assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress); const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase(); - const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync(); + const ERC721ProxyContractInstance = await this._getERC721ProxyContract(); const isAuthorized = await ERC721ProxyContractInstance.authorized.callAsync(normalizedExchangeContractAddress); return isAuthorized; } @@ -52,36 +52,23 @@ export class ERC721ProxyWrapper extends ContractWrapper { * @return The list of authorized addresses. */ public async getAuthorizedAddressesAsync(): Promise<string[]> { - const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync(); + const ERC721ProxyContractInstance = await this._getERC721ProxyContract(); const authorizedAddresses = await ERC721ProxyContractInstance.getAuthorizedAddresses.callAsync(); return authorizedAddresses; } - /** - * Retrieves the Ethereum address of the ERC721Proxy contract deployed on the network - * that the user-passed web3 provider is connected to. - * @returns The Ethereum address of the ERC721Proxy contract being used. - */ - public getContractAddress(): string { - const contractAddress = this._getContractAddress(artifacts.ERC721Proxy, this._contractAddressIfExists); - return contractAddress; - } // HACK: We don't want this method to be visible to the other units within that package but not to the end user. // TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused. // tslint:disable-next-line:no-unused-variable private _invalidateContractInstance(): void { delete this._erc721ProxyContractIfExists; } - private async _getERC721ProxyContractAsync(): Promise<wrappers.ERC721ProxyContract> { + private _getERC721ProxyContract(): wrappers.ERC721ProxyContract { if (!_.isUndefined(this._erc721ProxyContractIfExists)) { return this._erc721ProxyContractIfExists; } - const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync( - artifacts.ERC721Proxy, - this._contractAddressIfExists, - ); const contractInstance = new wrappers.ERC721ProxyContract( - abi, - address, + this.abi, + this.address, this._web3Wrapper.getProvider(), this._web3Wrapper.getContractDefaults(), ); |