import { getProvider } from '@decentraland/web3-provider'; import abi from '../../contracts/ERC1155ERC721'; import * as EthConnect from "../../node_modules/eth-connect/esm"; import { RequestManager } from '../../node_modules/eth-connect/eth-connect'; export class ERC1155ERC721Contract { requestManager: RequestManager|undefined; contract: any|undefined; public async connect(address: string) { const provider = await getProvider() this.requestManager = new EthConnect.RequestManager(provider); const factory = new EthConnect.ContractFactory(this.requestManager, abi); this.contract = (await factory.at(address)) as any; } public async getItemQuantity(seller: string, supplyID: string): Promise { if (this.contract === undefined) { throw new Error('ERC1155ERC721Contract not connected yet') } log('getItemQuantity', 'seller', seller, 'supplyID', supplyID); return await this.contract.balanceOf(seller, supplyID); } }