From c9d0deeab890a7925fcba772bfdc6307c6021a61 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Fri, 30 Jan 2026 15:26:45 +0000 Subject: [PATCH 1/2] bump versions, cleanup --- package.json | 4 +-- typescript-client/actions/create-ata.ts | 15 ++++---- typescript-client/actions/create-mint.ts | 26 ++++++++------ typescript-client/actions/delegate-approve.ts | 17 ++++----- typescript-client/actions/delegate-revoke.ts | 17 ++++----- typescript-client/actions/load-ata.ts | 20 +++++------ typescript-client/actions/mint-to.ts | 29 +++++++++------ .../actions/transfer-interface.ts | 35 ++++++++++++------- typescript-client/actions/unwrap.ts | 17 ++++----- typescript-client/actions/wrap.ts | 32 ++++++++++------- typescript-client/instructions/create-ata.ts | 14 ++++---- typescript-client/instructions/create-mint.ts | 20 +++++------ typescript-client/instructions/load-ata.ts | 13 ++++--- typescript-client/instructions/mint-to.ts | 26 ++++++++------ .../instructions/transfer-interface.ts | 16 ++++----- typescript-client/instructions/unwrap.ts | 30 ++++++++++------ typescript-client/instructions/wrap.ts | 30 ++++++++++------ typescript-client/package.json | 4 +-- 18 files changed, 203 insertions(+), 162 deletions(-) diff --git a/package.json b/package.json index 7af8e8e..3d0bb01 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "toolkit:payments": "npm run -w toolkits/payments-and-wallets" }, "dependencies": { - "@lightprotocol/compressed-token": "^0.22.1-alpha.8", - "@lightprotocol/stateless.js": "^0.22.1-alpha.7", + "@lightprotocol/compressed-token": "^0.23.0-beta.4", + "@lightprotocol/stateless.js": "^0.23.0-beta.4", "@solana/spl-token": "^0.4.13", "@solana/web3.js": "1.98.4", "dotenv": "^16.5.0" diff --git a/typescript-client/actions/create-ata.ts b/typescript-client/actions/create-ata.ts index 9d7c0f9..6890459 100644 --- a/typescript-client/actions/create-ata.ts +++ b/typescript-client/actions/create-ata.ts @@ -9,21 +9,18 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - const { mint } = await createMintInterface(rpc, payer, payer, null, 9); const owner = Keypair.generate(); diff --git a/typescript-client/actions/create-mint.ts b/typescript-client/actions/create-mint.ts index c5eb146..54e2d72 100644 --- a/typescript-client/actions/create-mint.ts +++ b/typescript-client/actions/create-mint.ts @@ -1,26 +1,26 @@ import "dotenv/config"; import { Keypair } from "@solana/web3.js"; import { createRpc } from "@lightprotocol/stateless.js"; -import { createMintInterface, createTokenMetadata } from "@lightprotocol/compressed-token"; +import { + createMintInterface, + createTokenMetadata, +} from "@lightprotocol/compressed-token"; import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - const { mint, transactionSignature } = await createMintInterface( rpc, payer, @@ -30,7 +30,11 @@ const payer = Keypair.fromSecretKey( undefined, undefined, undefined, - createTokenMetadata("Example Token", "EXT", "https://example.com/metadata.json") + createTokenMetadata( + "Example Token", + "EXT", + "https://example.com/metadata.json", + ), ); console.log("Mint:", mint.toBase58()); diff --git a/typescript-client/actions/delegate-approve.ts b/typescript-client/actions/delegate-approve.ts index c786e00..b29f0f5 100644 --- a/typescript-client/actions/delegate-approve.ts +++ b/typescript-client/actions/delegate-approve.ts @@ -6,21 +6,18 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - // Setup: Get compressed tokens const { mint } = await createMint(rpc, payer, payer.publicKey, 9); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); @@ -33,7 +30,7 @@ const payer = Keypair.fromSecretKey( mint, bn(500), payer, - delegate.publicKey + delegate.publicKey, ); console.log("Tx:", tx); diff --git a/typescript-client/actions/delegate-revoke.ts b/typescript-client/actions/delegate-revoke.ts index a689e90..3a9201d 100644 --- a/typescript-client/actions/delegate-revoke.ts +++ b/typescript-client/actions/delegate-revoke.ts @@ -11,21 +11,18 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - // Setup: Get compressed tokens const { mint } = await createMint(rpc, payer, payer.publicKey, 9); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); @@ -36,7 +33,7 @@ const payer = Keypair.fromSecretKey( const delegatedAccounts = await rpc.getCompressedTokenAccountsByDelegate( delegate.publicKey, - { mint } + { mint }, ); const tx = await revoke(rpc, payer, delegatedAccounts.items, payer); diff --git a/typescript-client/actions/load-ata.ts b/typescript-client/actions/load-ata.ts index 39bf749..4abfe2f 100644 --- a/typescript-client/actions/load-ata.ts +++ b/typescript-client/actions/load-ata.ts @@ -11,27 +11,27 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - // Setup: Get compressed tokens (cold storage) const { mint } = await createMint(rpc, payer, payer.publicKey, 9); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); // Load compressed tokens to hot balance - const lightTokenAta = getAssociatedTokenAddressInterface(mint, payer.publicKey); + const lightTokenAta = getAssociatedTokenAddressInterface( + mint, + payer.publicKey, + ); const tx = await loadAta(rpc, lightTokenAta, payer, mint, payer); console.log("Tx:", tx); diff --git a/typescript-client/actions/mint-to.ts b/typescript-client/actions/mint-to.ts index ba0fd29..245a72e 100644 --- a/typescript-client/actions/mint-to.ts +++ b/typescript-client/actions/mint-to.ts @@ -11,28 +11,35 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - const { mint } = await createMintInterface(rpc, payer, payer, null, 9); const recipient = Keypair.generate(); await createAtaInterface(rpc, payer, mint, recipient.publicKey); - const destination = getAssociatedTokenAddressInterface(mint, recipient.publicKey); - const tx = await mintToInterface(rpc, payer, mint, destination, payer, 1_000_000_000); + const destination = getAssociatedTokenAddressInterface( + mint, + recipient.publicKey, + ); + const tx = await mintToInterface( + rpc, + payer, + mint, + destination, + payer, + 1_000_000_000, + ); console.log("Tx:", tx); })(); diff --git a/typescript-client/actions/transfer-interface.ts b/typescript-client/actions/transfer-interface.ts index 517fa6a..43c9456 100644 --- a/typescript-client/actions/transfer-interface.ts +++ b/typescript-client/actions/transfer-interface.ts @@ -12,33 +12,44 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - const { mint } = await createMintInterface(rpc, payer, payer, null, 9); const sender = Keypair.generate(); await createAtaInterface(rpc, payer, mint, sender.publicKey); - const senderAta = getAssociatedTokenAddressInterface(mint, sender.publicKey); + const senderAta = getAssociatedTokenAddressInterface( + mint, + sender.publicKey, + ); await mintToInterface(rpc, payer, mint, senderAta, payer, 1_000_000_000); const recipient = Keypair.generate(); await createAtaInterface(rpc, payer, mint, recipient.publicKey); - const recipientAta = getAssociatedTokenAddressInterface(mint, recipient.publicKey); + const recipientAta = getAssociatedTokenAddressInterface( + mint, + recipient.publicKey, + ); - const tx = await transferInterface(rpc, payer, senderAta, mint, recipientAta, sender, 500_000_000); + const tx = await transferInterface( + rpc, + payer, + senderAta, + mint, + recipientAta, + sender, + 500_000_000, + ); console.log("Tx:", tx); })(); diff --git a/typescript-client/actions/unwrap.ts b/typescript-client/actions/unwrap.ts index 364cdf2..65f74f7 100644 --- a/typescript-client/actions/unwrap.ts +++ b/typescript-client/actions/unwrap.ts @@ -8,21 +8,18 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - // Setup: Get compressed tokens (cold storage) const { mint } = await createMint(rpc, payer, payer.publicKey, 9); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); @@ -32,7 +29,7 @@ const payer = Keypair.fromSecretKey( rpc, payer, mint, - payer.publicKey + payer.publicKey, ); const tx = await unwrap(rpc, payer, splAta, payer, mint, bn(500)); diff --git a/typescript-client/actions/wrap.ts b/typescript-client/actions/wrap.ts index cfb9d89..027af8d 100644 --- a/typescript-client/actions/wrap.ts +++ b/typescript-client/actions/wrap.ts @@ -14,37 +14,45 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const RPC_URL = undefined; +// const rpc = createRpc(); + const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // devnet: - // const rpc = createRpc(RPC_URL); - // localnet: - const rpc = createRpc(); - // Setup: Get SPL tokens (needed to wrap) const { mint } = await createMint(rpc, payer, payer.publicKey, 9); const splAta = await createAssociatedTokenAccount( rpc, payer, mint, - payer.publicKey + payer.publicKey, ); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); await decompress(rpc, payer, mint, bn(1000), payer, splAta); // Wrap SPL tokens to rent-free token ATA - const lightTokenAta = getAssociatedTokenAddressInterface(mint, payer.publicKey); + const lightTokenAta = getAssociatedTokenAddressInterface( + mint, + payer.publicKey, + ); await createAtaInterfaceIdempotent(rpc, payer, mint, payer.publicKey); - const tx = await wrap(rpc, payer, splAta, lightTokenAta, payer, mint, bn(500)); + const tx = await wrap( + rpc, + payer, + splAta, + lightTokenAta, + payer, + mint, + bn(500), + ); console.log("Tx:", tx); })(); diff --git a/typescript-client/instructions/create-ata.ts b/typescript-client/instructions/create-ata.ts index 55966d8..13fdab5 100644 --- a/typescript-client/instructions/create-ata.ts +++ b/typescript-client/instructions/create-ata.ts @@ -14,15 +14,15 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -// const rpc = createRpc(RPC_URL); +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const rpc = createRpc(); +// const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { @@ -31,7 +31,7 @@ const payer = Keypair.fromSecretKey( const owner = Keypair.generate(); const associatedToken = getAssociatedTokenAddressInterface( mint, - owner.publicKey + owner.publicKey, ); const ix = createAssociatedTokenAccountInterfaceInstruction( @@ -39,7 +39,7 @@ const payer = Keypair.fromSecretKey( associatedToken, owner.publicKey, mint, - CTOKEN_PROGRAM_ID + CTOKEN_PROGRAM_ID, ); const tx = new Transaction().add(ix); diff --git a/typescript-client/instructions/create-mint.ts b/typescript-client/instructions/create-mint.ts index f1250af..662c6d0 100644 --- a/typescript-client/instructions/create-mint.ts +++ b/typescript-client/instructions/create-mint.ts @@ -24,20 +24,20 @@ const COMPRESSED_MINT_SEED = Buffer.from("compressed_mint"); function findMintAddress(mintSigner: PublicKey): [PublicKey, number] { return PublicKey.findProgramAddressSync( [COMPRESSED_MINT_SEED, mintSigner.toBuffer()], - CTOKEN_PROGRAM_ID + CTOKEN_PROGRAM_ID, ); } // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -// const rpc = createRpc(RPC_URL); +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const rpc = createRpc(); +// const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { @@ -48,7 +48,7 @@ const payer = Keypair.fromSecretKey( const validityProof = await rpc.getValidityProofV2( [], - [{ address: mintPda.toBytes(), treeInfo: addressTreeInfo }] + [{ address: mintPda.toBytes(), treeInfo: addressTreeInfo }], ); const ix = createMintInstruction( @@ -63,13 +63,13 @@ const payer = Keypair.fromSecretKey( createTokenMetadata( "Example Token", "EXT", - "https://example.com/metadata.json" - ) + "https://example.com/metadata.json", + ), ); const tx = new Transaction().add( ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }), - ix + ix, ); const signature = await sendAndConfirmTransaction(rpc, tx, [ payer, diff --git a/typescript-client/instructions/load-ata.ts b/typescript-client/instructions/load-ata.ts index a94d508..025ddb3 100644 --- a/typescript-client/instructions/load-ata.ts +++ b/typescript-client/instructions/load-ata.ts @@ -16,15 +16,15 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; const rpc = createRpc(RPC_URL); // localnet: // const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { @@ -32,7 +32,10 @@ const payer = Keypair.fromSecretKey( const { mint } = await createMint(rpc, payer, payer.publicKey, 9); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); - const lightTokenAta = getAssociatedTokenAddressInterface(mint, payer.publicKey); + const lightTokenAta = getAssociatedTokenAddressInterface( + mint, + payer.publicKey, + ); // load from cold to hot state const ixs = await createLoadAtaInstructions( @@ -40,7 +43,7 @@ const payer = Keypair.fromSecretKey( lightTokenAta, payer.publicKey, mint, - payer.publicKey + payer.publicKey, ); if (ixs.length === 0) return console.log("Nothing to load"); diff --git a/typescript-client/instructions/mint-to.ts b/typescript-client/instructions/mint-to.ts index 404b964..2492ad5 100644 --- a/typescript-client/instructions/mint-to.ts +++ b/typescript-client/instructions/mint-to.ts @@ -1,5 +1,10 @@ import "dotenv/config"; -import { Keypair, ComputeBudgetProgram, Transaction, sendAndConfirmTransaction } from "@solana/web3.js"; +import { + Keypair, + ComputeBudgetProgram, + Transaction, + sendAndConfirmTransaction, +} from "@solana/web3.js"; import { createRpc, bn, DerivationMode } from "@lightprotocol/stateless.js"; import { createMintInterface, @@ -12,26 +17,25 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -// const rpc = createRpc(RPC_URL); +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const rpc = createRpc(); +// const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - const { mint } = await createMintInterface(rpc, payer, payer, null, 9); const recipient = Keypair.generate(); await createAtaInterface(rpc, payer, mint, recipient.publicKey); const destination = getAssociatedTokenAddressInterface( mint, - recipient.publicKey + recipient.publicKey, ); const mintInterface = await getMintInterface(rpc, mint); @@ -48,7 +52,7 @@ const payer = Keypair.fromSecretKey( }, ], [], - DerivationMode.compressible + DerivationMode.compressible, ); } @@ -58,12 +62,12 @@ const payer = Keypair.fromSecretKey( payer.publicKey, payer.publicKey, 1_000_000_000, - validityProof + validityProof, ); const tx = new Transaction().add( ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), - ix + ix, ); const signature = await sendAndConfirmTransaction(rpc, tx, [payer]); diff --git a/typescript-client/instructions/transfer-interface.ts b/typescript-client/instructions/transfer-interface.ts index c2dc0f0..6251560 100644 --- a/typescript-client/instructions/transfer-interface.ts +++ b/typescript-client/instructions/transfer-interface.ts @@ -17,15 +17,15 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -// const rpc = createRpc(RPC_URL); +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); // localnet: -const rpc = createRpc(); +// const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { @@ -35,7 +35,7 @@ const payer = Keypair.fromSecretKey( await createAtaInterface(rpc, payer, mint, sender.publicKey); const senderAta = getAssociatedTokenAddressInterface( mint, - sender.publicKey + sender.publicKey, ); await mintToInterface(rpc, payer, mint, senderAta, payer, 1_000_000_000); @@ -43,14 +43,14 @@ const payer = Keypair.fromSecretKey( await createAtaInterface(rpc, payer, mint, recipient.publicKey); const recipientAta = getAssociatedTokenAddressInterface( mint, - recipient.publicKey + recipient.publicKey, ); const ix = createTransferInterfaceInstruction( senderAta, recipientAta, sender.publicKey, - 500_000_000 + 500_000_000, ); const tx = new Transaction().add(ix); diff --git a/typescript-client/instructions/unwrap.ts b/typescript-client/instructions/unwrap.ts index 209c4a8..19d2c97 100644 --- a/typescript-client/instructions/unwrap.ts +++ b/typescript-client/instructions/unwrap.ts @@ -1,5 +1,10 @@ import "dotenv/config"; -import { Keypair, ComputeBudgetProgram, Transaction, sendAndConfirmTransaction } from "@solana/web3.js"; +import { + Keypair, + ComputeBudgetProgram, + Transaction, + sendAndConfirmTransaction, +} from "@solana/web3.js"; import { createRpc, bn } from "@lightprotocol/stateless.js"; import { createMint, @@ -15,36 +20,38 @@ import { readFileSync } from "fs"; // devnet: // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // Setup: Get compressed tokens (cold storage) const { mint } = await createMint(rpc, payer, payer.publicKey, 9); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); // Load compressed tokens to hot balance, then create unwrap instruction - const lightTokenAta = getAssociatedTokenAddressInterface(mint, payer.publicKey); + const lightTokenAta = getAssociatedTokenAddressInterface( + mint, + payer.publicKey, + ); await loadAta(rpc, lightTokenAta, payer, mint, payer); const splAta = await createAssociatedTokenAccount( rpc, payer, mint, - payer.publicKey + payer.publicKey, ); const splInterfaceInfos = await getSplInterfaceInfos(rpc, mint); const splInterfaceInfo = splInterfaceInfos.find( - (info) => info.isInitialized + (info) => info.isInitialized, ); if (!splInterfaceInfo) throw new Error("No SPL interface found"); @@ -56,12 +63,13 @@ const payer = Keypair.fromSecretKey( mint, bn(500), splInterfaceInfo, - payer.publicKey + 9, // decimals - must match the mint decimals + payer.publicKey, ); const tx = new Transaction().add( ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), - ix + ix, ); const signature = await sendAndConfirmTransaction(rpc, tx, [payer]); diff --git a/typescript-client/instructions/wrap.ts b/typescript-client/instructions/wrap.ts index 3490574..8c86592 100644 --- a/typescript-client/instructions/wrap.ts +++ b/typescript-client/instructions/wrap.ts @@ -1,5 +1,10 @@ import "dotenv/config"; -import { Keypair, ComputeBudgetProgram, Transaction, sendAndConfirmTransaction } from "@solana/web3.js"; +import { + Keypair, + ComputeBudgetProgram, + Transaction, + sendAndConfirmTransaction, +} from "@solana/web3.js"; import { createRpc, bn } from "@lightprotocol/stateless.js"; import { createMint, @@ -16,36 +21,38 @@ import { readFileSync } from "fs"; // devnet: // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( - JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) - ) + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")), + ), ); (async function () { - // Setup: Get SPL tokens (needed to wrap) const { mint } = await createMint(rpc, payer, payer.publicKey, 9); const splAta = await createAssociatedTokenAccount( rpc, payer, mint, - payer.publicKey + payer.publicKey, ); await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000)); await decompress(rpc, payer, mint, bn(1000), payer, splAta); // Create wrap instruction - const lightTokenAta = getAssociatedTokenAddressInterface(mint, payer.publicKey); + const lightTokenAta = getAssociatedTokenAddressInterface( + mint, + payer.publicKey, + ); await createAtaInterfaceIdempotent(rpc, payer, mint, payer.publicKey); const splInterfaceInfos = await getSplInterfaceInfos(rpc, mint); const splInterfaceInfo = splInterfaceInfos.find( - (info) => info.isInitialized + (info) => info.isInitialized, ); if (!splInterfaceInfo) throw new Error("No SPL interface found"); @@ -57,12 +64,13 @@ const payer = Keypair.fromSecretKey( mint, bn(500), splInterfaceInfo, - payer.publicKey + 9, // decimals - must match the mint decimals + payer.publicKey, ); const tx = new Transaction().add( ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), - ix + ix, ); const signature = await sendAndConfirmTransaction(rpc, tx, [payer]); diff --git a/typescript-client/package.json b/typescript-client/package.json index 23d8e11..f90c485 100644 --- a/typescript-client/package.json +++ b/typescript-client/package.json @@ -4,8 +4,8 @@ "type": "module", "description": "Working examples for light-token operations on Solana devnet", "dependencies": { - "@lightprotocol/compressed-token": "alpha", - "@lightprotocol/stateless.js": "alpha", + "@lightprotocol/compressed-token": "beta", + "@lightprotocol/stateless.js": "beta", "@solana/web3.js": "^1.98.0", "dotenv": "^16.0.0" }, From 2ec8c07dbbb910770891af37b733ce5dc7ee2325 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Fri, 30 Jan 2026 15:26:56 +0000 Subject: [PATCH 2/2] bump versions, clean up --- typescript-client/actions/create-ata.ts | 6 +++--- typescript-client/actions/create-mint.ts | 6 +++--- typescript-client/actions/delegate-approve.ts | 6 +++--- typescript-client/actions/delegate-revoke.ts | 6 +++--- typescript-client/actions/load-ata.ts | 6 +++--- typescript-client/actions/mint-to.ts | 6 +++--- typescript-client/actions/transfer-interface.ts | 6 +++--- typescript-client/actions/unwrap.ts | 6 +++--- typescript-client/actions/wrap.ts | 6 +++--- typescript-client/instructions/create-ata.ts | 6 +++--- typescript-client/instructions/create-mint.ts | 6 +++--- typescript-client/instructions/load-ata.ts | 6 +++--- typescript-client/instructions/mint-to.ts | 6 +++--- typescript-client/instructions/transfer-interface.ts | 6 +++--- 14 files changed, 42 insertions(+), 42 deletions(-) diff --git a/typescript-client/actions/create-ata.ts b/typescript-client/actions/create-ata.ts index 6890459..53c46ad 100644 --- a/typescript-client/actions/create-ata.ts +++ b/typescript-client/actions/create-ata.ts @@ -9,10 +9,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/create-mint.ts b/typescript-client/actions/create-mint.ts index 54e2d72..b43c94c 100644 --- a/typescript-client/actions/create-mint.ts +++ b/typescript-client/actions/create-mint.ts @@ -9,10 +9,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/delegate-approve.ts b/typescript-client/actions/delegate-approve.ts index b29f0f5..278cf7b 100644 --- a/typescript-client/actions/delegate-approve.ts +++ b/typescript-client/actions/delegate-approve.ts @@ -6,10 +6,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/delegate-revoke.ts b/typescript-client/actions/delegate-revoke.ts index 3a9201d..ecbe802 100644 --- a/typescript-client/actions/delegate-revoke.ts +++ b/typescript-client/actions/delegate-revoke.ts @@ -11,10 +11,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/load-ata.ts b/typescript-client/actions/load-ata.ts index 4abfe2f..90ffd12 100644 --- a/typescript-client/actions/load-ata.ts +++ b/typescript-client/actions/load-ata.ts @@ -11,10 +11,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/mint-to.ts b/typescript-client/actions/mint-to.ts index 245a72e..09a6717 100644 --- a/typescript-client/actions/mint-to.ts +++ b/typescript-client/actions/mint-to.ts @@ -11,10 +11,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/transfer-interface.ts b/typescript-client/actions/transfer-interface.ts index 43c9456..51516fc 100644 --- a/typescript-client/actions/transfer-interface.ts +++ b/typescript-client/actions/transfer-interface.ts @@ -12,10 +12,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/unwrap.ts b/typescript-client/actions/unwrap.ts index 65f74f7..98056df 100644 --- a/typescript-client/actions/unwrap.ts +++ b/typescript-client/actions/unwrap.ts @@ -8,10 +8,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/actions/wrap.ts b/typescript-client/actions/wrap.ts index 027af8d..87a18c1 100644 --- a/typescript-client/actions/wrap.ts +++ b/typescript-client/actions/wrap.ts @@ -14,10 +14,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/instructions/create-ata.ts b/typescript-client/instructions/create-ata.ts index 13fdab5..ff2009c 100644 --- a/typescript-client/instructions/create-ata.ts +++ b/typescript-client/instructions/create-ata.ts @@ -14,10 +14,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/instructions/create-mint.ts b/typescript-client/instructions/create-mint.ts index 662c6d0..48dec81 100644 --- a/typescript-client/instructions/create-mint.ts +++ b/typescript-client/instructions/create-mint.ts @@ -29,10 +29,10 @@ function findMintAddress(mintSigner: PublicKey): [PublicKey, number] { } // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/instructions/load-ata.ts b/typescript-client/instructions/load-ata.ts index 025ddb3..9168f1c 100644 --- a/typescript-client/instructions/load-ata.ts +++ b/typescript-client/instructions/load-ata.ts @@ -16,10 +16,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/instructions/mint-to.ts b/typescript-client/instructions/mint-to.ts index 2492ad5..a867274 100644 --- a/typescript-client/instructions/mint-to.ts +++ b/typescript-client/instructions/mint-to.ts @@ -17,10 +17,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array( diff --git a/typescript-client/instructions/transfer-interface.ts b/typescript-client/instructions/transfer-interface.ts index 6251560..50d0a18 100644 --- a/typescript-client/instructions/transfer-interface.ts +++ b/typescript-client/instructions/transfer-interface.ts @@ -17,10 +17,10 @@ import { homedir } from "os"; import { readFileSync } from "fs"; // devnet: -const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; -const rpc = createRpc(RPC_URL); +// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +// const rpc = createRpc(RPC_URL); // localnet: -// const rpc = createRpc(); +const rpc = createRpc(); const payer = Keypair.fromSecretKey( new Uint8Array(