From 2467514280fcb4eae23892b6e1a34ad6db0a5c76 Mon Sep 17 00:00:00 2001 From: 0xRektified Date: Tue, 11 Nov 2025 19:24:18 +0800 Subject: [PATCH] fix: spl-token-sale-tutorial add missing helper functions in test setup --- .../spl-token-sale-tutorial.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/content/spl-token-sale-tutorial/spl-token-sale-tutorial.md b/content/spl-token-sale-tutorial/spl-token-sale-tutorial.md index 95d009b..2c189f7 100644 --- a/content/spl-token-sale-tutorial/spl-token-sale-tutorial.md +++ b/content/spl-token-sale-tutorial/spl-token-sale-tutorial.md @@ -189,6 +189,19 @@ import * as web3 from "@solana/web3.js"; import { assert } from "chai"; import { TokenSale } from "../target/types/token_sale"; +// Helper functions for token conversions +function toRawTokenAmount(amount: number): number { + return amount * 1e9; +} + +function toDisplayAmount(amount: number): number { + return amount / 1e9; +} + +function lamportsToSol(lamports: number | anchor.BN): number { + return Number(lamports) / 1e9; +} + describe("token_sale", async () => { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider);