From 6899de25399c45848fc54dfbf6a65ffd2e5be072 Mon Sep 17 00:00:00 2001 From: Leonn Leite Date: Tue, 6 Jan 2026 13:38:51 -0300 Subject: [PATCH] refactor: remove social media URL handling from token sale creation --- src/api/types/LaunchpadDtos.ts | 21 ------ src/chaincode/launchpad/createSale.spec.ts | 88 +--------------------- src/chaincode/launchpad/createSale.ts | 10 +-- 3 files changed, 2 insertions(+), 117 deletions(-) diff --git a/src/api/types/LaunchpadDtos.ts b/src/api/types/LaunchpadDtos.ts index c2bea99..16cd9e4 100644 --- a/src/api/types/LaunchpadDtos.ts +++ b/src/api/types/LaunchpadDtos.ts @@ -104,18 +104,6 @@ export class CreateTokenSaleDTO extends SubmitCallDTO { @BigNumberProperty() public preBuyQuantity: BigNumber; - @IsString() - @IsOptional() - public websiteUrl?: string; - - @IsString() - @IsOptional() - public telegramUrl?: string; - - @IsString() - @IsOptional() - public twitterUrl?: string; - @IsOptional() @IsInt() public saleStartTime?: number; @@ -176,15 +164,6 @@ export class CreateSaleResDto { @IsNotEmpty() public description: string; - @IsOptional() - public websiteUrl?: string; - - @IsOptional() - public telegramUrl?: string; - - @IsOptional() - public twitterUrl?: string; - @IsNotEmpty() public initialBuyQuantity: string; diff --git a/src/chaincode/launchpad/createSale.spec.ts b/src/chaincode/launchpad/createSale.spec.ts index 614f384..960f443 100644 --- a/src/chaincode/launchpad/createSale.spec.ts +++ b/src/chaincode/launchpad/createSale.spec.ts @@ -34,7 +34,6 @@ describe("createSale", () => { "TestCollection", "TestCategory" ); - createSaleDto.websiteUrl = "https://example.com"; createSaleDto.uniqueKey = randomUniqueKey(); const signedDto = createSaleDto.signed(users.testUser1.privateKey); @@ -54,60 +53,6 @@ describe("createSale", () => { expect(response.Data?.isFinalized).toBe(false); }); - it("should create token sale with telegram URL", async () => { - // Given - const { ctx, contract } = fixture(LaunchpadContract).registeredUsers(users.testUser1); - - const createSaleDto = new CreateTokenSaleDTO( - "Telegram Token", - "TG", - "A token with telegram link", - "https://example.com/tg.png", - new BigNumber(0), - "TelegramCollection", - "SocialCategory" - ); - createSaleDto.telegramUrl = "https://t.me/testtoken"; - createSaleDto.uniqueKey = randomUniqueKey(); - - const signedDto = createSaleDto.signed(users.testUser1.privateKey); - - // When - const response = await contract.CreateSale(ctx, signedDto); - - // Then - expect(response.Status).toBe(1); - expect(response.Data?.telegramUrl).toBe("https://t.me/testtoken"); - expect(response.Data?.websiteUrl).toBe(""); - expect(response.Data?.twitterUrl).toBe(""); - }); - - it("should create token sale with twitter URL", async () => { - // Given - const { ctx, contract } = fixture(LaunchpadContract).registeredUsers(users.testUser1); - - const createSaleDto = new CreateTokenSaleDTO( - "Twitter Token", - "TWT", - "A token with twitter link", - "https://example.com/twt.png", - new BigNumber(0), - "TwitterCollection", - "SocialCategory" - ); - createSaleDto.twitterUrl = "https://twitter.com/testtoken"; - createSaleDto.uniqueKey = randomUniqueKey(); - - const signedDto = createSaleDto.signed(users.testUser1.privateKey); - - // When - const response = await contract.CreateSale(ctx, signedDto); - - // Then - expect(response.Status).toBe(1); - expect(response.Data?.twitterUrl).toBe("https://twitter.com/testtoken"); - }); - it("should create token sale with pre-buy amount", async () => { // Given - Setup GALA token for pre-buy (matching LaunchpadSale nativeToken) const galaClass = plainToInstance(TokenClass, { @@ -162,7 +107,6 @@ describe("createSale", () => { "PreBuyCollection", "PreBuyCategory" ); - createSaleDto.websiteUrl = "https://example.com"; createSaleDto.uniqueKey = randomUniqueKey(); const signedDto = createSaleDto.signed(users.testUser1.privateKey); @@ -188,7 +132,6 @@ describe("createSale", () => { "LowerCollection", "LowerCategory" ); - createSaleDto.websiteUrl = "https://example.com"; createSaleDto.uniqueKey = randomUniqueKey(); const signedDto = createSaleDto.signed(users.testUser1.privateKey); @@ -201,35 +144,7 @@ describe("createSale", () => { expect(response.Data?.symbol).toBe("LOWER"); // Should be converted to uppercase }); - it("should create sale with all social media URLs", async () => { - // Given - const { ctx, contract } = fixture(LaunchpadContract).registeredUsers(users.testUser1); - - const createSaleDto = new CreateTokenSaleDTO( - "Social Token", - "SOC", - "A fully connected social token", - "https://example.com/soc.png", - new BigNumber(0), - "SocialCollection", - "FullSocialCategory" - ); - createSaleDto.websiteUrl = "https://socialtoken.com"; - createSaleDto.telegramUrl = "https://t.me/socialtoken"; - createSaleDto.twitterUrl = "https://twitter.com/socialtoken"; - createSaleDto.uniqueKey = randomUniqueKey(); - - const signedDto = createSaleDto.signed(users.testUser1.privateKey); - - // When - const response = await contract.CreateSale(ctx, signedDto); - - // Then - expect(response.Status).toBe(1); - 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"); - }); + // Social links are now handled off-chain (DB source of truth); chain no longer returns them. it("should create sale with custom token image", async () => { // Given @@ -244,7 +159,6 @@ describe("createSale", () => { "ImageCollection", "ImageCategory" ); - createSaleDto.websiteUrl = "https://example.com"; createSaleDto.uniqueKey = randomUniqueKey(); const signedDto = createSaleDto.signed(users.testUser1.privateKey); diff --git a/src/chaincode/launchpad/createSale.ts b/src/chaincode/launchpad/createSale.ts index a4fd577..e892e5a 100644 --- a/src/chaincode/launchpad/createSale.ts +++ b/src/chaincode/launchpad/createSale.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ConflictError, DefaultError, TokenInstanceKey, asValidUserAlias } from "@gala-chain/api"; +import { ConflictError, TokenInstanceKey, asValidUserAlias } from "@gala-chain/api"; import { GalaChainContext, createTokenClass, @@ -30,7 +30,6 @@ import { NativeTokenQuantityDto, SaleStatus } from "../../api/types"; -import { PreConditionFailedError } from "../../api/utils/error"; import { buyWithNative } from "./buyWithNative"; /** @@ -62,10 +61,6 @@ export async function createSale( let isSaleFinalized = false; // Validate input parameters - if (!launchpadDetails.websiteUrl && !launchpadDetails.telegramUrl && !launchpadDetails.twitterUrl) { - throw new PreConditionFailedError("Token sale creation requires atleast one social link."); - } - launchpadDetails.tokenSymbol = launchpadDetails.tokenSymbol.toUpperCase(); // Define the token class key @@ -165,9 +160,6 @@ export async function createSale( tokenName: launchpadDetails.tokenName, symbol: launchpadDetails.tokenSymbol, description: launchpadDetails.tokenDescription, - websiteUrl: launchpadDetails.websiteUrl ? launchpadDetails.websiteUrl : "", - telegramUrl: launchpadDetails.telegramUrl ? launchpadDetails.telegramUrl : "", - twitterUrl: launchpadDetails.twitterUrl ? launchpadDetails.twitterUrl : "", initialBuyQuantity: launchpadDetails.preBuyQuantity.toFixed(), vaultAddress: vaultAddress, creatorAddress: ctx.callingUser,