Skip to content

Commit f679f5c

Browse files
fix formatting
1 parent 8b133fa commit f679f5c

9 files changed

Lines changed: 193 additions & 135 deletions

File tree

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# MDX files with code blocks - formatter breaks indentation
2+
light-token/cookbook/*.mdx
3+
light-token/faq.mdx
4+
light-token/toolkits/*.mdx
5+
blog/light-token.mdx
6+

blog/light-token.mdx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description: " Today we bring to you the light-token standard. A token standard
66
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
77
import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx";
88
import { RentLifecycleVisualizer } from "/snippets/jsx/rent-lifecycle-visualizer.jsx";
9+
import { blogSplCreateAtaCode, blogLightCreateAtaCode } from "/snippets/code-samples/code-compare-snippets.jsx";
910

1011
Today we bring to you the light-token standard. A token standard with mint and token accounts equivalent to SPL, but without rent-exemption.
1112
Users receive and send the same tokens.
@@ -44,20 +45,8 @@ and puts the barrier low to integrate light-token in your protocol, app, or paym
4445
Example to create SPL vs light-token account:
4546

4647
<CodeCompare
47-
firstCode={`// Create SPL token account
48-
const ix = createAssociatedTokenAccountInstruction(
49-
payer,
50-
ata,
51-
owner,
52-
mint
53-
);`}
54-
secondCode={`// Create light-token account
55-
const ix = CreateAssociatedTokenAccount.new(
56-
payer,
57-
account,
58-
owner,
59-
mint
60-
);`}
48+
firstCode={blogSplCreateAtaCode}
49+
secondCode={blogLightCreateAtaCode}
6150
firstLabel="SPL"
6251
secondLabel="Light Token"
6352
/>

light-token/cookbook/create-ata.mdx

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import CTokenTsClientPrerequisites from "/snippets/light-token-guides/light-toke
1616
import ClientCustomRentConfig from "/snippets/light-token-guides/client-custom-rent-config.mdx";
1717
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
1818
import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx";
19+
import {
20+
splCreateAtaCode,
21+
lightCreateAtaCode,
22+
} from "/snippets/code-samples/code-compare-snippets.jsx";
1923

2024
1. Associated light-token accounts are Solana accounts that hold token balances of light, SPL, or Token 2022 mints.
2125
2. The address for light-ATAs is deterministically derived with the owner's address, compressed token program ID, and mint address.
@@ -38,24 +42,8 @@ The `createAtaInterface` function creates an associated light-token account in a
3842
Compare to SPL:
3943

4044
<CodeCompare
41-
firstCode={`// SPL create ATA
42-
import { getOrCreateAssociatedTokenAccount } from "@solana/spl-token";
43-
44-
const ata = await getOrCreateAssociatedTokenAccount(
45-
connection,
46-
payer,
47-
mint,
48-
owner
49-
);`}
50-
secondCode={`// light-token create ATA
51-
import { createAtaInterface } from "@lightprotocol/compressed-token";
52-
53-
const ata = await createAtaInterface(
54-
rpc,
55-
payer,
56-
mint,
57-
owner
58-
);`}
45+
firstCode={splCreateAtaCode}
46+
secondCode={lightCreateAtaCode}
5947
firstLabel="SPL"
6048
secondLabel="light-token"
6149
/>
@@ -542,6 +530,7 @@ pub fn process_create_ata2_invoke_signed(
542530
# Next Steps
543531

544532
{" "}
533+
545534
<Card
546535
title="Learn how to mint light-tokens"
547536
icon="chevron-right"

light-token/cookbook/create-mint.mdx

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import ClientCustomRentConfig from "/snippets/light-token-guides/client-custom-r
1313
import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx";
1414
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
1515
import { CodeRunnerEmbed } from "/snippets/jsx/code-runner-embed.jsx";
16+
import {
17+
splCreateMintCode,
18+
lightCreateMintCode,
19+
} from "/snippets/code-samples/code-compare-snippets.jsx";
1620

1721
1. Mint accounts uniquely represent a token on Solana and store its global metadata.
1822
2. Mints for light-token accounts are compressed accounts and rent-free.
@@ -33,27 +37,8 @@ You can use the same interface regardless of mint type.
3337
Compare to SPL:
3438

3539
<CodeCompare
36-
firstCode={`// SPL createMint
37-
import { createMint } from "@solana/spl-token";
38-
39-
const mint = await createMint(
40-
connection,
41-
payer,
42-
mintAuthority,
43-
freezeAuthority,
44-
decimals
45-
);`}
46-
secondCode={`// light-token createMint
47-
import { createMintInterface } from "@lightprotocol/compressed-token";
48-
49-
const { mint } = await createMintInterface(
50-
rpc,
51-
payer,
52-
mintAuthority,
53-
freezeAuthority,
54-
decimals,
55-
mintKeypair
56-
);`}
40+
firstCode={splCreateMintCode}
41+
secondCode={lightCreateMintCode}
5742
firstLabel="SPL"
5843
secondLabel="light-token"
5944
/>

light-token/cookbook/mint-to.mdx

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import CTokenClientPrerequisites from "/snippets/light-token-guides/light-token-
1111
import ClientCustomRentConfig from "/snippets/light-token-guides/client-custom-rent-config.mdx";
1212
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
1313
import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx";
14+
import {
15+
splMintToCode,
16+
lightMintToCode,
17+
} from "/snippets/code-samples/code-compare-snippets.jsx";
1418

1519
1. Mint To creates new tokens of a mint and deposits them to a specified token account.
1620
2. Before we can mint any tokens, we need an initialized mint account (SPL, Token-2022 or Light) for which we hold the mint authority.
@@ -28,30 +32,10 @@ The function auto-detects the token program (SPL, Token-2022, or Light) from the
2832
Compare to SPL:
2933

3034
<CodeCompare
31-
firstCode={`// SPL mintTo
32-
import { mintTo } from "@solana/spl-token";
33-
34-
const tx = await mintTo(
35-
connection,
36-
payer,
37-
mint,
38-
destination,
39-
mintAuthority,
40-
amount
41-
);`}
42-
secondCode={`// light-token mintTo
43-
import { mintToInterface } from "@lightprotocol/compressed-token";
44-
45-
const tx = await mintToInterface(
46-
rpc,
47-
payer,
48-
mint,
49-
destination,
50-
mintAuthority,
51-
amount
52-
);`}
53-
firstLabel="SPL"
54-
secondLabel="light-token"
35+
firstCode={splMintToCode}
36+
secondCode={lightMintToCode}
37+
firstLabel="SPL"
38+
secondLabel="light-token"
5539
/>
5640

5741
<Info>
@@ -84,25 +68,24 @@ import {
8468
} from "@lightprotocol/compressed-token";
8569

8670
async function main() {
87-
const rpc = createRpc();
88-
const payer = Keypair.generate();
89-
const sig = await rpc.requestAirdrop(payer.publicKey, 10e9);
90-
await rpc.confirmTransaction(sig);
71+
const rpc = createRpc();
72+
const payer = Keypair.generate();
73+
const sig = await rpc.requestAirdrop(payer.publicKey, 10e9);
74+
await rpc.confirmTransaction(sig);
9175

92-
const { mint } = await createMintInterface(rpc, payer, payer, null, 9);
76+
const { mint } = await createMintInterface(rpc, payer, payer, null, 9);
9377

94-
const recipient = Keypair.generate();
95-
await createAtaInterface(rpc, payer, mint, recipient.publicKey);
78+
const recipient = Keypair.generate();
79+
await createAtaInterface(rpc, payer, mint, recipient.publicKey);
9680

97-
const destination = getAssociatedTokenAddressInterface(mint, recipient.publicKey);
98-
const tx = await mintToInterface(rpc, payer, mint, destination, payer, 1_000_000_000);
81+
const destination = getAssociatedTokenAddressInterface(mint, recipient.publicKey);
82+
const tx = await mintToInterface(rpc, payer, mint, destination, payer, 1_000_000_000);
9983

100-
console.log("Tx:", tx);
84+
console.log("Tx:", tx);
10185
}
10286

10387
main().catch(console.error);
104-
105-
````
88+
```
10689

10790
```typescript Instruction
10891
import "dotenv/config";
@@ -180,7 +163,7 @@ const payer = Keypair.fromSecretKey(
180163

181164
console.log("Tx:", signature);
182165
})();
183-
````
166+
```
184167

185168
</CodeGroup>
186169

light-token/cookbook/transfer-interface.mdx

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import CTokenTsClientPrerequisites from "/snippets/light-token-guides/light-toke
1313
import ClientCustomRentConfig from "/snippets/light-token-guides/client-custom-rent-config.mdx";
1414
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
1515
import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx";
16+
import {
17+
splTransferCode,
18+
lightTransferCode,
19+
} from "/snippets/code-samples/code-compare-snippets.jsx";
1620

1721
## Get Started
1822

@@ -57,29 +61,8 @@ The `transferInterface` function transfers tokens between token accounts (SPL, T
5761
Compare to SPL:
5862

5963
<CodeCompare
60-
firstCode={`// SPL transfer
61-
import { transfer } from "@solana/spl-token";
62-
63-
const tx = await transfer(
64-
connection,
65-
payer,
66-
sourceAta,
67-
destinationAta,
68-
owner,
69-
amount
70-
);`}
71-
secondCode={`// light-token transfer
72-
import { transferInterface } from "@lightprotocol/compressed-token";
73-
74-
const tx = await transferInterface(
75-
rpc,
76-
payer,
77-
sourceAta,
78-
mint,
79-
destinationAta,
80-
owner,
81-
amount
82-
);`}
64+
firstCode={splTransferCode}
65+
secondCode={lightTransferCode}
8366
firstLabel="SPL"
8467
secondLabel="light-token"
8568
/>

light-token/faq.mdx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ description: Frequently asked questions about light-token.
66
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
77
import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx";
88
import { RentLifecycleVisualizer } from "/snippets/jsx/rent-lifecycle-visualizer.jsx";
9+
import {
10+
splCreateAtaCode,
11+
lightCreateAtaCode,
12+
} from "/snippets/code-samples/code-compare-snippets.jsx";
913

1014
#### What is light-token?
1115

@@ -33,26 +37,10 @@ No. The `light-token-sdk` methods follow similar patterns to SPL.
3337
Reveal the interface method in the code example and find a few examples below.
3438

3539
<CodeCompare
36-
firstCode={`// SPL create ATA
37-
import { getOrCreateAssociatedTokenAccount } from "@solana/spl-token";
38-
39-
const ata = await getOrCreateAssociatedTokenAccount(
40-
connection,
41-
payer,
42-
mint,
43-
owner
44-
);`}
45-
secondCode={`// light-token create ATA
46-
import { createAtaInterface } from "@lightprotocol/compressed-token";
47-
48-
const ata = await createAtaInterface(
49-
rpc,
50-
payer,
51-
mint,
52-
owner
53-
);`}
54-
firstLabel="SPL"
55-
secondLabel="light-token"
40+
firstCode={splCreateAtaCode}
41+
secondCode={lightCreateAtaCode}
42+
firstLabel="SPL"
43+
secondLabel="light-token"
5644
/>
5745

5846
<table>

light-token/toolkits/for-wallets.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const tx = new Transaction().add(
153153
))
154154
);
155155

156-
````
156+
```
157157

158158
<Accordion title="Compare to SPL">
159159

@@ -173,7 +173,7 @@ const tx = new Transaction().add(
173173
mint
174174
)
175175
);
176-
````
176+
```
177177

178178
</Accordion>
179179
</Tab>

0 commit comments

Comments
 (0)