Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"swagger": "2.0",
"info": {
"version": "1.26.15",
"version": "1.26.16",
"title": "THX API Specification",
"description": "User guides are available at https://docs.thx.network."
},
Expand Down Expand Up @@ -772,6 +772,12 @@
},
"description": {
"example": "any"
},
"royaltyAddress": {
"example": "any"
},
"royaltyPercentage": {
"example": "any"
}
}
}
Expand Down Expand Up @@ -3203,6 +3209,24 @@
}
}
},
"royaltyRecipient": {
"type": "object",
"properties": {
"type": {
"type": "string",
"example": "string"
}
}
},
"royaltyBps": {
"type": "object",
"properties": {
"type": {
"type": "string",
"example": "number"
}
}
},
"logoImgUrl": {
"type": "object",
"properties": {
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/erc721/erc721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe('ERC721', () => {
schema = [
{ name: 'color', propType: 'string', description: 'lorem ipsum' },
{ name: 'size', propType: 'string', description: 'lorem ipsum dolor sit' },
];
],
royaltyAddress = '0x00',
royaltyPercentage = 5;
let erc721ID: string;

beforeAll(beforeAllCallback);
Expand All @@ -34,6 +36,8 @@ describe('ERC721', () => {
name,
symbol,
description,
royaltyAddress,
royaltyPercentage,
schema: JSON.stringify(schema),
})
.expect(({ body }: request.Response) => {
Expand All @@ -50,6 +54,8 @@ describe('ERC721', () => {
expect(body.properties[1].propType).toBe(schema[1].propType);
expect(isAddress(body.address)).toBe(true);
expect(body.archived).toBe(false);
expect(body.royaltyRecipient).toBe(royaltyAddress);
expect(body.royaltyBps).toBe(royaltyPercentage * 1000);
expect(body.logoImgUrl).toBeDefined();
erc721ID = body._id;
})
Expand All @@ -73,6 +79,8 @@ describe('ERC721', () => {
expect(body.properties[1].description).toBe(schema[1].description);
expect(body.properties[1].name).toBe(schema[1].name);
expect(body.properties[1].propType).toBe(schema[1].propType);
expect(body.royaltyRecipient).toBe(royaltyAddress);
expect(body.royaltyBps).toBe(royaltyPercentage * 1000);
expect(isAddress(body.address)).toBe(true);
expect(body.logoImgUrl).toBeDefined();
})
Expand Down
5 changes: 5 additions & 0 deletions src/controllers/erc721/post.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Request, Response } from 'express';
import { body, check } from 'express-validator';
import ERC721Service from '@/services/ERC721Service';
import { ADDRESS_ZERO } from '@/config/secrets';
import ImageService from '@/services/ImageService';
import { BadRequestError } from '@/util/errors';

Expand All @@ -9,6 +10,8 @@ const validation = [
body('symbol').exists().isString(),
body('description').exists().isString(),
body('chainId').exists().isNumeric(),
body('royaltyAddress').optional().isString(),
body('royaltyPercentage').optional().isInt({ max: 100 }),
body('schema').exists(),
check('file')
.optional()
Expand Down Expand Up @@ -44,6 +47,8 @@ const controller = async (req: Request, res: Response) => {
description: req.body.description,
properties,
archived: false,
royaltyRecipient: req.body.royaltyAddress ? req.body.royaltyAddress : ADDRESS_ZERO,
royaltyBps: req.body.royaltyPercentage ? Number(req.body.royaltyPercentage) * 1000 : 0,
logoImgUrl,
});

Expand Down
2 changes: 2 additions & 0 deletions src/models/ERC721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const ERC721Schema = new mongoose.Schema(
baseURL: String,
properties: [{ name: String, propType: String, description: String }],
archived: Boolean,
royaltyRecipient: String,
royaltyBps: Number,
logoImgUrl: String,
},
{ timestamps: true },
Expand Down
2 changes: 1 addition & 1 deletion src/services/ERC721Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function deploy(data: TERC721): Promise<ERC721Document> {
const contract = await TransactionService.deploy(
abi,
bytecode,
[erc721.name, erc721.symbol, erc721.baseURL, defaultAccount],
[erc721.name, erc721.symbol, erc721.baseURL, defaultAccount, erc721.royaltyRecipient, erc721.royaltyBps],
erc721.chainId,
);

Expand Down
2 changes: 2 additions & 0 deletions src/types/TERC721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type TERC721 = {
createdAt?: Date;
updatedAt?: Date;
archived?: boolean;
royaltyRecipient?: string;
royaltyBps?: number;
logoImgUrl?: string;
};

Expand Down