@bit-ui-libs/common
Version:
This library was generated with [Nx](https://nx.dev).
75 lines (61 loc) • 2.15 kB
text/typescript
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<void, MintRequest>(`${this.web3ApiUrl}/mint-${type}`, req);
}
getWitnessVdt(witnessId: string) {
return this.get<WitnessVDTResponse>(`${this.web3ApiUrl}/witness-vdt/${witnessId}`);
}
getDeviceVdt(deviceId: string) {
return this.get<DeviceVdt>(`${this.web3ApiUrl}/device-vdt/${deviceId}`);
}
getUserVdt(userId: string) {
return this.get<UserVdt>(`${this.web3ApiUrl}/user-vdt/${userId}`, {});
}
getUserVdtPublic(qrId: string) {
return this.get<UserVdtPublic>(`${this.web3ApiUrl}/${qrId}/user-vdt-public`, {});
}
initUserVdt(req: InitUserVdtRequest) {
return this.post<void, InitUserVdtRequest>(`${this.web3ApiUrl}/init-user-vdt`, req);
}
initUserListVdt() {
return this.post<void, object>(`${this.web3ApiUrl}/init-user-list-vdt`, {});
}
initUserVdtV2(req: InitUserVdtRequest) {
return this.post<void, InitUserVdtRequest>(`${this.web3ApiUrl}/init-user-vdt-v2`, req);
}
getOrganizationVdtPublic(qrId: string) {
return this.get<OrganizationVdtPublic>(`${this.web3ApiUrl}/${qrId}/organization-vdt-public`, {});
}
getGasEstimation(assetId: string) {
return this.get<GasEstimation>(`${this.web3ApiUrl}/gas-estimation`, { assetId });
}
publishCustomerFile(id: string, comment?: string) {
return this.post<void, PublishCustomerFileRequest>(
`${this.web3ApiUrl}/customer-file/publish`,
{
id,
comment,
},
{ timeout: 60_000 }
);
}
}