// @ts-ignore import * as registryClient from '@src/assets/js/block-sync/data/TokenUniqueSymbolIndex.json'; import Web3 from 'web3'; import {environment} from '@src/environments/environment'; const web3 = new Web3(environment.web3Provider); const abi = registryClient.default; export class TokenRegistry { contractAddress: string; signerAddress: string; contract: any; constructor(contractAddress: string, signerAddress?: string) { this.contractAddress = contractAddress; this.contract = new web3.eth.Contract(abi, this.contractAddress); if (signerAddress) { this.signerAddress = signerAddress; } else { this.signerAddress = web3.eth.accounts[0]; } } public async totalTokens(): Promise { return await this.contract.methods.entryCount().call(); } public async entry(serial: number): Promise { return await this.contract.methods.entry(serial).call(); } public async addressOf(identifier: string): Promise { const id = '0x' + web3.utils.padRight(new Buffer(identifier).toString('hex'), 64); return await this.contract.methods.addressOf(id).call(); } }