JS - v0.21.0
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.
How to Migrate from v0.20.x
You can find working code snippets here.
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:
Last updated
Was this helpful?