import { BaseService, BaseServiceOptions } from '../api/services/base-service'; import { ChainTypeEnum } from '../asset/interfaces/chain-type-enum'; import { DeviceVdt, GasEstimation, InitUserVdtRequest, MintRequest, OrganizationVdtPublic, PublishCustomerFileRequest, UserVdt, UserVdtPublic, WitnessVDTResponse, } from '../web3/interfaces'; export class Web3Service extends BaseService { web3ApiUrl: string; constructor(opts: BaseServiceOptions) { super(opts); this.web3ApiUrl = `${this.apiUrl}/web3/v1/nft`; } mint(chainType: ChainTypeEnum, req: MintRequest) { const type = chainType === ChainTypeEnum.Services ? 'service' : 'asset'; return this.post(`${this.web3ApiUrl}/mint-${type}`, req); } getWitnessVdt(witnessId: string) { return this.get(`${this.web3ApiUrl}/witness-vdt/${witnessId}`); } getDeviceVdt(deviceId: string) { return this.get(`${this.web3ApiUrl}/device-vdt/${deviceId}`); } getUserVdt(userId: string) { return this.get(`${this.web3ApiUrl}/user-vdt/${userId}`, {}); } getUserVdtPublic(qrId: string) { return this.get(`${this.web3ApiUrl}/${qrId}/user-vdt-public`, {}); } initUserVdt(req: InitUserVdtRequest) { return this.post(`${this.web3ApiUrl}/init-user-vdt`, req); } initUserListVdt() { return this.post(`${this.web3ApiUrl}/init-user-list-vdt`, {}); } initUserVdtV2(req: InitUserVdtRequest) { return this.post(`${this.web3ApiUrl}/init-user-vdt-v2`, req); } getOrganizationVdtPublic(qrId: string) { return this.get(`${this.web3ApiUrl}/${qrId}/organization-vdt-public`, {}); } getGasEstimation(assetId: string) { return this.get(`${this.web3ApiUrl}/gas-estimation`, { assetId }); } publishCustomerFile(id: string, comment?: string) { return this.post( `${this.web3ApiUrl}/customer-file/publish`, { id, comment, }, { timeout: 60_000 } ); } }