src/app/_eth/token-registry.ts
Properties |
Methods |
|
constructor(contractAddress: string, signerAddress?: string)
|
Defined in src/app/_eth/token-registry.ts:10
|
contract |
Type : any
|
Defined in src/app/_eth/token-registry.ts:10
|
contractAddress |
Type : string
|
Defined in src/app/_eth/token-registry.ts:8
|
signerAddress |
Type : string
|
Defined in src/app/_eth/token-registry.ts:9
|
Public Async addressOf | ||||||
addressOf(identifier: string)
|
||||||
Defined in src/app/_eth/token-registry.ts:30
|
||||||
Parameters :
Returns :
Promise<string>
|
Public Async entry | ||||||
entry(serial: number)
|
||||||
Defined in src/app/_eth/token-registry.ts:26
|
||||||
Parameters :
Returns :
Promise<string>
|
Public Async totalTokens |
totalTokens()
|
Defined in src/app/_eth/token-registry.ts:22
|
Returns :
Promise<number>
|
import Web3 from 'web3';
import {environment} from '@src/environments/environment';
const abi: Array<any> = require('@src/assets/js/block-sync/data/TokenUniqueSymbolIndex.json');
const web3: Web3 = new Web3(environment.web3Provider);
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<number> {
return await this.contract.methods.entryCount().call();
}
public async entry(serial: number): Promise<string> {
return await this.contract.methods.entry(serial).call();
}
public async addressOf(identifier: string): Promise<string> {
const id: string = web3.eth.abi.encodeParameter('bytes32', web3.utils.toHex(identifier));
return await this.contract.methods.addressOf(id).call();
}
}