nft-folder-blockchain-connector-besu
Version:
A NestJS-based blockchain connector that communicates with specific smart contracts from the NFT Folder project.
131 lines • 6.6 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SegmentController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const segment_service_1 = require("./segment.service");
const segment_create_dto_1 = require("./dto/segment.create.dto");
const segment_read_dto_1 = require("./dto/segment.read.dto");
const token_information_dto_1 = require("../token/dto/token.information.dto");
let SegmentController = class SegmentController {
service;
constructor(service) {
this.service = service;
}
createSegment(dto) {
return this.service.createSegment(dto.name);
}
getAllSegments() {
return this.service.fetchAllSegments();
}
getSegment(index) {
return this.service.fetchSegment(index);
}
addToken(index, dto) {
return this.service.addToken(index, dto.tokenAddress, Number(dto.tokenId));
}
removeToken(index, dto) {
return this.service.removeToken(index, dto.tokenAddress, Number(dto.tokenId));
}
};
exports.SegmentController = SegmentController;
__decorate([
(0, common_1.Post)(),
(0, swagger_1.ApiOperation)({
description: 'This endpoint accepts a name and creates a new Segment with this name',
summary: 'Creates a new Segment',
}),
(0, swagger_1.ApiResponse)({ status: 201, description: 'The Segment has been successfully created.' }),
(0, swagger_1.ApiResponse)({ status: 400, description: 'The input does not have the correct format.' }),
(0, swagger_1.ApiBody)({ description: 'Contains the name of the new Segment', type: segment_create_dto_1.SegmentCreateDto }),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [segment_create_dto_1.SegmentCreateDto]),
__metadata("design:returntype", Promise)
], SegmentController.prototype, "createSegment", null);
__decorate([
(0, common_1.Get)(),
(0, swagger_1.ApiOperation)({ summary: 'Returns all segments' }),
(0, swagger_1.ApiOkResponse)({
description: 'The list of all segments that are stored on the blockchain.',
type: segment_read_dto_1.SegmentReadDto,
isArray: true,
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], SegmentController.prototype, "getAllSegments", null);
__decorate([
(0, common_1.Get)(':index'),
(0, swagger_1.ApiOperation)({ summary: 'Returns the segment at the specified index' }),
(0, swagger_1.ApiOkResponse)({
description: 'The Segment at the specified index',
type: segment_read_dto_1.SegmentReadDto,
isArray: false,
}),
(0, swagger_1.ApiResponse)({
status: 400,
description: 'The specified index has not the correct format or there is no Segment at the specified index.',
}),
(0, swagger_1.ApiParam)({ name: 'index', type: Number, description: 'The index of the searched Segment' }),
__param(0, (0, common_1.Param)('index')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], SegmentController.prototype, "getSegment", null);
__decorate([
(0, common_1.Patch)(':index/add-token'),
(0, swagger_1.ApiOperation)({ summary: 'Adds a token to the segment at the specified index' }),
(0, swagger_1.ApiOkResponse)({
description: 'The token was successfully added to the segment',
isArray: false,
}),
(0, swagger_1.ApiResponse)({
status: 400,
description: 'The specified index has not the correct format, there is no Segment at the specified index, the token does not exist or the token has already been added to the segment.',
}),
(0, swagger_1.ApiParam)({ name: 'index', type: String }),
(0, swagger_1.ApiBody)({ type: token_information_dto_1.TokenInformationDto, description: 'Contains the address and id of the token' }),
__param(0, (0, common_1.Param)('index')),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, token_information_dto_1.TokenInformationDto]),
__metadata("design:returntype", Promise)
], SegmentController.prototype, "addToken", null);
__decorate([
(0, common_1.Patch)(':index/remove-token'),
(0, swagger_1.ApiOperation)({ summary: 'Removes a token from the segment at the specified index' }),
(0, swagger_1.ApiOkResponse)({
description: 'The token was successfully removed from the segment',
isArray: false,
}),
(0, swagger_1.ApiResponse)({
status: 400,
description: 'The specified index has not the correct format, there is no Segment at the specified index, the token does not exist or the token is not part of the segment.',
}),
(0, swagger_1.ApiParam)({ name: 'index', type: String }),
(0, swagger_1.ApiBody)({ type: token_information_dto_1.TokenInformationDto, description: 'Contains the address and id of the token' }),
__param(0, (0, common_1.Param)('index')),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, token_information_dto_1.TokenInformationDto]),
__metadata("design:returntype", Promise)
], SegmentController.prototype, "removeToken", null);
exports.SegmentController = SegmentController = __decorate([
(0, common_1.Controller)('segments'),
(0, swagger_1.ApiTags)('Segments'),
__metadata("design:paramtypes", [segment_service_1.SegmentService])
], SegmentController);
//# sourceMappingURL=segment.controller.js.map