ZK Compression
  • Introduction
    • Overview
    • Intro to Development
  • Event
    • 🗓️Event: 1000x Hackathon
  • Release Notes
    • JS - v0.21.0
  • Learn
    • In a Nutshell
    • Core Concepts
      • Compressed Account Model
      • State Trees
      • Validity Proofs
      • Lifecycle of a Transaction
      • Limitations
  • Developers
    • TypeScript Client
    • JSON RPC Methods
      • getCompressedAccount
      • getCompressedBalance
      • getCompressedTokenAccountBalance
      • getCompressedBalanceByOwner
      • getCompressedMintTokenHolders
      • getCompressedTokenBalancesByOwnerV2
      • getCompressedAccountsByOwner
      • getMultipleCompressedAccounts
      • getCompressedTokenAccountsByOwner
      • getCompressedTokenAccountsByDelegate
      • getTransactionWithCompressionInfo
      • getCompressedAccountProof
      • getMultipleCompressedAccountProofs
      • getMultipleNewAddressProofs
      • getValidityProof
      • getCompressionSignaturesForAccount
      • getCompressionSignaturesForAddress
      • getCompressionSignaturesForOwner
      • getCompressionSignaturesForTokenOwner
      • getLatestCompressionSignatures
      • getLatestNonVotingSignatures
      • getIndexerSlot
      • getIndexerHealth
    • Addresses and URLs
    • Creating Airdrops with Compressed Tokens
    • Using Token-2022
    • Add Compressed Token Support to Your Wallet
    • Create programs with the program-template
  • Node Operators
    • Run a Node
  • resources
    • Security
    • Privacy Policy
Powered by GitBook
On this page
  • How to Migrate from v0.20.x
  • Compress
  • Decompress

Was this helpful?

  1. Release Notes

JS - v0.21.0

PreviousEvent: 1000x HackathonNextIn a Nutshell

Last updated 16 days ago

Was this helpful?

This is a JS release for @lightprotocol/stateless.js and @lightprotocol/compressed-token.

v0.21.0 has several important breaking changes that improve protocol scalability.

If you need help migrating, we're happy to assist you. Please reach out to the team .

How to Migrate from v0.20.x

You can find working code snippets .

Compress

// old
const activeStateTrees = await connection.getCachedActiveStateTreeInfo();
const { tree } = pickRandomTreeAndQueue(activeStateTrees);

const compressIx = await CompressedTokenProgram.compress({
    outputStateTree: tree,
});


// New
const treeInfos = await rpc.getStateTreeInfos();
const treeInfo = selectStateTreeInfo(treeInfos);

const infos = await getTokenPoolInfos(rpc, mint);
const tokenPoolInfo = selectTokenPoolInfo(infos);

const compressIx = await CompressedTokenProgram.compress({
    outputStateTreeInfo: treeInfo,
    tokenPoolInfo,
});

Decompress

Old (v0.20.x)

// ...

const stateTreeInfos = await rpc.getCachedActiveStateTreeInfo();
const { tree } = pickRandomTreeAndQueue(stateTreeInfos)

const ix = await CompressedTokenProgram.decompress({
    ...rest,
    outputStateTree: tree,
});

New (v0.21.x)

// ...

const poolInfos = await getTokenPoolInfos(rpc, mint);
const selectedTokenPoolInfos = selectTokenPoolInfosForDecompression(
    poolInfos,
    amount,
);

const ix = await CompressedTokenProgram.decompress({
    ...rest
    tokenPoolInfos: selectedTokenPoolInfos,
});

You can find a detailed list of all changes here:

here
here
light-protocol/js/compressed-token/CHANGELOG.md at b860d449b25d1943b4bc007717316913c9713be8 · Lightprotocol/light-protocolGitHub
Logo