-
Notifications
You must be signed in to change notification settings - Fork 0
chore: update docs to new JS beta #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -128,7 +128,7 @@ import { | |||||
| buildAndSignTx, | ||||||
| } from "@lightprotocol/stateless.js"; | ||||||
| import { | ||||||
| CompressedTokenProgram, | ||||||
| LightTokenProgram, | ||||||
| selectMinCompressedTokenAccountsForTransfer, | ||||||
| } from "@lightprotocol/compressed-token"; | ||||||
| import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; | ||||||
|
|
@@ -158,7 +158,7 @@ const amount = bn(1e8); | |||||
| inputAccounts.map((account) => account.compressedAccount.hash) | ||||||
| ); | ||||||
|
|
||||||
| const ix = await CompressedTokenProgram.transfer({ | ||||||
| const ix = await LightTokenProgram.transfer({ | ||||||
| payer: payer.publicKey, | ||||||
| inputCompressedTokenAccounts: inputAccounts, | ||||||
| toAddress: recipient.publicKey, | ||||||
|
|
@@ -291,7 +291,7 @@ import * as fs from 'fs'; | |||||
| import * as os from 'os'; | ||||||
|
|
||||||
| // 1. Setup RPC connection and load filesystem wallet for mint operations | ||||||
| // 2. Call createMint() to create SPL mint with token pool for compression | ||||||
| // 2. Call createMint() to create SPL mint with SPL interface for compression | ||||||
| // 3. Call mintTo() to mint compressed tokens to filesystem wallet | ||||||
|
|
||||||
| const connection: Rpc = createRpc(); // defaults to localhost:8899 | ||||||
|
|
@@ -307,7 +307,7 @@ const mintKeypair = Keypair.generate(); | |||||
| await connection.requestAirdrop(payer.publicKey, 1e9); | ||||||
| await new Promise(resolve => setTimeout(resolve, 1000)); | ||||||
|
|
||||||
| // Create SPL mint with token pool for compression | ||||||
| // Create SPL mint with SPL interface for compression | ||||||
| const { mint, transactionSignature } = await createMint( | ||||||
| connection, | ||||||
| payer, | ||||||
|
|
@@ -322,7 +322,7 @@ const mintKeypair = Keypair.generate(); | |||||
| const mintToTxId = await mintTo( | ||||||
| connection, | ||||||
| payer, | ||||||
| mint, // SPL mint with token pool for compression | ||||||
| mint, // SPL mint with SPL interface for compression | ||||||
| payer.publicKey, // recipient address | ||||||
| payer, | ||||||
| 10e9, | ||||||
|
|
@@ -344,7 +344,7 @@ Make sure you add your Mint address to `send-tokens.ts`. | |||||
| // 1. Load wallet and fetch compressed token accounts with getCompressedTokenAccountsByOwner() | ||||||
| // 2. Select accounts for transfer using selectMinCompressedTokenAccountsForTransfer() | ||||||
| // and get validity proof with getValidityProof() | ||||||
| // 3. Create transfer instruction with CompressedTokenProgram.transfer() | ||||||
| // 3. Create transfer instruction with LightTokenProgram.transfer() | ||||||
| // and submit transaction with sendAndConfirmTx() | ||||||
| // 4. Verify balances via getCompressedTokenAccountsByOwner() | ||||||
|
|
||||||
|
|
@@ -357,7 +357,7 @@ import { | |||||
| buildAndSignTx, | ||||||
| } from "@lightprotocol/stateless.js"; | ||||||
| import { | ||||||
| CompressedTokenProgram, | ||||||
| LightTokenProgram, | ||||||
| selectMinCompressedTokenAccountsForTransfer, | ||||||
| } from "@lightprotocol/compressed-token"; | ||||||
| import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; | ||||||
|
|
@@ -381,7 +381,7 @@ const amount = bn(1e8); | |||||
| // Step 2: Fetch compressed account hashes from state trees | ||||||
| const compressedTokenAccounts = | ||||||
| await connection.getCompressedTokenAccountsByOwner(owner.publicKey, { | ||||||
| mint, // SPL mint with token pool for compression | ||||||
| mint, // SPL mint with SPL interface for compression | ||||||
| }); | ||||||
|
|
||||||
| if (compressedTokenAccounts.items.length === 0) { | ||||||
|
|
@@ -405,7 +405,7 @@ const amount = bn(1e8); | |||||
| ); | ||||||
|
|
||||||
| // Step 4: Create transfer instruction that consumes input accounts and creates new output accounts | ||||||
| const ix = await CompressedTokenProgram.transfer({ | ||||||
| const ix = await LightTokenProgram.transfer({ | ||||||
| payer: payer.publicKey, | ||||||
| inputCompressedTokenAccounts: inputAccounts, // accounts to consume | ||||||
| toAddress: recipient.publicKey, | ||||||
|
|
@@ -454,7 +454,7 @@ Use these integrations to let users convert between regular and compressed forma | |||||
|
|
||||||
| <Accordion title="Decompress to Regular SPL"> | ||||||
|
|
||||||
| This example converts compressed tokens to regular SPL format using `CompressedTokenProgram.decompress().` | ||||||
| This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress().` | ||||||
|
|
||||||
| ```javascript | ||||||
| import { | ||||||
|
|
@@ -467,15 +467,15 @@ import { | |||||
| } from "@lightprotocol/stateless.js"; | ||||||
| import { ComputeBudgetProgram } from "@solana/web3.js"; | ||||||
| import { | ||||||
| CompressedTokenProgram, | ||||||
| LightTokenProgram, | ||||||
| getTokenPoolInfos, | ||||||
| selectMinCompressedTokenAccountsForTransfer, | ||||||
| selectTokenPoolInfosForDecompression, | ||||||
| } from "@lightprotocol/compressed-token"; | ||||||
|
|
||||||
| // 1. Setup RPC connection and fetch compressed token accounts with getCompressedTokenAccountsByOwner() | ||||||
| // 2. Select accounts and token pool infos using selectMinCompressedTokenAccountsForTransfer() and selectTokenPoolInfosForDecompression() | ||||||
| // 3. Create decompress instruction with CompressedTokenProgram.decompress() and submit transaction | ||||||
| // 2. Select accounts and SPL interface infos using selectMinCompressedTokenAccountsForTransfer() and selectTokenPoolInfosForDecompression() | ||||||
| // 3. Create decompress instruction with LightTokenProgram.decompress() and submit transaction | ||||||
|
|
||||||
| // Step 1: Setup RPC connection and define decompression parameters | ||||||
| const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>";); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-existing syntax error: stray semicolon inside The Proposed fix-const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>";);
+const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
@@ -510,7 +510,7 @@ const amount = 1e5; // 100K tokens to decompress | |||||
| ); | ||||||
|
|
||||||
| // 5. Build instruction | ||||||
| const ix = await CompressedTokenProgram.decompress({ | ||||||
| const ix = await LightTokenProgram.decompress({ | ||||||
| payer: payer.publicKey, | ||||||
| inputCompressedTokenAccounts: inputAccounts, | ||||||
| toAddress: owner.publicKey, | ||||||
|
|
@@ -540,12 +540,12 @@ const amount = 1e5; // 100K tokens to decompress | |||||
|
|
||||||
| <Accordion title="Compress Regular SPL Tokens"> | ||||||
|
|
||||||
| This example converts regular SPL tokens to compressed format using `CompressedTokenProgram.compress().` | ||||||
| This example converts regular SPL tokens to compressed format using `LightTokenProgram.compress().` | ||||||
|
|
||||||
| ```typescript | ||||||
| // 1. Setup RPC connection and get user ATA with getOrCreateAssociatedTokenAccount() | ||||||
| // 2. Fetch state tree and token pool infos using getStateTreeInfos() and getTokenPoolInfos() | ||||||
| // 3. Create compress instruction with CompressedTokenProgram.compress() and submit transaction | ||||||
| // 2. Fetch state tree and SPL interface infos using getStateTreeInfos() and getTokenPoolInfos() | ||||||
| // 3. Create compress instruction with LightTokenProgram.compress() and submit transaction | ||||||
|
|
||||||
|
|
||||||
| import { | ||||||
|
|
@@ -557,7 +557,7 @@ import { | |||||
| } from "@lightprotocol/stateless.js"; | ||||||
| import { ComputeBudgetProgram } from "@solana/web3.js"; | ||||||
| import { | ||||||
| CompressedTokenProgram, | ||||||
| LightTokenProgram, | ||||||
| getTokenPoolInfos, | ||||||
| selectTokenPoolInfo, | ||||||
| } from "@lightprotocol/compressed-token"; | ||||||
|
|
@@ -584,20 +584,20 @@ const amount = 1e5; // 100K tokens to compress | |||||
| const treeInfos = await connection.getStateTreeInfos(); | ||||||
| const treeInfo = selectStateTreeInfo(treeInfos); | ||||||
|
|
||||||
| // Step 4: Fetch and select token pool info for compression | ||||||
| // Step 4: Fetch and select SPL interface info for compression | ||||||
| const tokenPoolInfos = await getTokenPoolInfos(connection, mint); | ||||||
| const tokenPoolInfo = selectTokenPoolInfo(tokenPoolInfos); | ||||||
|
|
||||||
| // Step 5: Create compress instruction - transfer SPL tokens to pool and create compressed accounts | ||||||
| const compressInstruction = await CompressedTokenProgram.compress({ | ||||||
| const compressInstruction = await LightTokenProgram.compress({ | ||||||
| payer: payer.publicKey, // fee payer | ||||||
| owner: payer.publicKey, // owner of source SPL tokens | ||||||
| source: sourceTokenAccount.address, // source ATA address | ||||||
| toAddress: payer.publicKey, // recipient of compressed tokens (self) | ||||||
| amount, // amount to compress | ||||||
| mint, // token mint address | ||||||
| outputStateTreeInfo: treeInfo, // state tree for compressed accounts | ||||||
| tokenPoolInfo, // token pool for compression | ||||||
| tokenPoolInfo, | ||||||
| }); | ||||||
|
|
||||||
| // Step 6: Build, sign, and submit compression transaction | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Punctuation inside backtick makes method reference look like a chained property access.
The trailing period is inside the backtick:
`LightTokenProgram.decompress().`which renders as a property access. Move the period outside.Same issue on line 543 with
`LightTokenProgram.compress().`.Proposed fix
Line 543:
📝 Committable suggestion
🤖 Prompt for AI Agents