Skip to content
Closed
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
40 changes: 40 additions & 0 deletions src/api/types/LaunchpadDtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ export class CreateTokenSaleDTO extends SubmitCallDTO {
@IsOptional()
public twitterUrl?: string;

@IsString()
@IsOptional()
public instagramUrl?: string;

@IsString()
@IsOptional()
public facebookUrl?: string;

@IsString()
@IsOptional()
public redditUrl?: string;

@IsString()
@IsOptional()
public tiktokUrl?: string;

@IsOptional()
@IsInt()
public saleStartTime?: number;
Expand Down Expand Up @@ -185,6 +201,30 @@ export class CreateSaleResDto {
@IsOptional()
public twitterUrl?: string;

@IsOptional()
public instagramUrl?: string;

@IsOptional()
public facebookUrl?: string;

@IsOptional()
public redditUrl?: string;

@IsOptional()
public tiktokUrl?: string;

@IsOptional()
public instagramUrl?: string;

@IsOptional()
public facebookUrl?: string;

@IsOptional()
public redditUrl?: string;

@IsOptional()
public tiktokUrl?: string;

@IsNotEmpty()
public initialBuyQuantity: string;

Expand Down
8 changes: 8 additions & 0 deletions src/chaincode/launchpad/createSale.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ describe("createSale", () => {
createSaleDto.websiteUrl = "https://socialtoken.com";
createSaleDto.telegramUrl = "https://t.me/socialtoken";
createSaleDto.twitterUrl = "https://twitter.com/socialtoken";
createSaleDto.instagramUrl = "https://instagram.com/socialtoken";
createSaleDto.facebookUrl = "https://facebook.com/socialtoken";
createSaleDto.redditUrl = "https://reddit.com/r/socialtoken";
createSaleDto.tiktokUrl = "https://tiktok.com/@socialtoken";
createSaleDto.uniqueKey = randomUniqueKey();

const signedDto = createSaleDto.signed(users.testUser1.privateKey);
Expand All @@ -229,6 +233,10 @@ describe("createSale", () => {
expect(response.Data?.websiteUrl).toBe("https://socialtoken.com");
expect(response.Data?.telegramUrl).toBe("https://t.me/socialtoken");
expect(response.Data?.twitterUrl).toBe("https://twitter.com/socialtoken");
expect(response.Data?.instagramUrl).toBe("https://instagram.com/socialtoken");
expect(response.Data?.facebookUrl).toBe("https://facebook.com/socialtoken");
expect(response.Data?.redditUrl).toBe("https://reddit.com/r/socialtoken");
expect(response.Data?.tiktokUrl).toBe("https://tiktok.com/@socialtoken");
});

it("should create sale with custom token image", async () => {
Expand Down
15 changes: 14 additions & 1 deletion src/chaincode/launchpad/createSale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ export async function createSale(
let isSaleFinalized = false;
// Validate input parameters

if (!launchpadDetails.websiteUrl && !launchpadDetails.telegramUrl && !launchpadDetails.twitterUrl) {
const hasAnySocial =
launchpadDetails.websiteUrl ||
launchpadDetails.telegramUrl ||
launchpadDetails.twitterUrl ||
launchpadDetails.instagramUrl ||
launchpadDetails.facebookUrl ||
launchpadDetails.redditUrl ||
launchpadDetails.tiktokUrl;

if (!hasAnySocial) {
throw new PreConditionFailedError("Token sale creation requires atleast one social link.");
}

Expand Down Expand Up @@ -168,6 +177,10 @@ export async function createSale(
websiteUrl: launchpadDetails.websiteUrl ? launchpadDetails.websiteUrl : "",
telegramUrl: launchpadDetails.telegramUrl ? launchpadDetails.telegramUrl : "",
twitterUrl: launchpadDetails.twitterUrl ? launchpadDetails.twitterUrl : "",
instagramUrl: launchpadDetails.instagramUrl ? launchpadDetails.instagramUrl : "",
facebookUrl: launchpadDetails.facebookUrl ? launchpadDetails.facebookUrl : "",
redditUrl: launchpadDetails.redditUrl ? launchpadDetails.redditUrl : "",
tiktokUrl: launchpadDetails.tiktokUrl ? launchpadDetails.tiktokUrl : "",
initialBuyQuantity: launchpadDetails.preBuyQuantity.toFixed(),
vaultAddress: vaultAddress,
creatorAddress: ctx.callingUser,
Expand Down