@lightprotocol/compressed-token 0.22.0 → 0.22.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,8 +28,8 @@ npm install --save \
28
28
 
29
29
  ### Documentation and examples
30
30
 
31
- - [Latest Source code](https://github.com/lightprotocol/light-protocol/tree/main/js/compressed-token)
32
- - [Creating and sending compressed tokens](https://www.zkcompression.com/developers/typescript-client#creating-minting-and-transferring-a-compressed-token)
31
+ - [Latest Source code](https://github.com/lightprotocol/light-protocol/tree/main/js/compressed-token)
32
+ - [Creating and sending compressed tokens](https://www.zkcompression.com/developers/typescript-client#creating-minting-and-transferring-a-compressed-token)
33
33
 
34
34
  ### Getting help
35
35
 
@@ -38,9 +38,9 @@ Check out the [Light](https://discord.gg/CYvjBgzRFP) and [Helius](https://discor
38
38
 
39
39
  When asking for help, please include:
40
40
 
41
- - A detailed description of what you're trying to achieve
42
- - Source code, if possible
43
- - The text of any errors you encountered, with stacktraces if available
41
+ - A detailed description of what you're trying to achieve
42
+ - Source code, if possible
43
+ - The text of any errors you encountered, with stacktraces if available
44
44
 
45
45
  ### Contributing
46
46
 
@@ -0,0 +1,2 @@
1
+ import{PublicKey as e,SystemProgram as t,TransactionInstruction as n,AddressLookupTableProgram as r,ComputeBudgetProgram as o,Keypair as i}from"@solana/web3.js";import{bn as s,getIndexOrAdd as a,TreeType as u,featureFlags as c,padOutputStateMerkleTrees as p,defaultStaticAccountsStruct as m,toArray as d,LightSystemProgram as l,defaultTestStateTreeAccounts as h,sumUpLamports as g,validateSufficientBalance as f,validateSameOwner as y,dedupeSigner as P,buildAndSignTx as k,sendAndConfirmTx as b,selectStateTreeInfo as A}from"@lightprotocol/stateless.js";import{unpackAccount as w,MINT_SIZE as S,createInitializeMint2Instruction as I,createMintToInstruction as C,TOKEN_PROGRAM_ID as T,TOKEN_2022_PROGRAM_ID as v,getOrCreateAssociatedTokenAccount as M}from"@solana/spl-token";import{struct as x,array as E,u8 as D,publicKey as U,u64 as R,option as W,vecU8 as B,u32 as O,bool as _,u16 as L,vec as K}from"@coral-xyz/borsh";var F="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},q=[],Y=[],N="undefined"!=typeof Uint8Array?Uint8Array:Array,V=0;function z(){V=1;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)q[t]=e[t],Y[e.charCodeAt(t)]=t;Y["-".charCodeAt(0)]=62,Y["_".charCodeAt(0)]=63}function $(e,t,n){for(var r,o,i=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(q[(o=r)>>18&63]+q[o>>12&63]+q[o>>6&63]+q[63&o]);return i.join("")}function H(e){var t;V||z();for(var n=e.length,r=n%3,o="",i=[],s=16383,a=0,u=n-r;a<u;a+=s)i.push($(e,a,a+s>u?u:a+s));return 1===r?(t=e[n-1],o+=q[t>>2],o+=q[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=q[t>>10],o+=q[t>>4&63],o+=q[t<<2&63],o+="="),i.push(o),i.join("")}function j(e,t,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,p=-7,m=n?o-1:0,d=n?-1:1,l=e[t+m];for(m+=d,i=l&(1<<-p)-1,l>>=-p,p+=a;p>0;i=256*i+e[t+m],m+=d,p-=8);for(s=i&(1<<-p)-1,i>>=-p,p+=r;p>0;s=256*s+e[t+m],m+=d,p-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:Infinity*(l?-1:1);s+=Math.pow(2,r),i-=c}return(l?-1:1)*s*Math.pow(2,i-r)}function Z(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,p=(1<<c)-1,m=p>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,h=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(a=isNaN(t)?1:0,s=p):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+m>=1?d/u:d*Math.pow(2,1-m))*u>=2&&(s++,u/=2),s+m>=p?(a=0,s=p):s+m>=1?(a=(t*u-1)*Math.pow(2,o),s+=m):(a=t*Math.pow(2,m-1)*Math.pow(2,o),s=0));o>=8;e[n+l]=255&a,l+=h,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+l]=255&s,l+=h,s/=256,c-=8);e[n+l-h]|=128*g}var Q={}.toString,J=Array.isArray||function(e){return"[object Array]"==Q.call(e)};function X(){return ee.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function G(e,t){if(X()<t)throw new RangeError("Invalid typed array length");return ee.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=ee.prototype:(null===e&&(e=new ee(t)),e.length=t),e}function ee(e,t,n){if(!(ee.TYPED_ARRAY_SUPPORT||this instanceof ee))return new ee(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return re(this,e)}return te(this,e,t,n)}function te(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),ee.TYPED_ARRAY_SUPPORT?(e=t).__proto__=ee.prototype:e=oe(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!ee.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|ae(t,n),o=(e=G(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(se(t)){var n=0|ie(t.length);return 0===(e=G(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?G(e,0):oe(e,t);if("Buffer"===t.type&&J(t.data))return oe(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function ne(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function re(e,t){if(ne(t),e=G(e,t<0?0:0|ie(t)),!ee.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function oe(e,t){var n=t.length<0?0:0|ie(t.length);e=G(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function ie(e){if(e>=X())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+X().toString(16)+" bytes");return 0|e}function se(e){return!(null==e||!e._isBuffer)}function ae(e,t){if(se(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=0;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Re(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return We(e).length;default:if(r)return Re(e).length;t=(""+t).toLowerCase(),r=1}}function ue(e,t,n){var r=0;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Se(this,t,n);case"utf8":case"utf-8":return ke(this,t,n);case"ascii":return Ae(this,t,n);case"latin1":case"binary":return we(this,t,n);case"base64":return Pe(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ie(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=1}}function ce(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function pe(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=ee.from(t,r)),se(t))return 0===t.length?-1:me(e,t,n,r,o);if("number"==typeof t)return t&=255,ee.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):me(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function me(e,t,n,r,o){var i,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var p=-1;for(i=n;i<a;i++)if(c(e,i)===c(t,-1===p?0:i-p)){if(-1===p&&(p=i),i-p+1===u)return p*s}else-1!==p&&(i-=i-p),p=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var m=1,d=0;d<u;d++)if(c(e,i+d)!==c(t,d)){m=0;break}if(m)return i}return-1}function de(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function le(e,t,n,r){return Be(Re(t,e.length-n),e,n,r)}function he(e,t,n,r){return Be(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function ge(e,t,n,r){return he(e,t,n,r)}function fe(e,t,n,r){return Be(We(t),e,n,r)}function ye(e,t,n,r){return Be(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function Pe(e,t,n){return 0===t&&n===e.length?H(e):H(e.slice(t,n))}function ke(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,u,c=e[o],p=null,m=c>239?4:c>223?3:c>191?2:1;if(o+m<=n)switch(m){case 1:c<128&&(p=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(p=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(p=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(p=u)}null===p?(p=65533,m=1):p>65535&&(p-=65536,r.push(p>>>10&1023|55296),p=56320|1023&p),r.push(p),o+=m}return function(e){var t=e.length;if(t<=be)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=be));return n}(r)}ee.TYPED_ARRAY_SUPPORT=void 0!==F.TYPED_ARRAY_SUPPORT?F.TYPED_ARRAY_SUPPORT:1,X(),ee.poolSize=8192,ee._augment=function(e){return e.__proto__=ee.prototype,e},ee.from=function(e,t,n){return te(null,e,t,n)},ee.TYPED_ARRAY_SUPPORT&&(ee.prototype.__proto__=Uint8Array.prototype,ee.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&ee[Symbol.species]),ee.alloc=function(e,t,n){return function(e,t,n,r){return ne(t),t<=0?G(e,t):void 0!==n?"string"==typeof r?G(e,t).fill(n,r):G(e,t).fill(n):G(e,t)}(null,e,t,n)},ee.allocUnsafe=function(e){return re(null,e)},ee.allocUnsafeSlow=function(e){return re(null,e)},ee.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Oe(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Oe(e.slice(0,0))}(e))},ee.compare=function(e,t){if(!se(e)||!se(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},ee.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 1;default:return 0}},ee.concat=function(e,t){if(!J(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return ee.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=ee.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!se(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},ee.byteLength=ae,ee.prototype._isBuffer=1,ee.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)ce(this,t,t+1);return this},ee.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)ce(this,t,t+3),ce(this,t+1,t+2);return this},ee.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)ce(this,t,t+7),ce(this,t+1,t+6),ce(this,t+2,t+5),ce(this,t+3,t+4);return this},ee.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?ke(this,0,e):ue.apply(this,arguments)},ee.prototype.equals=function(e){if(!se(e))throw new TypeError("Argument must be a Buffer");return this===e?1:0===ee.compare(this,e)},ee.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},ee.prototype.compare=function(e,t,n,r,o){if(!se(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(r,o),c=e.slice(t,n),p=0;p<a;++p)if(u[p]!==c[p]){i=u[p],s=c[p];break}return i<s?-1:s<i?1:0},ee.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},ee.prototype.indexOf=function(e,t,n){return pe(this,e,t,n,1)},ee.prototype.lastIndexOf=function(e,t,n){return pe(this,e,t,n,0)},ee.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=0;;)switch(r){case"hex":return de(this,e,t,n);case"utf8":case"utf-8":return le(this,e,t,n);case"ascii":return he(this,e,t,n);case"latin1":case"binary":return ge(this,e,t,n);case"base64":return fe(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ye(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=1}},ee.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var be=4096;function Ae(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function we(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function Se(e,t,n){var r,o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);for(var i="",s=t;s<n;++s)i+=(r=e[s])<16?"0"+r.toString(16):r.toString(16);return i}function Ie(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function Ce(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Te(e,t,n,r,o,i){if(!se(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function ve(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function Me(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function xe(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ee(e,t,n,r,o){return o||xe(e,0,n,4),Z(e,t,n,r,23,4),n+4}function De(e,t,n,r,o){return o||xe(e,0,n,8),Z(e,t,n,r,52,8),n+8}ee.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),ee.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=ee.prototype;else{var o=t-e;n=new ee(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},ee.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Ce(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},ee.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Ce(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},ee.prototype.readUInt8=function(e,t){return t||Ce(e,1,this.length),this[e]},ee.prototype.readUInt16LE=function(e,t){return t||Ce(e,2,this.length),this[e]|this[e+1]<<8},ee.prototype.readUInt16BE=function(e,t){return t||Ce(e,2,this.length),this[e]<<8|this[e+1]},ee.prototype.readUInt32LE=function(e,t){return t||Ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ee.prototype.readUInt32BE=function(e,t){return t||Ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ee.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Ce(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},ee.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Ce(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},ee.prototype.readInt8=function(e,t){return t||Ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ee.prototype.readInt16LE=function(e,t){t||Ce(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},ee.prototype.readInt16BE=function(e,t){t||Ce(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},ee.prototype.readInt32LE=function(e,t){return t||Ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ee.prototype.readInt32BE=function(e,t){return t||Ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ee.prototype.readFloatLE=function(e,t){return t||Ce(e,4,this.length),j(this,e,1,23,4)},ee.prototype.readFloatBE=function(e,t){return t||Ce(e,4,this.length),j(this,e,0,23,4)},ee.prototype.readDoubleLE=function(e,t){return t||Ce(e,8,this.length),j(this,e,1,52,8)},ee.prototype.readDoubleBE=function(e,t){return t||Ce(e,8,this.length),j(this,e,0,52,8)},ee.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Te(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},ee.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Te(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},ee.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,1,255,0),ee.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ee.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,2,65535,0),ee.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,1),t+2},ee.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,2,65535,0),ee.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,0),t+2},ee.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,4,4294967295,0),ee.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Me(this,e,t,1),t+4},ee.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,4,4294967295,0),ee.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Me(this,e,t,0),t+4},ee.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Te(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},ee.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Te(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},ee.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,1,127,-128),ee.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ee.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,2,32767,-32768),ee.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,1),t+2},ee.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,2,32767,-32768),ee.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,0),t+2},ee.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,4,2147483647,-2147483648),ee.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Me(this,e,t,1),t+4},ee.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Te(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ee.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Me(this,e,t,0),t+4},ee.prototype.writeFloatLE=function(e,t,n){return Ee(this,e,t,1,n)},ee.prototype.writeFloatBE=function(e,t,n){return Ee(this,e,t,0,n)},ee.prototype.writeDoubleLE=function(e,t,n){return De(this,e,t,1,n)},ee.prototype.writeDoubleBE=function(e,t,n){return De(this,e,t,0,n)},ee.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!ee.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},ee.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!ee.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=se(e)?e:Re(new ee(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var Ue=/[^+\/0-9A-Za-z-_]/g;function Re(e,t){var n;t=t||Infinity;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function We(e){return function(e){var t,n,r,o,i,s;V||z();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[a-2]?2:"="===e[a-1]?1:0,s=new N(3*a/4-i),r=i>0?a-4:a;var u=0;for(t=0,n=0;t<r;t+=4,n+=3)o=Y[e.charCodeAt(t)]<<18|Y[e.charCodeAt(t+1)]<<12|Y[e.charCodeAt(t+2)]<<6|Y[e.charCodeAt(t+3)],s[u++]=o>>16&255,s[u++]=o>>8&255,s[u++]=255&o;return 2===i?(o=Y[e.charCodeAt(t)]<<2|Y[e.charCodeAt(t+1)]>>4,s[u++]=255&o):1===i&&(o=Y[e.charCodeAt(t)]<<10|Y[e.charCodeAt(t+1)]<<4|Y[e.charCodeAt(t+2)]>>2,s[u++]=o>>8&255,s[u++]=255&o),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ue,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Be(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function Oe(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}const _e=ee.from("pool"),Le=ee.from("cpi_authority"),Ke=1461600,Fe=ee.from([23,169,27,122,147,169,209,152]),qe=ee.from([241,34,48,186,37,179,123,192]),Ye=ee.from([65,206,101,37,147,42,221,144]),Ne=ee.from([163,52,200,231,140,3,69,186]),Ve=ee.from([112,230,105,101,145,202,157,97]),ze=ee.from([69,74,217,36,115,117,97,76]),$e=ee.from([170,23,31,34,133,173,93,242]),He=ee.from([114,143,210,73,96,115,1,228]);function je(e,t){if(!e.mint.equals(t))throw new Error("TokenPool mint does not match the provided mint.");if(!e.isInitialized)throw new Error(`TokenPool is not initialized. Please create a compressed token pool for mint: ${t.toBase58()} via createTokenPool().`);return 1}async function Ze(e,t,n){const r=Array.from({length:5},((e,n)=>jt.deriveTokenPoolPdaWithIndex(t,n))),o=await e.getMultipleAccountsInfo(r.map((e=>e[0])),n);if(null===o[0])throw new Error(`TokenPool not found. Please create a compressed token pool for mint: ${t.toBase58()} via createTokenPool().`);const i=r.map(((e,t)=>o[t]?w(e[0],o[t],o[t].owner):null)),a=o[0].owner;return i.map(((e,n)=>e?{mint:t,tokenPoolPda:e.address,tokenProgram:a,activity:void 0,balance:s(e.amount.toString()),isInitialized:1,poolIndex:n,bump:r[n][1]}:{mint:t,tokenPoolPda:r[n][0],tokenProgram:a,activity:void 0,balance:s(0),isInitialized:0,poolIndex:n,bump:r[n][1]}))}var Qe;!function(e){e[e.Compress=1]="Compress",e[e.Decompress=2]="Decompress",e[e.Transfer=3]="Transfer"}(Qe||(Qe={}));const Je=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e};function Xe(e){const t=Je(e).filter((e=>e.isInitialized));if(0===t.length)throw new Error("Please pass at least one initialized token pool info.");return t[0]}function Ge(e,t){if(0===e.length)throw new Error("Please pass at least one token pool info.");const n=(e=Je(e)).find((e=>e.balance.gte(s(t).mul(s(10)))));if((e=e.filter((e=>e.isInitialized)).sort(((e,t)=>e.poolIndex-t.poolIndex))).every((e=>e.balance.isZero())))throw new Error("All provided token pool balances are zero. Please pass recent token pool infos.");return n?[n]:e}const et="Could not find accounts to select for transfer.";function tt(e,t,n=4){const r=e.find((e=>e.parsed.amount.eq(t)));return r?[[r],r.parsed.amount,r.compressedAccount.lamports,r.parsed.amount]:rt(e,t,n)}function nt(e,t,n=4){const[r,o,i,s]=rt(e,t,n);return{selectedAccounts:r,total:o,totalLamports:i,maxPossibleAmount:s}}function rt(e,t,n=4){const[r,o,i,a]=ot(e,t,n);if(o.lt(s(t))){const o=e.reduce(((e,t)=>e.add(t.parsed.amount)),s(0));throw r.length>=n?new Error(`Account limit exceeded: max ${a.toString()} (${n} accounts) per transaction. Total balance: ${o.toString()} (${e.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance for transfer. Required: ${t.toString()}, available: ${o.toString()}.`)}if(0===r.length)throw new Error(et);return[r,o,i,a]}function ot(e,t,n=4){if(0===e.length)throw new Error(et);let r=s(0),o=s(0),i=s(0);const a=[];e.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const i of e){if(a.length>=n)break;if(r.gte(s(t)))break;i.parsed.amount.isZero()&&i.compressedAccount.lamports.isZero()||(r=r.add(i.parsed.amount),o=o.add(i.compressedAccount.lamports),a.push(i))}if(i=e.slice(0,n).reduce(((e,t)=>e.add(t.parsed.amount)),s(0)),r.lt(s(t))&&console.log(`Insufficient balance for transfer. Requested: ${t.toString()}, Returns max available: ${i.toString()}.`),0===a.length)throw new Error(et);return[a,r,o,i]}function it(e,t,n=4){const[r,o,i,a]=st(e,t,n);if(o.lt(s(t))){const o=e.reduce(((e,t)=>e.add(t.parsed.amount)),s(0));throw r.length>=n?new Error(`Account limit exceeded: max ${a.toString()} (${n} accounts) per transaction. Total balance: ${o.toString()} (${e.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance. Required: ${t.toString()}, available: ${o.toString()}.`)}if(0===r.length)throw new Error(et);return[r,o,i,a]}function st(e,t,n=4){if(0===e.length)throw new Error(et);let r=s(0),o=s(0);const i=[],a=e.filter((e=>!e.parsed.amount.isZero()||!e.compressedAccount.lamports.isZero()));a.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const e of a){if(i.length>=n)break;if(r=r.add(e.parsed.amount),o=o.add(e.compressedAccount.lamports),i.push(e),r.gte(s(t))){const e=a.slice(i.length);if(e.length>0){const t=e.reduce(((e,t)=>t.parsed.amount.lt(e.parsed.amount)?t:e));i.length<n&&(i.push(t),r=r.add(t.parsed.amount),o=o.add(t.compressedAccount.lamports))}break}}const u=a.slice(0,n).reduce(((e,t)=>e.add(t.parsed.amount)),s(0));if(0===i.length)throw new Error(et);return[i,r,o,u]}function at(e){const{inputCompressedTokenAccounts:t,outputStateTreeInfo:n,remainingAccounts:r=[],rootIndices:o,tokenTransferOutputs:i}=e,m=r.slice();let d=null;t.length>0&&t[0].parsed.delegate&&(d=a(m,t[0].parsed.delegate));const l=[];if(t.forEach(((e,t)=>{const n=a(m,e.compressedAccount.treeInfo.tree),r=a(m,e.compressedAccount.treeInfo.queue);l.push({amount:e.parsed.amount,delegateIndex:d,merkleContext:{merkleTreePubkeyIndex:n,queuePubkeyIndex:r,leafIndex:e.compressedAccount.leafIndex,proveByIndex:e.compressedAccount.proveByIndex},rootIndex:o[t],lamports:e.compressedAccount.lamports.eq(s(0))?null:e.compressedAccount.lamports,tlv:null})})),t.length>0&&n)throw new Error("Cannot specify both input accounts and outputStateTreeInfo");let h;if(t.length>0)h=t[0].compressedAccount.treeInfo;else{if(!n)throw new Error("Neither input accounts nor outputStateTreeInfo are available");h=n}const g=h.nextTreeInfo||h;let f=g.tree;if(g.treeType===u.StateV2){if(!c.isV2())throw new Error("V2 trees are not supported yet");f=g.queue}const y=p(f,i.length),P=[];y.forEach(((e,t)=>{const n=a(m,e);P.push({owner:i[t].owner,amount:i[t].amount,lamports:i[t].lamports?.eq(s(0))?null:i[t].lamports,merkleTreeIndex:n,tlv:null})}));const k=m.map((e=>({pubkey:e,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:l,remainingAccountMetas:k,packedOutputTokenData:P}}function ut(e,t){if(!e.every((e=>e.parsed.mint.equals(t))))throw new Error("All input accounts must belong to the same mint");return 1}const ct=x([E(D(),32,"a"),E(D(),64,"b"),E(D(),32,"c")]),pt=x([U("owner"),R("amount"),W(R(),"lamports"),D("merkleTreeIndex"),W(B(),"tlv")]),mt=x([R("amount"),W(D(),"delegateIndex"),x([D("merkleTreePubkeyIndex"),D("queuePubkeyIndex"),O("leafIndex"),_("proveByIndex")],"merkleContext"),L("rootIndex"),W(R(),"lamports"),W(B(),"tlv")]),dt=x([U("owner"),W(D(),"delegateChangeAccountIndex")]),lt=x([_("setContext"),_("firstSetContext"),D("cpiContextAccountIndex")]),ht=x([W(ct,"proof"),U("mint"),W(dt,"delegatedTransfer"),K(mt,"inputTokenDataWithContext"),K(pt,"outputCompressedAccounts"),_("isCompress"),W(R(),"compressOrDecompressAmount"),W(lt,"cpiContext"),W(D(),"lamportsChangeAccountMerkleTreeIndex")]),gt=x([K(U(),"recipients"),K(R(),"amounts"),W(R(),"lamports")]),ft=x([K(U(),"pubkeys"),W(K(R(),"amounts"),"amounts"),W(R(),"lamports"),W(R(),"amount"),D("index"),D("bump")]),yt=x([U("owner"),W(R(),"remainingAmount"),W(lt,"cpiContext")]);function Pt(e){const t=ee.alloc(1e3),n=gt.encode({recipients:e.recipients,amounts:e.amounts,lamports:e.lamports},t);return ee.concat([new Uint8Array(qe),new Uint8Array(t.subarray(0,n))])}function kt(e){return gt.decode(e.subarray(qe.length))}function bt(e){const t=ee.alloc(1e3),n=ft.encode(e,t),r=ee.alloc(4);r.writeUInt32LE(n,0);const o=t.subarray(0,n);return ee.concat([new Uint8Array(Ye),new Uint8Array(r),new Uint8Array(o)])}function At(e){return ft.decode(e.subarray(Ye.length+4))}function wt(e){const t=ee.alloc(1e3),n=yt.encode({owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext},t);return ee.concat([new Uint8Array(Ve),new Uint8Array(t.subarray(0,n))])}function St(e){const t=yt.decode(e.subarray(Ve.length));return{owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext}}function It(e){const t=ee.alloc(1e3),n=ht.encode(e,t),r=ee.alloc(4);r.writeUInt32LE(n,0);const o=t.subarray(0,n);return ee.concat([new Uint8Array(Ne),new Uint8Array(r),new Uint8Array(o)])}function Ct(e){return ht.decode(e.slice(Ne.length+4))}const Tt=e=>{const{feePayer:t,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},vt=e=>{const{feePayer:t,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s,existingTokenPoolPda:a}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},Mt=e=>{const t=jt.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,mint:i,tokenPoolPda:s,tokenProgram:a,lightSystemProgram:u,registeredProgramPda:c,noopProgram:p,accountCompressionAuthority:m,accountCompressionProgram:d,merkleTree:l,selfProgram:h,systemProgram:g,solPoolPda:f}=e;return[{pubkey:n,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1},{pubkey:s,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:1},{pubkey:h,isSigner:0,isWritable:0},{pubkey:g,isSigner:0,isWritable:0},{pubkey:f??t,isSigner:0,isWritable:1}]},xt=e=>{const t=jt.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,lightSystemProgram:i,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:u,accountCompressionProgram:c,selfProgram:p,tokenPoolPda:m,compressOrDecompressTokenAccount:d,tokenProgram:l,systemProgram:h}=e;return[{pubkey:n,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0},{pubkey:m??t,isSigner:0,isWritable:1},{pubkey:d??t,isSigner:0,isWritable:1},{pubkey:l??t,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0}]},Et=e=>{const{feePayer:t,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:p}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0}]},Dt=Et,Ut=e=>{const{feePayer:t,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:p,mint:m}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0}]},Rt=Ut,Wt=x([x([E(D(),32,"a"),E(D(),64,"b"),E(D(),32,"c")],"proof"),U("mint"),K(mt,"inputTokenDataWithContext"),W(lt,"cpiContext"),U("delegate"),R("delegatedAmount"),D("delegateMerkleTreeIndex"),D("changeAccountMerkleTreeIndex"),W(R(),"delegateLamports")]),Bt=x([x([E(D(),32,"a"),E(D(),64,"b"),E(D(),32,"c")],"proof"),U("mint"),K(mt,"inputTokenDataWithContext"),W(lt,"cpiContext"),D("outputAccountMerkleTreeIndex")]),Ot={a:new Array(32).fill(0),b:new Array(64).fill(0),c:new Array(32).fill(0)};function _t(e){return e.a.every((e=>0===e))&&e.b.every((e=>0===e))&&e.c.every((e=>0===e))}function Lt(e){const t=ee.alloc(1e3),n=e.proof??Ot,r=Wt.encode({...e,proof:n},t),o=ee.alloc(4);o.writeUInt32LE(r,0);const i=t.subarray(0,r);return ee.concat([new Uint8Array(ze),new Uint8Array(o),new Uint8Array(i)])}function Kt(e){const t=Wt.decode(e.subarray(ze.length));return{...t,proof:_t(t.proof)?null:t.proof}}function Ft(e){const t=ee.alloc(1e3),n=e.proof??Ot,r=Bt.encode({...e,proof:n},t),o=ee.alloc(4);o.writeUInt32LE(r,0);const i=t.subarray(0,r);return ee.concat([new Uint8Array($e),new Uint8Array(o),new Uint8Array(i)])}function qt(e){const t=Bt.decode(e.subarray($e.length));return{...t,proof:_t(t.proof)?null:t.proof}}const Yt=e=>e.reduce(((e,t)=>e.add(t.parsed.amount)),s(0)),Nt=e=>{const t=e[0].parsed.owner;e.forEach((e=>{if(!e.parsed.owner.equals(t))throw new Error("Token accounts must be owned by the same owner")}))},Vt=e=>({mint:e[0].parsed.mint,currentOwner:e[0].parsed.owner,delegate:e[0].parsed.delegate}),zt=(e,t)=>{if(e.length<1)throw new Error("Must supply at least one input token account.");const n=e[0].parsed.owner,r=e.findIndex((e=>e.parsed.delegate));if(-1===r)return{delegatedTransfer:null,authority:n};const o=e[r].parsed.delegate;return{delegatedTransfer:{owner:n,delegateChangeAccountIndex:t.length<=1?null:0},authority:o}};function $t(e,t,n){n=s(n);const r=Yt(e),o=g(e.map((e=>e.compressedAccount))),i=r.sub(n);return f(i),i.eq(s(0))&&o.eq(s(0))?[{owner:t,amount:n,lamports:o,tlv:null}]:(y(e.map((e=>e.compressedAccount))),Nt(e),[{owner:e[0].parsed.owner,amount:i,lamports:o,tlv:null},{owner:t,amount:n,lamports:s(0),tlv:null}])}function Ht(e,t){t=s(t);const n=g(e.map((e=>e.compressedAccount))),r=Yt(e).sub(t);return f(r),r.eq(s(0))&&n.eq(s(0))?[]:(y(e.map((e=>e.compressedAccount))),Nt(e),[{owner:e[0].parsed.owner,amount:r,lamports:n,tlv:null}])}class jt{constructor(){}static programId=new e("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");static setProgramId(t){this.programId="string"==typeof t?new e(t):t}static deriveTokenPoolPda(t){const n=[_e,t.toBuffer()],[r,o]=e.findProgramAddressSync(n,this.programId);return r}static findTokenPoolIndexAndBump(e,t){for(let n=0;n<5;n++){const r=jt.deriveTokenPoolPdaWithIndex(t,n);if(r[0].equals(e))return[n,r[1]]}throw new Error("Token pool not found")}static deriveTokenPoolPdaWithIndex(t,n){let r=[];r=0===n?[ee.from("pool"),t.toBuffer(),ee.from([])]:[ee.from("pool"),t.toBuffer(),ee.from([n])];const[o,i]=e.findProgramAddressSync(r,this.programId);return[o,i]}static get deriveCpiAuthorityPda(){const[t,n]=e.findProgramAddressSync([Le],this.programId);return t}static async createMint({feePayer:e,mint:n,authority:r,freezeAuthority:o,decimals:i,rentExemptBalance:s,tokenProgramId:a,mintSize:u}){const c=a??T;return[t.createAccount({fromPubkey:e,lamports:s,newAccountPubkey:n,programId:c,space:u??S}),I(n,i,r,o,c),await this.createTokenPool({feePayer:e,mint:n,tokenProgramId:c})]}static async createTokenPool({feePayer:e,mint:r,tokenProgramId:o}){const i=o??T,s=this.deriveTokenPoolPdaWithIndex(r,0),a=Tt({mint:r,feePayer:e,tokenPoolPda:s[0],tokenProgram:i,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:t.programId});return new n({programId:this.programId,keys:a,data:Fe})}static async addTokenPool({feePayer:e,mint:r,poolIndex:o,tokenProgramId:i}){if(o<=0)throw new Error("Pool index must be greater than 0. For 0, use CreateTokenPool instead.");if(o>3)throw new Error(`Invalid poolIndex ${o}. Max 4 pools per mint.`);const s=i??T,a=this.deriveTokenPoolPdaWithIndex(r,o-1),u=this.deriveTokenPoolPdaWithIndex(r,o),c=vt({mint:r,feePayer:e,tokenPoolPda:u[0],existingTokenPoolPda:a[0],tokenProgram:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:t.programId});return new n({programId:this.programId,keys:c,data:ee.concat([new Uint8Array(He),new Uint8Array(ee.from([o]))])})}static async mintTo({feePayer:e,mint:r,authority:o,toPubkey:i,amount:a,outputStateTreeInfo:c,tokenPoolInfo:p}){const h=m(),g=p.tokenProgram;je(p,r);const f=d(a).map((e=>s(e))),y=d(i);if(f.length!==y.length)throw new Error("Amount and toPubkey arrays must have the same length");const P=Mt({mint:r,feePayer:e,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:g,tokenPoolPda:p.tokenPoolPda,lightSystemProgram:l.programId,registeredProgramPda:h.registeredProgramPda,noopProgram:h.noopProgram,accountCompressionAuthority:h.accountCompressionAuthority,accountCompressionProgram:h.accountCompressionProgram,merkleTree:c.treeType===u.StateV2?c.queue:c.tree,selfProgram:this.programId,systemProgram:t.programId,solPoolPda:null}),k=Pt({recipients:y,amounts:f,lamports:null});return new n({programId:this.programId,keys:P,data:k})}static async approveAndMintTo({feePayer:e,mint:t,authority:n,authorityTokenAccount:r,toPubkey:o,amount:i,outputStateTreeInfo:s,tokenPoolInfo:a}){const u=BigInt(i.toString());return[C(t,r,n,u,[],a.tokenProgram),await this.compress({payer:e,owner:n,source:r,toAddress:o,mint:t,amount:i,outputStateTreeInfo:s,tokenPoolInfo:a})]}static async transfer({payer:e,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a}){const u=$t(r,o,i),{inputTokenDataWithContext:c,packedOutputTokenData:p,remainingAccountMetas:d}=at({inputCompressedTokenAccounts:r,rootIndices:a,tokenTransferOutputs:u}),{mint:h}=Vt(r),{delegatedTransfer:g,authority:f}=zt(r,u),y=It({proof:s,mint:h,delegatedTransfer:g,inputTokenDataWithContext:c,outputCompressedAccounts:p,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:P,noopProgram:k,registeredProgramPda:b,accountCompressionProgram:A}=m(),w=xt({feePayer:e,authority:f,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:b,noopProgram:k,accountCompressionAuthority:P,accountCompressionProgram:A,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:t.programId});return w.push(...d),new n({programId:this.programId,keys:w,data:y})}static async createTokenProgramLookupTable({payer:e,authority:n,mints:i,recentSlot:s,remainingAccounts:a}){const[u,c]=r.createLookupTable({authority:n,payer:n,recentSlot:s});let p=[];i&&(p=[...i,...i.map((e=>this.deriveTokenPoolPda(e)))]);const d=[u,r.extendLookupTable({payer:e,authority:n,lookupTable:c,addresses:[t.programId,o.programId,this.deriveCpiAuthorityPda,l.programId,jt.programId,m().registeredProgramPda,m().noopProgram,m().accountCompressionAuthority,m().accountCompressionProgram,h().merkleTree,h().nullifierQueue,h().addressTree,h().addressQueue,this.programId,T,v,n,...p]})];if(a&&a.length>0)for(let t=0;t<a.length;t+=25){const o=a.slice(t,t+25),i=r.extendLookupTable({payer:e,authority:n,lookupTable:c,addresses:o});d.push(i)}return{instructions:d,address:c}}static async compress({payer:e,owner:r,source:o,toAddress:i,amount:a,mint:u,outputStateTreeInfo:p,tokenPoolInfo:h}){let g;const f=d(a),y=d(i);if(je(h,u),f.length!==y.length)throw new Error("Amount and toAddress arrays must have the same length");if(c.isV2()){const[i,a]=this.findTokenPoolIndexAndBump(h.tokenPoolPda,u),c=bt({pubkeys:y,amounts:f.length>1?f.map((e=>s(e))):null,lamports:null,amount:1===f.length?s(f[0]):null,index:i,bump:a}),d=Mt({mint:u,feePayer:e,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:h.tokenProgram,tokenPoolPda:h.tokenPoolPda,lightSystemProgram:l.programId,...m(),merkleTree:p.queue,selfProgram:this.programId,systemProgram:t.programId,solPoolPda:null});return d.push({pubkey:o,isWritable:1,isSigner:0}),new n({programId:this.programId,keys:d,data:c})}{g=f.map(((e,t)=>{const n=s(e);return{owner:y[t],amount:n,lamports:null,tlv:null}}));const{inputTokenDataWithContext:i,packedOutputTokenData:c,remainingAccountMetas:d}=at({inputCompressedTokenAccounts:[],outputStateTreeInfo:p,rootIndices:[],tokenTransferOutputs:g}),P=It({proof:null,mint:u,delegatedTransfer:null,inputTokenDataWithContext:i,outputCompressedAccounts:c,compressOrDecompressAmount:Array.isArray(a)?a.map((e=>s(e))).reduce(((e,t)=>e.add(t)),s(0)):s(a),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),k=xt({...m(),feePayer:e,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,selfProgram:this.programId,systemProgram:t.programId,tokenPoolPda:h.tokenPoolPda,compressOrDecompressTokenAccount:o,tokenProgram:h.tokenProgram});return k.push(...d),new n({programId:this.programId,keys:k,data:P})}}static async decompress({payer:e,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:a,recentInputStateRootIndices:u,tokenPoolInfos:c}){const p=s(i),h=d(c),g=Ht(r,p),{inputTokenDataWithContext:f,packedOutputTokenData:y,remainingAccountMetas:P}=at({inputCompressedTokenAccounts:r,rootIndices:u,tokenTransferOutputs:g,remainingAccounts:h.slice(1).map((e=>e.tokenPoolPda))}),{mint:k}=Vt(r),{delegatedTransfer:b,authority:A}=zt(r,g),w=It({proof:a,mint:k,delegatedTransfer:b,inputTokenDataWithContext:f,outputCompressedAccounts:y,compressOrDecompressAmount:p,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),S=h[0].tokenProgram,{accountCompressionAuthority:I,noopProgram:C,registeredProgramPda:T,accountCompressionProgram:v}=m(),M=xt({feePayer:e,authority:A,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:T,noopProgram:C,accountCompressionAuthority:I,accountCompressionProgram:v,selfProgram:this.programId,tokenPoolPda:h[0].tokenPoolPda,compressOrDecompressTokenAccount:o,tokenProgram:S,systemProgram:t.programId});return M.push(...P),new n({programId:this.programId,keys:M,data:w})}static async mergeTokenAccounts({payer:e,owner:t,inputCompressedTokenAccounts:n,mint:r,recentValidityProof:o,recentInputStateRootIndices:i}){if(n.length>4)throw new Error("Cannot merge more than 4 token accounts at once");return ut(n,r),[await this.transfer({payer:e,inputCompressedTokenAccounts:n,toAddress:t,amount:n.reduce(((e,t)=>e.add(t.parsed.amount)),s(0)),recentInputStateRootIndices:i,recentValidityProof:o})]}static async compressSplTokenAccount({feePayer:e,authority:r,tokenAccount:o,mint:i,remainingAmount:s,outputStateTreeInfo:a,tokenPoolInfo:c}){je(c,i);const p=[{pubkey:a.treeType===u.StateV2?a.queue:a.tree,isSigner:0,isWritable:1}],d=wt({owner:r,remainingAmount:s??null,cpiContext:null}),{accountCompressionAuthority:h,noopProgram:g,registeredProgramPda:f,accountCompressionProgram:y}=m(),P=xt({feePayer:e,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:f,noopProgram:g,accountCompressionAuthority:h,accountCompressionProgram:y,selfProgram:this.programId,tokenPoolPda:c.tokenPoolPda,compressOrDecompressTokenAccount:o,tokenProgram:c.tokenProgram,systemProgram:t.programId});return P.push(...p),new n({programId:this.programId,keys:P,data:d})}static async getMintProgramId(e,t){return(await t.getAccountInfo(e))?.owner}static async approve({payer:e,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:a,recentInputStateRootIndices:c}){const{inputTokenDataWithContext:p,remainingAccountMetas:d}=at({inputCompressedTokenAccounts:r,rootIndices:c,tokenTransferOutputs:[]}),{mint:h,currentOwner:g}=Vt(r),f=r[0].compressedAccount.treeInfo.treeType===u.StateV2?1:0,y=Lt({proof:a,mint:h,inputTokenDataWithContext:p,cpiContext:null,delegate:o,delegatedAmount:s(i),delegateMerkleTreeIndex:f,changeAccountMerkleTreeIndex:f,delegateLamports:null}),{accountCompressionAuthority:P,noopProgram:k,registeredProgramPda:b,accountCompressionProgram:A}=m(),w=Et({feePayer:e,authority:g,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:b,noopProgram:k,accountCompressionAuthority:P,accountCompressionProgram:A,selfProgram:this.programId,systemProgram:t.programId});return w.push(...d),new n({programId:this.programId,keys:w,data:y})}static async revoke({payer:e,inputCompressedTokenAccounts:r,recentValidityProof:o,recentInputStateRootIndices:i}){Nt(r);const{inputTokenDataWithContext:s,remainingAccountMetas:a}=at({inputCompressedTokenAccounts:r,rootIndices:i,tokenTransferOutputs:[]}),{mint:c,currentOwner:p}=Vt(r),d=Ft({proof:o,mint:c,inputTokenDataWithContext:s,cpiContext:null,outputAccountMerkleTreeIndex:r[0].compressedAccount.treeInfo.treeType===u.StateV2?2:1}),{accountCompressionAuthority:h,noopProgram:g,registeredProgramPda:f,accountCompressionProgram:y}=m(),P=Dt({feePayer:e,authority:p,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:f,noopProgram:g,accountCompressionAuthority:h,accountCompressionProgram:y,selfProgram:this.programId,systemProgram:t.programId});return P.push(...a),new n({programId:this.programId,keys:P,data:d})}}async function Zt(e,t,n,r,i,a,u){r=s(r);const c=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:n}),[p]=tt(c.items,r),m=await e.getValidityProofV0(p.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await jt.approve({payer:t.publicKey,inputCompressedTokenAccounts:p,toAddress:a,amount:r,recentInputStateRootIndices:m.rootIndices,recentValidityProof:m.compressedProof}),{blockhash:l}=await e.getLatestBlockhash(),h=P(t,[i]),g=k([o.setComputeUnitLimit({units:35e4}),d],t,l,h);return b(e,g,u)}async function Qt(e,t,n,r,i,s,a,u,c){a=a??A(await e.getStateTreeInfos()),u=u??Xe(await Ze(e,n));const p=await M(e,t,n,i.publicKey,void 0,void 0,c,u.tokenProgram),m=await jt.approveAndMintTo({feePayer:t.publicKey,mint:n,authority:i.publicKey,authorityTokenAccount:p.address,amount:s,toPubkey:r,outputStateTreeInfo:a,tokenPoolInfo:u}),{blockhash:l}=await e.getLatestBlockhash(),h=P(t,[i]),g=k([o.setComputeUnitLimit({units:15e4+2e4*d(s).length}),...m],t,l,h);return await b(e,g,c)}async function Jt(e,t,n,r,i,s,a,u,c,p){u=u??A(await e.getStateTreeInfos()),c=c??Xe(await Ze(e,n));const m=await jt.compress({payer:t.publicKey,owner:i.publicKey,source:s,toAddress:a,amount:r,mint:n,outputStateTreeInfo:u,tokenPoolInfo:c}),l=await e.getLatestBlockhash(),h=P(t,[i]),g=k([o.setComputeUnitLimit({units:13e4+2e4*d(r).length}),m],t,l.blockhash,h);return await b(e,g,p,l)}async function Xt(e,t,n,r,i,s,a,u,c){a=a??A(await e.getStateTreeInfos()),u=u??Xe(await Ze(e,n));const p=await jt.compressSplTokenAccount({feePayer:t.publicKey,authority:r.publicKey,tokenAccount:i,mint:n,remainingAmount:s,outputStateTreeInfo:a,tokenPoolInfo:u}),m=await e.getLatestBlockhash(),d=P(t,[r]),l=k([o.setComputeUnitLimit({units:15e4}),p],t,m.blockhash,d);return await b(e,l,c,m)}async function Gt(e,t,n,r,o=i.generate(),s,a,u){const c=await e.getMinimumBalanceForRentExemption(S),p=1==a?v:a||T,m=await jt.createMint({feePayer:t.publicKey,mint:o.publicKey,decimals:r,authority:"secretKey"in n?n.publicKey:n,freezeAuthority:u&&"secretKey"in u?u.publicKey:u??null,rentExemptBalance:c,tokenProgramId:p}),{blockhash:d}=await e.getLatestBlockhash(),l=P(t,[n,u].filter((e=>null!=e&&"secretKey"in e))),h=k(m,t,d,[...l,o]),g=await b(e,h,s);return{mint:o.publicKey,transactionSignature:g}}async function en(e,t,n,r,o){o=o||await jt.getMintProgramId(n,e);const i=await jt.createTokenPool({feePayer:t.publicKey,mint:n,tokenProgramId:o}),{blockhash:s}=await e.getLatestBlockhash(),a=k([i],t,s);return await b(e,a,r)}async function tn(e,t,n,r,o,i){i=i||await jt.getMintProgramId(n,e);const s=[],a=(await Ze(e,n)).slice(0,4),u=[];for(let e=0;e<a.length;e++)a[e].isInitialized||u.push(e);for(let e=0;e<r&&!(e>=u.length);e++)s.push(await jt.addTokenPool({mint:n,feePayer:t.publicKey,tokenProgramId:i,poolIndex:u[e]}));const{blockhash:c}=await e.getLatestBlockhash(),p=k(s,t,c);return await b(e,p,o)}async function nn(e,t,n,r,o){const i=await e.getSlot("finalized"),{instructions:s,address:a}=await jt.createTokenProgramLookupTable({payer:t.publicKey,authority:n.publicKey,mints:r,remainingAccounts:o,recentSlot:i}),u=P(t,[n]),c=[];for(const n of s){const r=await e.getLatestBlockhash(),o=k([n],t,r.blockhash,u),i=await b(e,o,{commitment:"finalized"},r);c.push(i)}return{txIds:c,address:a}}async function rn(e,t,n,r,i,a,u,c){r=s(r);const p=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:n}),[m]=rt(p.items,r),d=await e.getValidityProofV0(m.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),l=Ge(u=u??await Ze(e,n),r),h=await jt.decompress({payer:t.publicKey,inputCompressedTokenAccounts:m,toAddress:a,amount:r,tokenPoolInfos:l,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:g}=await e.getLatestBlockhash(),f=P(t,[i]),y=k([o.setComputeUnitLimit({units:35e4}),h],t,g,f);return await b(e,y,c)}async function on(e,t,n,r,i){const a=await e.getCompressedTokenAccountsByOwner(r.publicKey,{mint:n});if(0===a.items.length)throw new Error(`No compressed token accounts found for mint ${n.toBase58()}`);const u=[o.setComputeUnitLimit({units:1e6})];for(let o=0;o<a.items.slice(0,8).length;o+=4){const i=a.items.slice(o,o+4),c=await e.getValidityProof(i.map((e=>s(e.compressedAccount.hash)))),p=await jt.mergeTokenAccounts({payer:t.publicKey,owner:r.publicKey,inputCompressedTokenAccounts:i,mint:n,recentValidityProof:c.compressedProof,recentInputStateRootIndices:c.rootIndices});u.push(...p)}const{blockhash:c}=await e.getLatestBlockhash(),p=P(t,[r]),m=k(u,t,c,p);return b(e,m,i)}async function sn(e,t,n,r,i,s,a,u,c){a=a??A(await e.getStateTreeInfos()),u=u??Xe(await Ze(e,n));const p=await jt.mintTo({feePayer:t.publicKey,mint:n,authority:i.publicKey,amount:s,toPubkey:r,outputStateTreeInfo:a,tokenPoolInfo:u}),{blockhash:m}=await e.getLatestBlockhash(),d=P(t,[i]),l=k([o.setComputeUnitLimit({units:1e6}),p],t,m,d);return b(e,l,c)}async function an(e,t,n,r,i){const s=await e.getValidityProofV0(n.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));!function(e,t){if(!e.publicKey.equals(t[0].parsed.owner))throw new Error(`Owner ${e.publicKey.toBase58()} does not match account ${t[0].parsed.owner.toBase58()}`)}(r,n),function(e){if(e.some((e=>null===e.parsed.delegate)))throw new Error("Account is not delegated")}(n);const a=await jt.revoke({payer:t.publicKey,inputCompressedTokenAccounts:n,recentInputStateRootIndices:s.rootIndices,recentValidityProof:s.compressedProof}),{blockhash:u}=await e.getLatestBlockhash(),c=P(t,[r]),p=k([o.setComputeUnitLimit({units:5e5}),a],t,u,c);return b(e,p,i)}async function un(e,t,n,r,i,a,u){r=s(r);const c=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:n}),[p]=rt(c.items,r),m=await e.getValidityProofV0(p.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await jt.transfer({payer:t.publicKey,inputCompressedTokenAccounts:p,toAddress:a,amount:r,recentInputStateRootIndices:m.rootIndices,recentValidityProof:m.compressedProof}),{blockhash:l}=await e.getLatestBlockhash(),h=P(t,[i]),g=k([o.setComputeUnitLimit({units:5e5}),d],t,l,h);return b(e,g,u)}async function cn(e,t,n,r,i,a,u){r=s(r);const c=await e.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:n}),[p]=rt(c.items,r),m=await e.getValidityProofV0(p.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await jt.transfer({payer:t.publicKey,inputCompressedTokenAccounts:p,toAddress:a,amount:r,recentInputStateRootIndices:m.rootIndices,recentValidityProof:m.compressedProof}),{blockhash:l}=await e.getLatestBlockhash(),h=P(t,[i]),g=k([o.setComputeUnitLimit({units:5e5}),d],t,l,h);return b(e,g,u)}async function pn(e,t,n,r,i,a,u,c){r=s(r);const p=await e.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:n}),[m]=rt(p.items,r),d=await e.getValidityProofV0(m.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),l=u??Ge(await Ze(e,n),r),h=await jt.decompress({payer:t.publicKey,inputCompressedTokenAccounts:m,toAddress:a,amount:r,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,tokenPoolInfos:l}),{blockhash:g}=await e.getLatestBlockhash(),f=P(t,[i]),y=k([o.setComputeUnitLimit({units:35e4}),h],t,g,f);return b(e,y,c)}const mn={version:"1.2.0",name:"light_compressed_token",instructions:[{name:"createTokenPool",docs:["This instruction creates a token pool for a given mint. Every spl mint","can have one token pool. When a token is compressed the tokens are","transferrred to the token pool, and their compressed equivalent is","minted into a Merkle tree."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[]},{name:"addTokenPool",docs:["This instruction creates an additional token pool for a given mint.","The maximum number of token pools per mint is 5."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"existingTokenPoolPda",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[{name:"tokenPoolIndex",type:"u8"}]},{name:"mintTo",docs:["Mints tokens from an spl token mint to a list of compressed accounts.","Minted tokens are transferred to a pool account owned by the compressed","token program. The instruction creates one compressed output account for","every amount and pubkey input pair. A constant amount of lamports can be","transferred to each output account to enable. A use case to add lamports","to a compressed token account is to prevent spam. This is the only way","to add lamports to a compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0,docs:["programs"]},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"merkleTree",isMut:1,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"solPoolPda",isMut:1,isSigner:0,isOptional:1}],args:[{name:"publicKeys",type:{vec:"publicKey"}},{name:"amounts",type:{vec:"u64"}},{name:"lamports",type:{option:"u64"}}]},{name:"compressSplTokenAccount",docs:["Compresses the balance of an spl token account sub an optional remaining","amount. This instruction does not close the spl token account. To close","the account bundle a close spl account instruction in your transaction."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"owner",type:"publicKey"},{name:"remainingAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]},{name:"transfer",docs:["Transfers compressed tokens from one account to another. All accounts","must be of the same mint. Additional spl tokens can be compressed or","decompressed. In one transaction only compression or decompression is","possible. Lamports can be transferred alongside tokens. If output token","accounts specify less lamports than inputs the remaining lamports are","transferred to an output compressed account. Signer must be owner or","delegate. If a delegated token account is transferred the delegate is","not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"approve",docs:["Delegates an amount to a delegate. A compressed token account is either","completely delegated or not. Prior delegates are not preserved. Cannot","be called by a delegate.","The instruction creates two output accounts:","1. one account with delegated amount","2. one account with remaining(change) amount"],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"revoke",docs:["Revokes a delegation. The instruction merges all inputs into one output","account. Cannot be called by a delegate. Delegates are not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"freeze",docs:["Freezes compressed token accounts. Inputs must not be frozen. Creates as","many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"thaw",docs:["Thaws frozen compressed token accounts. Inputs must be frozen. Creates","as many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"burn",docs:["Burns compressed tokens and spl tokens from the pool account. Delegates","can burn tokens. The output compressed token account remains delegated.","Creates one output compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"stubIdlBuild",docs:["This function is a stub to allow Anchor to include the input types in","the IDL. It should not be included in production builds nor be called in","practice."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs1",type:{defined:"CompressedTokenInstructionDataTransfer"}},{name:"inputs2",type:{defined:"TokenData"}}]}],types:[{name:"AccountState",type:{kind:"enum",variants:[{name:"Initialized"},{name:"Frozen"}]}},{name:"CompressedAccount",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"lamports",type:"u64"},{name:"address",type:{option:{array:["u8",32]}}},{name:"data",type:{option:{defined:"CompressedAccountData"}}}]}},{name:"CompressedAccountData",type:{kind:"struct",fields:[{name:"discriminator",type:{array:["u8",8]}},{name:"data",type:"bytes"},{name:"dataHash",type:{array:["u8",32]}}]}},{name:"CompressedCpiContext",type:{kind:"struct",fields:[{name:"setContext",docs:["Is set by the program that is invoking the CPI to signal that is should","set the cpi context."],type:"bool"},{name:"firstSetContext",docs:["Is set to wipe the cpi context since someone could have set it before","with unrelated data."],type:"bool"},{name:"cpiContextAccountIndex",docs:["Index of cpi context account in remaining accounts."],type:"u8"}]}},{name:"CompressedProof",type:{kind:"struct",fields:[{name:"a",type:{array:["u8",32]}},{name:"b",type:{array:["u8",64]}},{name:"c",type:{array:["u8",32]}}]}},{name:"CompressedTokenInstructionDataTransfer",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"delegatedTransfer",docs:["Is required if the signer is delegate,","-> delegate is authority account,","owner = Some(owner) is the owner of the token account."],type:{option:{defined:"DelegatedTransfer"}}},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"PackedTokenTransferOutputData"}}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"lamportsChangeAccountMerkleTreeIndex",type:{option:"u8"}}]}},{name:"CompressedTokenInstructionDataRevoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"outputAccountMerkleTreeIndex",type:"u8"}]}},{name:"CompressedTokenInstructionDataApprove",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"delegate",type:"publicKey"},{name:"delegatedAmount",type:"u64"},{name:"delegateMerkleTreeIndex",type:"u8"},{name:"changeAccountMerkleTreeIndex",type:"u8"},{name:"delegateLamports",type:{option:"u64"}}]}},{name:"DelegatedTransfer",docs:["Struct to provide the owner when the delegate is signer of the transaction."],type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"delegateChangeAccountIndex",docs:["Index of change compressed account in output compressed accounts. In","case that the delegate didn't spend the complete delegated compressed","account balance the change compressed account will be delegated to her","as well."],type:{option:"u8"}}]}},{name:"InputTokenDataWithContext",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"delegateIndex",type:{option:"u8"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",type:"u16"},{name:"lamports",type:{option:"u64"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"InstructionDataInvoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"}]}},{name:"InstructionDataInvokeCpi",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]}},{name:"MerkleTreeSequenceNumber",type:{kind:"struct",fields:[{name:"pubkey",type:"publicKey"},{name:"seq",type:"u64"}]}},{name:"NewAddressParamsPacked",type:{kind:"struct",fields:[{name:"seed",type:{array:["u8",32]}},{name:"addressQueueAccountIndex",type:"u8"},{name:"addressMerkleTreeAccountIndex",type:"u8"},{name:"addressMerkleTreeRootIndex",type:"u16"}]}},{name:"OutputCompressedAccountWithPackedContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleTreeIndex",type:"u8"}]}},{name:"PackedCompressedAccountWithMerkleContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",docs:["Index of root used in inclusion validity proof."],type:"u16"},{name:"readOnly",docs:["Placeholder to mark accounts read-only unimplemented set to false."],type:"bool"}]}},{name:"PackedMerkleContext",type:{kind:"struct",fields:[{name:"merkleTreePubkeyIndex",type:"u8"},{name:"queuePubkeyIndex",type:"u8"},{name:"leafIndex",type:"u32"},{name:"proveByIndex",type:"bool"}]}},{name:"PackedTokenTransferOutputData",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"amount",type:"u64"},{name:"lamports",type:{option:"u64"}},{name:"merkleTreeIndex",type:"u8"},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"PublicTransactionEvent",type:{kind:"struct",fields:[{name:"inputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"outputLeafIndices",type:{vec:"u32"}},{name:"sequenceNumbers",type:{vec:{defined:"MerkleTreeSequenceNumber"}}},{name:"relayFee",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"pubkeyArray",type:{vec:"publicKey"}},{name:"message",type:{option:"bytes"}}]}},{name:"QueueIndex",type:{kind:"struct",fields:[{name:"queueId",docs:["Id of queue in queue account."],type:"u8"},{name:"index",docs:["Index of compressed account hash in queue."],type:"u16"}]}},{name:"TokenData",type:{kind:"struct",fields:[{name:"mint",docs:["The mint associated with this account"],type:"publicKey"},{name:"owner",docs:["The owner of this account."],type:"publicKey"},{name:"amount",docs:["The amount of tokens this account holds."],type:"u64"},{name:"delegate",docs:["If `delegate` is `Some` then `delegated_amount` represents","the amount authorized by the delegate"],type:{option:"publicKey"}},{name:"state",docs:["The account's state"],type:{defined:"AccountState"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}}],errors:[{code:6e3,name:"PublicKeyAmountMissmatch",msg:"public keys and amounts must be of same length"},{code:6001,name:"ComputeInputSumFailed",msg:"ComputeInputSumFailed"},{code:6002,name:"ComputeOutputSumFailed",msg:"ComputeOutputSumFailed"},{code:6003,name:"ComputeCompressSumFailed",msg:"ComputeCompressSumFailed"},{code:6004,name:"ComputeDecompressSumFailed",msg:"ComputeDecompressSumFailed"},{code:6005,name:"SumCheckFailed",msg:"SumCheckFailed"},{code:6006,name:"DecompressRecipientUndefinedForDecompress",msg:"DecompressRecipientUndefinedForDecompress"},{code:6007,name:"CompressedPdaUndefinedForDecompress",msg:"CompressedPdaUndefinedForDecompress"},{code:6008,name:"DeCompressAmountUndefinedForDecompress",msg:"DeCompressAmountUndefinedForDecompress"},{code:6009,name:"CompressedPdaUndefinedForCompress",msg:"CompressedPdaUndefinedForCompress"},{code:6010,name:"DeCompressAmountUndefinedForCompress",msg:"DeCompressAmountUndefinedForCompress"},{code:6011,name:"DelegateSignerCheckFailed",msg:"DelegateSignerCheckFailed"},{code:6012,name:"MintTooLarge",msg:"Minted amount greater than u64::MAX"},{code:6013,name:"SplTokenSupplyMismatch",msg:"SplTokenSupplyMismatch"},{code:6014,name:"HeapMemoryCheckFailed",msg:"HeapMemoryCheckFailed"},{code:6015,name:"InstructionNotCallable",msg:"The instruction is not callable"},{code:6016,name:"ArithmeticUnderflow",msg:"ArithmeticUnderflow"},{code:6017,name:"HashToFieldError",msg:"HashToFieldError"},{code:6018,name:"InvalidAuthorityMint",msg:"Expected the authority to be also a mint authority"},{code:6019,name:"InvalidFreezeAuthority",msg:"Provided authority is not the freeze authority"},{code:6020,name:"InvalidDelegateIndex"},{code:6021,name:"TokenPoolPdaUndefined"},{code:6022,name:"IsTokenPoolPda",msg:"Compress or decompress recipient is the same account as the token pool pda."},{code:6023,name:"InvalidTokenPoolPda"},{code:6024,name:"NoInputTokenAccountsProvided"},{code:6025,name:"NoInputsProvided"},{code:6026,name:"MintHasNoFreezeAuthority"},{code:6027,name:"MintWithInvalidExtension"},{code:6028,name:"InsufficientTokenAccountBalance",msg:"The token account balance is less than the remaining amount."},{code:6029,name:"InvalidTokenPoolBump",msg:"Max number of token pools reached."},{code:6030,name:"FailedToDecompress"},{code:6031,name:"FailedToBurnSplTokensFromTokenPool"},{code:6032,name:"NoMatchingBumpFound"}]};function dn(e){return!Array.isArray(e)}export{He as ADD_TOKEN_POOL_DISCRIMINATOR,ze as APPROVE_DISCRIMINATOR,Qe as Action,Ye as BATCH_COMPRESS_DISCRIMINATOR,Ve as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,Le as CPI_AUTHORITY_SEED,Fe as CREATE_TOKEN_POOL_DISCRIMINATOR,Wt as CompressedTokenInstructionDataApproveLayout,Bt as CompressedTokenInstructionDataRevokeLayout,ht as CompressedTokenInstructionDataTransferLayout,jt as CompressedTokenProgram,lt as CpiContextLayout,dt as DelegatedTransferLayout,et as ERROR_NO_ACCOUNTS_FOUND,mn as IDL,qe as MINT_TO_DISCRIMINATOR,_e as POOL_SEED,$e as REVOKE_DISCRIMINATOR,Ke as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,Ne as TRANSFER_DISCRIMINATOR,vt as addTokenPoolAccountsLayout,tn as addTokenPools,Zt as approve,Et as approveAccountsLayout,Qt as approveAndMintTo,ft as batchCompressLayout,ut as checkMint,je as checkTokenPoolInfo,Jt as compress,Xt as compressSplTokenAccount,yt as compressSplTokenAccountInstructionDataLayout,Ht as createDecompressOutputState,Gt as createMint,en as createTokenPool,Tt as createTokenPoolAccountsLayout,nn as createTokenProgramLookupTable,$t as createTransferOutputState,Kt as decodeApproveInstructionData,At as decodeBatchCompressInstructionData,St as decodeCompressSplTokenAccountInstructionData,kt as decodeMintToInstructionData,qt as decodeRevokeInstructionData,Ct as decodeTransferInstructionData,rn as decompress,pn as decompressDelegated,Lt as encodeApproveInstructionData,bt as encodeBatchCompressInstructionData,wt as encodeCompressSplTokenAccountInstructionData,Pt as encodeMintToInstructionData,Ft as encodeRevokeInstructionData,It as encodeTransferInstructionData,Ut as freezeAccountsLayout,Ze as getTokenPoolInfos,dn as isSingleTokenPoolInfo,on as mergeTokenAccounts,sn as mintTo,Mt as mintToAccountsLayout,gt as mintToLayout,at as packCompressedTokenAccounts,zt as parseMaybeDelegatedTransfer,Vt as parseTokenData,an as revoke,Dt as revokeAccountsLayout,nt as selectMinCompressedTokenAccountsForDecompression,rt as selectMinCompressedTokenAccountsForTransfer,ot as selectMinCompressedTokenAccountsForTransferOrPartial,it as selectSmartCompressedTokenAccountsForTransfer,st as selectSmartCompressedTokenAccountsForTransferOrPartial,tt as selectTokenAccountsForApprove,Xe as selectTokenPoolInfo,Ge as selectTokenPoolInfosForDecompression,Yt as sumUpTokenAmount,Rt as thawAccountsLayout,un as transfer,xt as transferAccountsLayout,cn as transferDelegated,Nt as validateSameTokenOwner};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/constants.ts","../../../../../src/utils/get-token-pool-infos.ts","../../../../../src/utils/select-input-accounts.ts","../../../../../src/utils/pack-compressed-token-accounts.ts","../../../../../src/utils/validation.ts","../../../../../src/layout.ts","../../../../../src/program.ts","../../../../../src/actions/approve.ts","../../../../../src/actions/approve-and-mint-to.ts","../../../../../src/actions/compress.ts","../../../../../src/actions/compress-spl-token-account.ts","../../../../../src/actions/create-mint.ts","../../../../../src/actions/create-token-pool.ts","../../../../../src/actions/create-token-program-lookup-table.ts","../../../../../src/actions/decompress.ts","../../../../../src/actions/merge-token-accounts.ts","../../../../../src/actions/mint-to.ts","../../../../../src/actions/revoke.ts","../../../../../src/actions/transfer.ts","../../../../../src/actions/transfer-delegated.ts","../../../../../src/actions/decompress-delegated.ts","../../../../../src/idl.ts","../../../../../src/types.ts"],"sourcesContent":["import { Buffer } from 'buffer';\nexport const POOL_SEED = Buffer.from('pool');\n\nexport const CPI_AUTHORITY_SEED = Buffer.from('cpi_authority');\n\nexport const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;\n\nexport const CREATE_TOKEN_POOL_DISCRIMINATOR = Buffer.from([\n 23, 169, 27, 122, 147, 169, 209, 152,\n]);\nexport const MINT_TO_DISCRIMINATOR = Buffer.from([\n 241, 34, 48, 186, 37, 179, 123, 192,\n]);\nexport const BATCH_COMPRESS_DISCRIMINATOR = Buffer.from([\n 65, 206, 101, 37, 147, 42, 221, 144,\n]);\nexport const TRANSFER_DISCRIMINATOR = Buffer.from([\n 163, 52, 200, 231, 140, 3, 69, 186,\n]);\nexport const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR = Buffer.from([\n 112, 230, 105, 101, 145, 202, 157, 97,\n]);\n\nexport const APPROVE_DISCRIMINATOR = Buffer.from([\n 69, 74, 217, 36, 115, 117, 97, 76,\n]);\nexport const REVOKE_DISCRIMINATOR = Buffer.from([\n 170, 23, 31, 34, 133, 173, 93, 242,\n]);\nexport const ADD_TOKEN_POOL_DISCRIMINATOR = Buffer.from([\n 114, 143, 210, 73, 96, 115, 1, 228,\n]);\n","import { Commitment, PublicKey } from '@solana/web3.js';\nimport { unpackAccount } from '@solana/spl-token';\nimport { CompressedTokenProgram } from '../program';\nimport { bn, Rpc } from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\n\n/**\n * Check if the token pool info is initialized and has a balance.\n * @param mint The mint of the token pool\n * @param tokenPoolInfo The token pool info\n * @returns True if the token pool info is initialized and has a balance\n */\nexport function checkTokenPoolInfo(\n tokenPoolInfo: TokenPoolInfo,\n mint: PublicKey,\n): boolean {\n if (!tokenPoolInfo.mint.equals(mint)) {\n throw new Error(`TokenPool mint does not match the provided mint.`);\n }\n\n if (!tokenPoolInfo.isInitialized) {\n throw new Error(\n `TokenPool is not initialized. Please create a compressed token pool for mint: ${mint.toBase58()} via createTokenPool().`,\n );\n }\n return true;\n}\n\n/**\n * Get the token pool infos for a given mint.\n * @param rpc The RPC client\n * @param mint The mint of the token pool\n * @param commitment The commitment to use\n *\n * @returns The token pool infos\n */\nexport async function getTokenPoolInfos(\n rpc: Rpc,\n mint: PublicKey,\n commitment?: Commitment,\n): Promise<TokenPoolInfo[]> {\n const addressesAndBumps = Array.from({ length: 5 }, (_, i) =>\n CompressedTokenProgram.deriveTokenPoolPdaWithIndex(mint, i),\n );\n\n const accountInfos = await rpc.getMultipleAccountsInfo(\n addressesAndBumps.map(addressAndBump => addressAndBump[0]),\n commitment,\n );\n\n if (accountInfos[0] === null) {\n throw new Error(\n `TokenPool not found. Please create a compressed token pool for mint: ${mint.toBase58()} via createTokenPool().`,\n );\n }\n\n const parsedInfos = addressesAndBumps.map((addressAndBump, i) =>\n accountInfos[i]\n ? unpackAccount(\n addressAndBump[0],\n accountInfos[i],\n accountInfos[i].owner,\n )\n : null,\n );\n\n const tokenProgram = accountInfos[0].owner;\n return parsedInfos.map((parsedInfo, i) => {\n if (!parsedInfo) {\n return {\n mint,\n tokenPoolPda: addressesAndBumps[i][0],\n tokenProgram,\n activity: undefined,\n balance: bn(0),\n isInitialized: false,\n poolIndex: i,\n bump: addressesAndBumps[i][1],\n };\n }\n\n return {\n mint,\n tokenPoolPda: parsedInfo.address,\n tokenProgram,\n activity: undefined,\n balance: bn(parsedInfo.amount.toString()),\n isInitialized: true,\n poolIndex: i,\n bump: addressesAndBumps[i][1],\n };\n });\n}\n\nexport type TokenPoolActivity = {\n signature: string;\n amount: BN;\n action: Action;\n};\n\n/**\n * Token pool pda info.\n */\nexport type TokenPoolInfo = {\n /**\n * The mint of the token pool\n */\n mint: PublicKey;\n /**\n * The token pool address\n */\n tokenPoolPda: PublicKey;\n /**\n * The token program of the token pool\n */\n tokenProgram: PublicKey;\n /**\n * count of txs and volume in the past 60 seconds.\n */\n activity?: {\n txs: number;\n amountAdded: BN;\n amountRemoved: BN;\n };\n /**\n * Whether the token pool is initialized\n */\n isInitialized: boolean;\n /**\n * The balance of the token pool\n */\n balance: BN;\n /**\n * The index of the token pool\n */\n poolIndex: number;\n /**\n * The bump used to derive the token pool pda\n */\n bump: number;\n};\n\n/**\n * @internal\n */\nexport enum Action {\n Compress = 1,\n Decompress = 2,\n Transfer = 3,\n}\n\n/**\n * @internal\n */\nconst shuffleArray = <T>(array: T[]): T[] => {\n for (let i = array.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [array[i], array[j]] = [array[j], array[i]];\n }\n return array;\n};\n\n/**\n * For `compress` and `mintTo` instructions only.\n * Select a random token pool info from the token pool infos.\n *\n * For `decompress`, use {@link selectTokenPoolInfosForDecompression} instead.\n *\n * @param infos The token pool infos\n *\n * @returns A random token pool info\n */\nexport function selectTokenPoolInfo(infos: TokenPoolInfo[]): TokenPoolInfo {\n const shuffledInfos = shuffleArray(infos);\n\n // filter only infos that are initialized\n const filteredInfos = shuffledInfos.filter(info => info.isInitialized);\n\n if (filteredInfos.length === 0) {\n throw new Error(\n 'Please pass at least one initialized token pool info.',\n );\n }\n\n // Return a single random token pool info\n return filteredInfos[0];\n}\n\n/**\n * Select one or multiple token pool infos from the token pool infos.\n *\n * Use this function for `decompress`.\n *\n * For `compress`, `mintTo` use {@link selectTokenPoolInfo} instead.\n *\n * @param infos The token pool infos\n * @param decompressAmount The amount of tokens to withdraw\n *\n * @returns Array with one or more token pool infos.\n */\nexport function selectTokenPoolInfosForDecompression(\n infos: TokenPoolInfo[],\n decompressAmount: number | BN,\n): TokenPoolInfo[] {\n if (infos.length === 0) {\n throw new Error('Please pass at least one token pool info.');\n }\n\n infos = shuffleArray(infos);\n // Find the first info where balance is 10x the requested amount\n const sufficientBalanceInfo = infos.find(info =>\n info.balance.gte(bn(decompressAmount).mul(bn(10))),\n );\n\n // filter only infos that are initialized\n infos = infos\n .filter(info => info.isInitialized)\n .sort((a, b) => a.poolIndex - b.poolIndex);\n\n const allBalancesZero = infos.every(info => info.balance.isZero());\n if (allBalancesZero) {\n throw new Error(\n 'All provided token pool balances are zero. Please pass recent token pool infos.',\n );\n }\n\n // If none found, return all infos\n return sufficientBalanceInfo ? [sufficientBalanceInfo] : infos;\n}\n","import { bn, ParsedTokenAccount } from '@lightprotocol/stateless.js';\n\nimport BN from 'bn.js';\n\nexport const ERROR_NO_ACCOUNTS_FOUND =\n 'Could not find accounts to select for transfer.';\n\n/**\n * Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.\n *\n * @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.\n * @param {BN} approveAmount - Amount to approve.\n * @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.\n * @returns {[\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]} - Returns:\n * - selectedAccounts: Accounts chosen for approval.\n * - total: Total amount from selected accounts.\n * - totalLamports: Total lamports from selected accounts.\n * - maxPossibleAmount: Max approvable amount given maxInputs.\n */\nexport function selectTokenAccountsForApprove(\n accounts: ParsedTokenAccount[],\n approveAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n // First try to find an exact match\n const exactMatch = accounts.find(account =>\n account.parsed.amount.eq(approveAmount),\n );\n if (exactMatch) {\n return [\n [exactMatch],\n exactMatch.parsed.amount,\n exactMatch.compressedAccount.lamports,\n exactMatch.parsed.amount,\n ];\n }\n\n // If no exact match, fall back to minimum selection\n return selectMinCompressedTokenAccountsForTransfer(\n accounts,\n approveAmount,\n maxInputs,\n );\n}\n\n/**\n * Selects the minimum number of compressed token accounts required for a\n * decompress instruction, up to a specified maximum.\n *\n * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.\n * @param {BN} amount Amount to decompress.\n * @param {number} [maxInputs=4] Max accounts to select. Default\n * is 4.\n *\n * @returns Returns selected accounts and their totals.\n */\nexport function selectMinCompressedTokenAccountsForDecompression(\n accounts: ParsedTokenAccount[],\n amount: BN,\n maxInputs: number = 4,\n): {\n selectedAccounts: ParsedTokenAccount[];\n total: BN;\n totalLamports: BN | null;\n maxPossibleAmount: BN;\n} {\n const [selectedAccounts, total, totalLamports, maxPossibleAmount] =\n selectMinCompressedTokenAccountsForTransfer(\n accounts,\n amount,\n maxInputs,\n );\n return { selectedAccounts, total, totalLamports, maxPossibleAmount };\n}\n\n/**\n * Selects the minimum number of compressed token accounts required for a\n * transfer or decompression instruction, up to a specified maximum.\n *\n * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.\n * @param {BN} transferAmount Amount to transfer or decompress.\n * @param {number} [maxInputs=4] Max accounts to select. Default\n * is 4.\n *\n * @returns Returns selected accounts and their totals. [\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]\n */\nexport function selectMinCompressedTokenAccountsForTransfer(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n const [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ] = selectMinCompressedTokenAccountsForTransferOrPartial(\n accounts,\n transferAmount,\n maxInputs,\n );\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n const totalBalance = accounts.reduce(\n (acc, account) => acc.add(account.parsed.amount),\n bn(0),\n );\n if (selectedAccounts.length >= maxInputs) {\n throw new Error(\n `Account limit exceeded: max ${maxPossibleAmount.toString()} (${maxInputs} accounts) per transaction. Total balance: ${totalBalance.toString()} (${accounts.length} accounts). Consider multiple transfers to spend full balance.`,\n );\n } else {\n throw new Error(\n `Insufficient balance for transfer. Required: ${transferAmount.toString()}, available: ${totalBalance.toString()}.`,\n );\n }\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,\n * returns partial amounts if insufficient accounts are found instead of\n * throwing an error.\n */\nexport function selectMinCompressedTokenAccountsForTransferOrPartial(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n if (accounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n let accumulatedAmount = bn(0);\n let accumulatedLamports = bn(0);\n let maxPossibleAmount = bn(0);\n\n const selectedAccounts: ParsedTokenAccount[] = [];\n\n accounts.sort((a, b) => b.parsed.amount.cmp(a.parsed.amount));\n\n for (const account of accounts) {\n if (selectedAccounts.length >= maxInputs) break;\n if (accumulatedAmount.gte(bn(transferAmount))) break;\n\n if (\n !account.parsed.amount.isZero() ||\n !account.compressedAccount.lamports.isZero()\n ) {\n accumulatedAmount = accumulatedAmount.add(account.parsed.amount);\n accumulatedLamports = accumulatedLamports.add(\n account.compressedAccount.lamports,\n );\n selectedAccounts.push(account);\n }\n }\n\n // Max, considering maxInputs\n maxPossibleAmount = accounts\n .slice(0, maxInputs)\n .reduce((total, account) => total.add(account.parsed.amount), bn(0));\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n console.log(\n `Insufficient balance for transfer. Requested: ${transferAmount.toString()}, Returns max available: ${maxPossibleAmount.toString()}.`,\n );\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Selects compressed token accounts for a transfer, ensuring one extra account\n * if possible, up to maxInputs.\n *\n * 1. Sorts accounts by amount (desc)\n * 2. Selects accounts until transfer amount is met or maxInputs is reached,\n * attempting to add one extra account if possible.\n *\n * @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.\n * @param {BN} transferAmount - The token amount to be transferred.\n * @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.\n * @returns {[\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]} - An array containing:\n * - selectedAccounts: The accounts selected for the transfer.\n * - total: The total amount accumulated from the selected accounts.\n * - totalLamports: The total lamports accumulated from the selected accounts.\n * - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.\n *\n * @example\n * const accounts = [\n * { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },\n * { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },\n * { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },\n * ];\n * const transferAmount = new BN(75);\n * const maxInputs = 2;\n *\n * const [selectedAccounts, total, totalLamports, maxPossibleAmount] =\n * selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);\n *\n * console.log(selectedAccounts.length); // 2\n * console.log(total.toString()); // '150'\n * console.log(totalLamports!.toString()); // '15'\n * console.log(maxPossibleAmount.toString()); // '150'\n */\nexport function selectSmartCompressedTokenAccountsForTransfer(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n const [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ] = selectSmartCompressedTokenAccountsForTransferOrPartial(\n accounts,\n transferAmount,\n maxInputs,\n );\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n const totalBalance = accounts.reduce(\n (acc, account) => acc.add(account.parsed.amount),\n bn(0),\n );\n if (selectedAccounts.length >= maxInputs) {\n throw new Error(\n `Account limit exceeded: max ${maxPossibleAmount.toString()} (${maxInputs} accounts) per transaction. Total balance: ${totalBalance.toString()} (${accounts.length} accounts). Consider multiple transfers to spend full balance.`,\n );\n } else {\n throw new Error(\n `Insufficient balance. Required: ${transferAmount.toString()}, available: ${totalBalance.toString()}.`,\n );\n }\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,\n * returns partial amounts if insufficient accounts are found instead of\n * throwing an error.\n */\nexport function selectSmartCompressedTokenAccountsForTransferOrPartial(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n if (accounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n let accumulatedAmount = bn(0);\n let accumulatedLamports = bn(0);\n\n const selectedAccounts: ParsedTokenAccount[] = [];\n\n // we can ignore zero value accounts.\n const nonZeroAccounts = accounts.filter(\n account =>\n !account.parsed.amount.isZero() ||\n !account.compressedAccount.lamports.isZero(),\n );\n\n nonZeroAccounts.sort((a, b) => b.parsed.amount.cmp(a.parsed.amount));\n\n for (const account of nonZeroAccounts) {\n if (selectedAccounts.length >= maxInputs) break;\n accumulatedAmount = accumulatedAmount.add(account.parsed.amount);\n accumulatedLamports = accumulatedLamports.add(\n account.compressedAccount.lamports,\n );\n selectedAccounts.push(account);\n\n if (accumulatedAmount.gte(bn(transferAmount))) {\n // Select smallest additional account if maxInputs not reached\n const remainingAccounts = nonZeroAccounts.slice(\n selectedAccounts.length,\n );\n if (remainingAccounts.length > 0) {\n const smallestAccount = remainingAccounts.reduce((min, acc) =>\n acc.parsed.amount.lt(min.parsed.amount) ? acc : min,\n );\n if (selectedAccounts.length < maxInputs) {\n selectedAccounts.push(smallestAccount);\n accumulatedAmount = accumulatedAmount.add(\n smallestAccount.parsed.amount,\n );\n accumulatedLamports = accumulatedLamports.add(\n smallestAccount.compressedAccount.lamports,\n );\n }\n }\n break;\n }\n }\n\n const maxPossibleAmount = nonZeroAccounts\n .slice(0, maxInputs)\n .reduce((max, account) => max.add(account.parsed.amount), bn(0));\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n","import {\n ParsedTokenAccount,\n InputTokenDataWithContext,\n getIndexOrAdd,\n bn,\n padOutputStateMerkleTrees,\n TreeType,\n featureFlags,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { PublicKey, AccountMeta } from '@solana/web3.js';\nimport {\n PackedTokenTransferOutputData,\n TokenTransferOutputData,\n} from '../types';\n\nexport type PackCompressedTokenAccountsParams = {\n /** Input state to be consumed */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * State trees that the output should be inserted into. Defaults to the 0th\n * state tree of the input state. Gets padded to the length of\n * outputCompressedAccounts.\n */\n outputStateTreeInfo?: TreeInfo;\n /** Optional remaining accounts to append to */\n remainingAccounts?: PublicKey[];\n /**\n * Root indices that are used on-chain to fetch the correct root\n * from the state Merkle tree account for validity proof verification.\n */\n rootIndices: number[];\n tokenTransferOutputs: TokenTransferOutputData[];\n};\n\n/**\n * Packs Compressed Token Accounts.\n */\nexport function packCompressedTokenAccounts(\n params: PackCompressedTokenAccountsParams,\n): {\n inputTokenDataWithContext: InputTokenDataWithContext[];\n remainingAccountMetas: AccountMeta[];\n packedOutputTokenData: PackedTokenTransferOutputData[];\n} {\n const {\n inputCompressedTokenAccounts,\n outputStateTreeInfo,\n remainingAccounts = [],\n rootIndices,\n tokenTransferOutputs,\n } = params;\n\n const _remainingAccounts = remainingAccounts.slice();\n let delegateIndex: number | null = null;\n\n if (\n inputCompressedTokenAccounts.length > 0 &&\n inputCompressedTokenAccounts[0].parsed.delegate\n ) {\n delegateIndex = getIndexOrAdd(\n _remainingAccounts,\n inputCompressedTokenAccounts[0].parsed.delegate,\n );\n }\n\n const packedInputTokenData: InputTokenDataWithContext[] = [];\n /// pack inputs\n inputCompressedTokenAccounts.forEach(\n (account: ParsedTokenAccount, index) => {\n const merkleTreePubkeyIndex = getIndexOrAdd(\n _remainingAccounts,\n account.compressedAccount.treeInfo.tree,\n );\n\n const queuePubkeyIndex = getIndexOrAdd(\n _remainingAccounts,\n account.compressedAccount.treeInfo.queue,\n );\n\n packedInputTokenData.push({\n amount: account.parsed.amount,\n delegateIndex,\n merkleContext: {\n merkleTreePubkeyIndex,\n queuePubkeyIndex,\n leafIndex: account.compressedAccount.leafIndex,\n proveByIndex: account.compressedAccount.proveByIndex,\n },\n rootIndex: rootIndices[index],\n lamports: account.compressedAccount.lamports.eq(bn(0))\n ? null\n : account.compressedAccount.lamports,\n tlv: null,\n });\n },\n );\n\n if (inputCompressedTokenAccounts.length > 0 && outputStateTreeInfo) {\n throw new Error(\n 'Cannot specify both input accounts and outputStateTreeInfo',\n );\n }\n\n let treeInfo: TreeInfo;\n if (inputCompressedTokenAccounts.length > 0) {\n treeInfo = inputCompressedTokenAccounts[0].compressedAccount.treeInfo;\n } else if (outputStateTreeInfo) {\n treeInfo = outputStateTreeInfo;\n } else {\n throw new Error(\n 'Neither input accounts nor outputStateTreeInfo are available',\n );\n }\n\n // Use next tree if available, otherwise fall back to current tree.\n // `nextTreeInfo` always takes precedence.\n const activeTreeInfo = treeInfo.nextTreeInfo || treeInfo;\n let activeTreeOrQueue = activeTreeInfo.tree;\n\n if (activeTreeInfo.treeType === TreeType.StateV2) {\n if (featureFlags.isV2()) {\n activeTreeOrQueue = activeTreeInfo.queue;\n } else throw new Error('V2 trees are not supported yet');\n }\n\n // Pack output state trees\n const paddedOutputStateMerkleTrees = padOutputStateMerkleTrees(\n activeTreeOrQueue,\n tokenTransferOutputs.length,\n );\n const packedOutputTokenData: PackedTokenTransferOutputData[] = [];\n paddedOutputStateMerkleTrees.forEach((account, index) => {\n const merkleTreeIndex = getIndexOrAdd(_remainingAccounts, account);\n packedOutputTokenData.push({\n owner: tokenTransferOutputs[index].owner,\n amount: tokenTransferOutputs[index].amount,\n lamports: tokenTransferOutputs[index].lamports?.eq(bn(0))\n ? null\n : tokenTransferOutputs[index].lamports,\n merkleTreeIndex,\n tlv: null,\n });\n });\n // to meta\n const remainingAccountMetas = _remainingAccounts.map(\n (account): AccountMeta => ({\n pubkey: account,\n isWritable: true,\n isSigner: false,\n }),\n );\n\n return {\n inputTokenDataWithContext: packedInputTokenData,\n remainingAccountMetas,\n packedOutputTokenData,\n };\n}\n","import { ParsedTokenAccount } from '@lightprotocol/stateless.js';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Check if all input accounts belong to the same mint.\n *\n * @param compressedTokenAccounts The compressed token accounts\n * @param mint The mint of the token pool\n * @returns True if all input accounts belong to the same mint\n */\nexport function checkMint(\n compressedTokenAccounts: ParsedTokenAccount[],\n mint: PublicKey,\n): boolean {\n if (\n !compressedTokenAccounts.every(account =>\n account.parsed.mint.equals(mint),\n )\n ) {\n throw new Error(`All input accounts must belong to the same mint`);\n }\n\n return true;\n}\n","import {\n struct,\n option,\n vec,\n bool,\n u64,\n u8,\n publicKey,\n array,\n u32,\n u16,\n vecU8,\n} from '@coral-xyz/borsh';\nimport { AccountMeta, PublicKey } from '@solana/web3.js';\nimport { CompressedTokenProgram } from './program';\nimport {\n BatchCompressInstructionData,\n CompressedTokenInstructionDataApprove,\n CompressedTokenInstructionDataRevoke,\n CompressedTokenInstructionDataTransfer,\n CompressSplTokenAccountInstructionData,\n MintToInstructionData,\n} from './types';\nimport {\n APPROVE_DISCRIMINATOR,\n BATCH_COMPRESS_DISCRIMINATOR,\n COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,\n MINT_TO_DISCRIMINATOR,\n REVOKE_DISCRIMINATOR,\n TRANSFER_DISCRIMINATOR,\n} from './constants';\nimport { Buffer } from 'buffer';\nimport { ValidityProof } from '@lightprotocol/stateless.js';\n\nconst CompressedProofLayout = struct([\n array(u8(), 32, 'a'),\n array(u8(), 64, 'b'),\n array(u8(), 32, 'c'),\n]);\n\nconst PackedTokenTransferOutputDataLayout = struct([\n publicKey('owner'),\n u64('amount'),\n option(u64(), 'lamports'),\n u8('merkleTreeIndex'),\n option(vecU8(), 'tlv'),\n]);\n\nconst InputTokenDataWithContextLayout = struct([\n u64('amount'),\n option(u8(), 'delegateIndex'),\n struct(\n [\n u8('merkleTreePubkeyIndex'),\n u8('queuePubkeyIndex'),\n u32('leafIndex'),\n bool('proveByIndex'),\n ],\n 'merkleContext',\n ),\n u16('rootIndex'),\n option(u64(), 'lamports'),\n option(vecU8(), 'tlv'),\n]);\n\nexport const DelegatedTransferLayout = struct([\n publicKey('owner'),\n option(u8(), 'delegateChangeAccountIndex'),\n]);\n\nexport const CpiContextLayout = struct([\n bool('setContext'),\n bool('firstSetContext'),\n u8('cpiContextAccountIndex'),\n]);\n\nexport const CompressedTokenInstructionDataTransferLayout = struct([\n option(CompressedProofLayout, 'proof'),\n publicKey('mint'),\n option(DelegatedTransferLayout, 'delegatedTransfer'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n vec(PackedTokenTransferOutputDataLayout, 'outputCompressedAccounts'),\n bool('isCompress'),\n option(u64(), 'compressOrDecompressAmount'),\n option(CpiContextLayout, 'cpiContext'),\n option(u8(), 'lamportsChangeAccountMerkleTreeIndex'),\n]);\n\nexport const mintToLayout = struct([\n vec(publicKey(), 'recipients'),\n vec(u64(), 'amounts'),\n option(u64(), 'lamports'),\n]);\n\nexport const batchCompressLayout = struct([\n vec(publicKey(), 'pubkeys'),\n option(vec(u64(), 'amounts'), 'amounts'),\n option(u64(), 'lamports'),\n option(u64(), 'amount'),\n u8('index'),\n u8('bump'),\n]);\n\nexport const compressSplTokenAccountInstructionDataLayout = struct([\n publicKey('owner'),\n option(u64(), 'remainingAmount'),\n option(CpiContextLayout, 'cpiContext'),\n]);\n\nexport function encodeMintToInstructionData(\n data: MintToInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = mintToLayout.encode(\n {\n recipients: data.recipients,\n amounts: data.amounts,\n lamports: data.lamports,\n },\n buffer,\n );\n\n return Buffer.concat([\n new Uint8Array(MINT_TO_DISCRIMINATOR),\n new Uint8Array(buffer.subarray(0, len)),\n ]);\n}\n\nexport function decodeMintToInstructionData(\n buffer: Buffer,\n): MintToInstructionData {\n return mintToLayout.decode(\n buffer.subarray(MINT_TO_DISCRIMINATOR.length),\n ) as MintToInstructionData;\n}\n\nexport function encodeBatchCompressInstructionData(\n data: BatchCompressInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = batchCompressLayout.encode(data, buffer);\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n return Buffer.concat([\n new Uint8Array(BATCH_COMPRESS_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeBatchCompressInstructionData(\n buffer: Buffer,\n): BatchCompressInstructionData {\n return batchCompressLayout.decode(\n buffer.subarray(BATCH_COMPRESS_DISCRIMINATOR.length + 4),\n ) as BatchCompressInstructionData;\n}\n\nexport function encodeCompressSplTokenAccountInstructionData(\n data: CompressSplTokenAccountInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = compressSplTokenAccountInstructionDataLayout.encode(\n {\n owner: data.owner,\n remainingAmount: data.remainingAmount,\n cpiContext: data.cpiContext,\n },\n buffer,\n );\n\n return Buffer.concat([\n new Uint8Array(COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR),\n new Uint8Array(buffer.subarray(0, len)),\n ]);\n}\n\nexport function decodeCompressSplTokenAccountInstructionData(\n buffer: Buffer,\n): CompressSplTokenAccountInstructionData {\n const data = compressSplTokenAccountInstructionDataLayout.decode(\n buffer.subarray(COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR.length),\n ) as CompressSplTokenAccountInstructionData;\n return {\n owner: data.owner,\n remainingAmount: data.remainingAmount,\n cpiContext: data.cpiContext,\n };\n}\nexport function encodeTransferInstructionData(\n data: CompressedTokenInstructionDataTransfer,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const len = CompressedTokenInstructionDataTransferLayout.encode(\n data,\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(TRANSFER_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeTransferInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataTransfer {\n return CompressedTokenInstructionDataTransferLayout.decode(\n buffer.slice(TRANSFER_DISCRIMINATOR.length + 4),\n ) as CompressedTokenInstructionDataTransfer;\n}\n\ninterface BaseAccountsLayoutParams {\n feePayer: PublicKey;\n authority: PublicKey;\n cpiAuthorityPda: PublicKey;\n lightSystemProgram: PublicKey;\n registeredProgramPda: PublicKey;\n noopProgram: PublicKey;\n accountCompressionAuthority: PublicKey;\n accountCompressionProgram: PublicKey;\n selfProgram: PublicKey;\n systemProgram: PublicKey;\n}\nexport type createTokenPoolAccountsLayoutParams = {\n feePayer: PublicKey;\n tokenPoolPda: PublicKey;\n systemProgram: PublicKey;\n mint: PublicKey;\n tokenProgram: PublicKey;\n cpiAuthorityPda: PublicKey;\n};\n\nexport type addTokenPoolAccountsLayoutParams =\n createTokenPoolAccountsLayoutParams & {\n existingTokenPoolPda: PublicKey;\n };\n\nexport type mintToAccountsLayoutParams = BaseAccountsLayoutParams & {\n mint: PublicKey;\n tokenPoolPda: PublicKey;\n tokenProgram: PublicKey;\n merkleTree: PublicKey;\n solPoolPda: PublicKey | null;\n};\nexport type transferAccountsLayoutParams = BaseAccountsLayoutParams & {\n tokenPoolPda?: PublicKey;\n compressOrDecompressTokenAccount?: PublicKey;\n tokenProgram?: PublicKey;\n};\nexport type approveAccountsLayoutParams = BaseAccountsLayoutParams;\nexport type revokeAccountsLayoutParams = approveAccountsLayoutParams;\nexport type freezeAccountsLayoutParams = BaseAccountsLayoutParams & {\n mint: PublicKey;\n};\nexport type thawAccountsLayoutParams = freezeAccountsLayoutParams;\n\nexport const createTokenPoolAccountsLayout = (\n accounts: createTokenPoolAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n tokenPoolPda,\n systemProgram,\n mint,\n tokenProgram,\n cpiAuthorityPda,\n } = accounts;\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n ];\n};\n\nexport const addTokenPoolAccountsLayout = (\n accounts: addTokenPoolAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n tokenPoolPda,\n systemProgram,\n mint,\n tokenProgram,\n cpiAuthorityPda,\n existingTokenPoolPda,\n } = accounts;\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: existingTokenPoolPda, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n ];\n};\n\nexport const mintToAccountsLayout = (\n accounts: mintToAccountsLayoutParams,\n): AccountMeta[] => {\n const defaultPubkey = CompressedTokenProgram.programId;\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n mint,\n tokenPoolPda,\n tokenProgram,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n merkleTree,\n selfProgram,\n systemProgram,\n solPoolPda,\n } = accounts;\n\n const accountsList: AccountMeta[] = [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: merkleTree, isSigner: false, isWritable: true },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n {\n pubkey: solPoolPda ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n ];\n\n return accountsList;\n};\n\nexport const transferAccountsLayout = (\n accounts: transferAccountsLayoutParams,\n): AccountMeta[] => {\n const defaultPubkey = CompressedTokenProgram.programId;\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n tokenPoolPda,\n compressOrDecompressTokenAccount,\n tokenProgram,\n systemProgram,\n } = accounts;\n\n const accountsList: AccountMeta[] = [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n {\n pubkey: tokenPoolPda ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: compressOrDecompressTokenAccount ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: tokenProgram ?? defaultPubkey,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n ];\n\n return accountsList;\n};\n\nexport const approveAccountsLayout = (\n accounts: approveAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n systemProgram,\n } = accounts;\n\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n ];\n};\n\nexport const revokeAccountsLayout = approveAccountsLayout;\n\nexport const freezeAccountsLayout = (\n accounts: freezeAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n systemProgram,\n mint,\n } = accounts;\n\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: false },\n ];\n};\n\nexport const thawAccountsLayout = freezeAccountsLayout;\n\nexport const CompressedTokenInstructionDataApproveLayout = struct([\n struct(\n [array(u8(), 32, 'a'), array(u8(), 64, 'b'), array(u8(), 32, 'c')],\n 'proof',\n ),\n publicKey('mint'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n option(CpiContextLayout, 'cpiContext'),\n publicKey('delegate'),\n u64('delegatedAmount'),\n u8('delegateMerkleTreeIndex'),\n u8('changeAccountMerkleTreeIndex'),\n option(u64(), 'delegateLamports'),\n]);\n\nexport const CompressedTokenInstructionDataRevokeLayout = struct([\n struct(\n [array(u8(), 32, 'a'), array(u8(), 64, 'b'), array(u8(), 32, 'c')],\n 'proof',\n ),\n publicKey('mint'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n option(CpiContextLayout, 'cpiContext'),\n u8('outputAccountMerkleTreeIndex'),\n]);\n\n// Approve and revoke instuctions do not support optional proof yet.\nconst emptyProof: ValidityProof = {\n a: new Array(32).fill(0),\n b: new Array(64).fill(0),\n c: new Array(32).fill(0),\n};\n\nfunction isEmptyProof(proof: ValidityProof): boolean {\n return (\n proof.a.every(a => a === 0) &&\n proof.b.every(b => b === 0) &&\n proof.c.every(c => c === 0)\n );\n}\n\nexport function encodeApproveInstructionData(\n data: CompressedTokenInstructionDataApprove,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const proofOption = data.proof ?? emptyProof;\n\n const len = CompressedTokenInstructionDataApproveLayout.encode(\n {\n ...data,\n proof: proofOption,\n },\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(APPROVE_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeApproveInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataApprove {\n const data = CompressedTokenInstructionDataApproveLayout.decode(\n buffer.subarray(APPROVE_DISCRIMINATOR.length),\n ) as CompressedTokenInstructionDataApprove;\n return {\n ...data,\n proof: isEmptyProof(data.proof!) ? null : data.proof!,\n };\n}\n\nexport function encodeRevokeInstructionData(\n data: CompressedTokenInstructionDataRevoke,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const proofOption = data.proof ?? emptyProof;\n\n const len = CompressedTokenInstructionDataRevokeLayout.encode(\n {\n ...data,\n proof: proofOption,\n },\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(REVOKE_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeRevokeInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataRevoke {\n const data = CompressedTokenInstructionDataRevokeLayout.decode(\n buffer.subarray(REVOKE_DISCRIMINATOR.length),\n ) as CompressedTokenInstructionDataRevoke;\n return {\n ...data,\n proof: isEmptyProof(data.proof!) ? null : data.proof!,\n };\n}\n","import {\n PublicKey,\n TransactionInstruction,\n SystemProgram,\n Connection,\n AddressLookupTableProgram,\n AccountMeta,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport { Buffer } from 'buffer';\nimport {\n ValidityProof,\n LightSystemProgram,\n ParsedTokenAccount,\n bn,\n defaultStaticAccountsStruct,\n sumUpLamports,\n toArray,\n validateSameOwner,\n validateSufficientBalance,\n defaultTestStateTreeAccounts,\n TreeInfo,\n CompressedProof,\n featureFlags,\n TreeType,\n} from '@lightprotocol/stateless.js';\nimport {\n MINT_SIZE,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n createInitializeMint2Instruction,\n createMintToInstruction,\n} from '@solana/spl-token';\nimport {\n CPI_AUTHORITY_SEED,\n POOL_SEED,\n CREATE_TOKEN_POOL_DISCRIMINATOR,\n ADD_TOKEN_POOL_DISCRIMINATOR,\n} from './constants';\nimport { checkMint, packCompressedTokenAccounts } from './utils';\nimport {\n encodeTransferInstructionData,\n encodeCompressSplTokenAccountInstructionData,\n encodeMintToInstructionData,\n createTokenPoolAccountsLayout,\n mintToAccountsLayout,\n transferAccountsLayout,\n approveAccountsLayout,\n revokeAccountsLayout,\n encodeApproveInstructionData,\n encodeRevokeInstructionData,\n addTokenPoolAccountsLayout,\n encodeBatchCompressInstructionData,\n} from './layout';\nimport {\n BatchCompressInstructionData,\n CompressedTokenInstructionDataApprove,\n CompressedTokenInstructionDataRevoke,\n CompressedTokenInstructionDataTransfer,\n DelegatedTransfer,\n TokenTransferOutputData,\n} from './types';\nimport {\n checkTokenPoolInfo,\n TokenPoolInfo,\n} from './utils/get-token-pool-infos';\n\nexport type CompressParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Owner of uncompressed token account\n */\n owner: PublicKey;\n /**\n * Source SPL Token account address\n */\n source: PublicKey;\n /**\n * Recipient address(es)\n */\n toAddress: PublicKey | PublicKey[];\n /**\n * Token amount(s) to compress\n */\n amount: number | BN | number[] | BN[];\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type CompressSplTokenAccountParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Token account owner\n */\n authority: PublicKey;\n /**\n * SPL Token account to compress\n */\n tokenAccount: PublicKey;\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * Amount to leave in token account\n */\n remainingAmount?: BN;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type DecompressParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Destination uncompressed token account\n */\n toAddress: PublicKey;\n /**\n * Token amount to decompress\n */\n amount: number | BN;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n /**\n * Token pool(s)\n */\n tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[];\n};\n\nexport type TransferParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Recipient address\n */\n toAddress: PublicKey;\n /**\n * Token amount to transfer\n */\n amount: BN | number;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\nexport type ApproveParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Recipient address\n */\n toAddress: PublicKey;\n /**\n * Token amount to approve\n */\n amount: BN | number;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\nexport type RevokeParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Input compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\n/**\n * Create Mint account for compressed Tokens\n */\nexport type CreateMintParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Optional: freeze authority\n */\n freezeAuthority: PublicKey | null;\n /**\n * Mint decimals\n */\n decimals: number;\n /**\n * lamport amount for mint account rent exemption\n */\n rentExemptBalance: number;\n /**\n * Optional: The token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n /**\n * Optional: Mint size to use, defaults to MINT_SIZE\n */\n mintSize?: number;\n};\n\n/**\n * Parameters for merging compressed token accounts\n */\nexport type MergeTokenAccountsParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Owner of the compressed token accounts to be merged\n */\n owner: PublicKey;\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * Array of compressed token accounts to merge\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Validity proof for state inclusion\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * State root indices of the input state\n */\n recentInputStateRootIndices: number[];\n};\n\n/**\n * Create compressed token accounts\n */\nexport type MintToParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * Token mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Recipient address(es)\n */\n toPubkey: PublicKey[] | PublicKey;\n /**\n * Token amount(s) to mint\n */\n amount: BN | BN[] | number | number[];\n /**\n * State tree for minted tokens\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\n/**\n * Register an existing SPL mint account to the compressed token program\n * Creates an omnibus account for the mint\n */\nexport type CreateTokenPoolParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Optional: The token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n};\n\nexport type AddTokenPoolParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * Token mint address\n */\n mint: PublicKey;\n /**\n * Token pool index\n */\n poolIndex: number;\n /**\n * Optional: Token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n};\n\n/**\n * Mint from existing SPL mint to compressed token accounts\n */\nexport type ApproveAndMintToParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Mint authority (associated) token account\n */\n authorityTokenAccount: PublicKey;\n /**\n * Recipient address\n */\n toPubkey: PublicKey;\n /**\n * Token amount to mint\n */\n amount: BN | number;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type CreateTokenProgramLookupTableParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Authority of the transaction\n */\n authority: PublicKey;\n /**\n * Optional Mint addresses to store in the lookup table\n */\n mints?: PublicKey[];\n /**\n * Recently finalized Solana slot\n */\n recentSlot: number;\n /**\n * Optional additional addresses to store in the lookup table\n */\n remainingAccounts?: PublicKey[];\n};\n\n/**\n * Sum up the token amounts of the compressed token accounts\n */\nexport const sumUpTokenAmount = (accounts: ParsedTokenAccount[]): BN => {\n return accounts.reduce(\n (acc, account: ParsedTokenAccount) => acc.add(account.parsed.amount),\n bn(0),\n );\n};\n\n/**\n * Validate that all the compressed token accounts are owned by the same owner.\n */\nexport const validateSameTokenOwner = (accounts: ParsedTokenAccount[]) => {\n const owner = accounts[0].parsed.owner;\n accounts.forEach(acc => {\n if (!acc.parsed.owner.equals(owner)) {\n throw new Error('Token accounts must be owned by the same owner');\n }\n });\n};\n\n/**\n * Parse compressed token accounts to get the mint, current owner and delegate.\n */\nexport const parseTokenData = (\n compressedTokenAccounts: ParsedTokenAccount[],\n) => {\n const mint = compressedTokenAccounts[0].parsed.mint;\n const currentOwner = compressedTokenAccounts[0].parsed.owner;\n const delegate = compressedTokenAccounts[0].parsed.delegate;\n\n return { mint, currentOwner, delegate };\n};\n\nexport const parseMaybeDelegatedTransfer = (\n inputs: ParsedTokenAccount[],\n outputs: TokenTransferOutputData[],\n): { delegatedTransfer: DelegatedTransfer | null; authority: PublicKey } => {\n if (inputs.length < 1)\n throw new Error('Must supply at least one input token account.');\n\n const owner = inputs[0].parsed.owner;\n\n const delegatedAccountsIndex = inputs.findIndex(a => a.parsed.delegate);\n\n /// Fast path: no delegated account used\n if (delegatedAccountsIndex === -1)\n return { delegatedTransfer: null, authority: owner };\n\n const delegate = inputs[delegatedAccountsIndex].parsed.delegate;\n const delegateChangeAccountIndex = outputs.length <= 1 ? null : 0;\n\n return {\n delegatedTransfer: {\n owner,\n delegateChangeAccountIndex,\n },\n authority: delegate!,\n };\n};\n\n/**\n * Create the output state for a transfer transaction.\n * @param inputCompressedTokenAccounts Input state\n * @param toAddress Recipient address\n * @param amount Amount of tokens to transfer\n * @returns Output token data for the transfer\n * instruction\n */\nexport function createTransferOutputState(\n inputCompressedTokenAccounts: ParsedTokenAccount[],\n toAddress: PublicKey,\n amount: number | BN,\n): TokenTransferOutputData[] {\n amount = bn(amount);\n const inputAmount = sumUpTokenAmount(inputCompressedTokenAccounts);\n const inputLamports = sumUpLamports(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n\n const changeAmount = inputAmount.sub(amount);\n\n validateSufficientBalance(changeAmount);\n\n if (changeAmount.eq(bn(0)) && inputLamports.eq(bn(0))) {\n return [\n {\n owner: toAddress,\n amount,\n lamports: inputLamports,\n tlv: null,\n },\n ];\n }\n\n /// validates token program\n validateSameOwner(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const outputCompressedAccounts: TokenTransferOutputData[] = [\n {\n owner: inputCompressedTokenAccounts[0].parsed.owner,\n amount: changeAmount,\n lamports: inputLamports,\n tlv: null,\n },\n {\n owner: toAddress,\n amount,\n lamports: bn(0),\n tlv: null,\n },\n ];\n return outputCompressedAccounts;\n}\n\n/**\n * Create the output state for a compress transaction.\n * @param inputCompressedTokenAccounts Input state\n * @param amount Amount of tokens to compress\n * @returns Output token data for the compress\n * instruction\n */\nexport function createDecompressOutputState(\n inputCompressedTokenAccounts: ParsedTokenAccount[],\n amount: number | BN,\n): TokenTransferOutputData[] {\n amount = bn(amount);\n const inputLamports = sumUpLamports(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n const inputAmount = sumUpTokenAmount(inputCompressedTokenAccounts);\n const changeAmount = inputAmount.sub(amount);\n\n validateSufficientBalance(changeAmount);\n\n /// lamports gets decompressed\n if (changeAmount.eq(bn(0)) && inputLamports.eq(bn(0))) {\n return [];\n }\n\n validateSameOwner(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const tokenTransferOutputs: TokenTransferOutputData[] = [\n {\n owner: inputCompressedTokenAccounts[0].parsed.owner,\n amount: changeAmount,\n lamports: inputLamports,\n tlv: null,\n },\n ];\n return tokenTransferOutputs;\n}\n\nexport class CompressedTokenProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the CompressedPda program\n */\n static programId: PublicKey = new PublicKey(\n 'cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m',\n );\n\n /**\n * Set a custom programId via PublicKey or base58 encoded string.\n * This method is not required for regular usage.\n *\n * Use this only if you know what you are doing.\n */\n static setProgramId(programId: PublicKey | string) {\n this.programId =\n typeof programId === 'string'\n ? new PublicKey(programId)\n : programId;\n }\n\n /**\n * Derive the token pool pda.\n * To derive the token pool pda with bump, use {@link deriveTokenPoolPdaWithIndex}.\n *\n * @param mint The mint of the token pool\n *\n * @returns The token pool pda\n */\n static deriveTokenPoolPda(mint: PublicKey): PublicKey {\n const seeds = [POOL_SEED, mint.toBuffer()];\n const [address, _] = PublicKey.findProgramAddressSync(\n seeds,\n this.programId,\n );\n return address;\n }\n\n /**\n * Find the index and bump for a given token pool pda and mint.\n *\n * @param poolPda The token pool pda to find the index and bump for\n * @param mint The mint of the token pool\n *\n * @returns The index and bump number.\n */\n static findTokenPoolIndexAndBump(\n poolPda: PublicKey,\n mint: PublicKey,\n ): [number, number] {\n for (let index = 0; index < 5; index++) {\n const derivedPda =\n CompressedTokenProgram.deriveTokenPoolPdaWithIndex(mint, index);\n if (derivedPda[0].equals(poolPda)) {\n return [index, derivedPda[1]];\n }\n }\n throw new Error('Token pool not found');\n }\n\n /**\n * Derive the token pool pda with index.\n *\n * @param mint The mint of the token pool\n * @param index Index. starts at 0. The Protocol supports 4 indexes aka token pools\n * per mint.\n *\n * @returns The token pool pda and bump.\n */\n static deriveTokenPoolPdaWithIndex(\n mint: PublicKey,\n index: number,\n ): [PublicKey, number] {\n let seeds: Buffer[] = [];\n if (index === 0) {\n seeds = [Buffer.from('pool'), mint.toBuffer(), Buffer.from([])]; // legacy, 1st\n } else {\n seeds = [\n Buffer.from('pool'),\n mint.toBuffer(),\n Buffer.from([index]),\n ];\n }\n const [address, bump] = PublicKey.findProgramAddressSync(\n seeds,\n this.programId,\n );\n return [address, bump];\n }\n\n /** @internal */\n static get deriveCpiAuthorityPda(): PublicKey {\n const [address, _] = PublicKey.findProgramAddressSync(\n [CPI_AUTHORITY_SEED],\n this.programId,\n );\n return address;\n }\n\n /**\n * Construct createMint instruction for compressed tokens.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param freezeAuthority Optional: freeze authority.\n * @param decimals Decimals.\n * @param rentExemptBalance Lamport amount for mint account rent exemption.\n * @param tokenProgramId Optional: Token program ID. Default: SPL Token Program ID\n * @param mintSize Optional: mint size. Default: MINT_SIZE\n *\n * @returns [createMintAccountInstruction, initializeMintInstruction,\n * createTokenPoolInstruction]\n *\n * Note that `createTokenPoolInstruction` must be executed after\n * `initializeMintInstruction`.\n */\n static async createMint({\n feePayer,\n mint,\n authority,\n freezeAuthority,\n decimals,\n rentExemptBalance,\n tokenProgramId,\n mintSize,\n }: CreateMintParams): Promise<TransactionInstruction[]> {\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n /// Create and initialize SPL Mint account\n const createMintAccountInstruction = SystemProgram.createAccount({\n fromPubkey: feePayer,\n lamports: rentExemptBalance,\n newAccountPubkey: mint,\n programId: tokenProgram,\n space: mintSize ?? MINT_SIZE,\n });\n\n const initializeMintInstruction = createInitializeMint2Instruction(\n mint,\n decimals,\n authority,\n freezeAuthority,\n tokenProgram,\n );\n\n const createTokenPoolInstruction = await this.createTokenPool({\n feePayer,\n mint,\n tokenProgramId: tokenProgram,\n });\n\n return [\n createMintAccountInstruction,\n initializeMintInstruction,\n createTokenPoolInstruction,\n ];\n }\n\n /**\n * Enable compression for an existing SPL mint, creating an omnibus account.\n * For new mints, use `CompressedTokenProgram.createMint`.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param tokenProgramId Optional: Token program ID. Default: SPL\n * Token Program ID\n *\n * @returns The createTokenPool instruction\n */\n static async createTokenPool({\n feePayer,\n mint,\n tokenProgramId,\n }: CreateTokenPoolParams): Promise<TransactionInstruction> {\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n const tokenPoolPda = this.deriveTokenPoolPdaWithIndex(mint, 0);\n\n const keys = createTokenPoolAccountsLayout({\n mint,\n feePayer,\n tokenPoolPda: tokenPoolPda[0],\n tokenProgram,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n systemProgram: SystemProgram.programId,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data: CREATE_TOKEN_POOL_DISCRIMINATOR,\n });\n }\n\n /**\n * Add a token pool to an existing SPL mint. For new mints, use\n * {@link createTokenPool}.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param poolIndex Pool index.\n * @param tokenProgramId Optional: Token program ID. Default: SPL\n * Token Program ID\n *\n * @returns The addTokenPool instruction\n */\n static async addTokenPool({\n feePayer,\n mint,\n poolIndex,\n tokenProgramId,\n }: AddTokenPoolParams): Promise<TransactionInstruction> {\n if (poolIndex <= 0) {\n throw new Error(\n 'Pool index must be greater than 0. For 0, use CreateTokenPool instead.',\n );\n }\n if (poolIndex > 3) {\n throw new Error(\n `Invalid poolIndex ${poolIndex}. Max 4 pools per mint.`,\n );\n }\n\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n const existingTokenPoolPda = this.deriveTokenPoolPdaWithIndex(\n mint,\n poolIndex - 1,\n );\n const tokenPoolPda = this.deriveTokenPoolPdaWithIndex(mint, poolIndex);\n\n const keys = addTokenPoolAccountsLayout({\n mint,\n feePayer,\n tokenPoolPda: tokenPoolPda[0],\n existingTokenPoolPda: existingTokenPoolPda[0],\n tokenProgram,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n systemProgram: SystemProgram.programId,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data: Buffer.concat([\n new Uint8Array(ADD_TOKEN_POOL_DISCRIMINATOR),\n new Uint8Array(Buffer.from([poolIndex])),\n ]),\n });\n }\n\n /**\n * Construct mintTo instruction for compressed tokens\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param toPubkey Recipient owner address.\n * @param amount Amount of tokens to mint.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The mintTo instruction\n */\n static async mintTo({\n feePayer,\n mint,\n authority,\n toPubkey,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: MintToParams): Promise<TransactionInstruction> {\n const systemKeys = defaultStaticAccountsStruct();\n const tokenProgram = tokenPoolInfo.tokenProgram;\n checkTokenPoolInfo(tokenPoolInfo, mint);\n\n const amounts = toArray<BN | number>(amount).map(amount => bn(amount));\n const toPubkeys = toArray(toPubkey);\n\n if (amounts.length !== toPubkeys.length) {\n throw new Error(\n 'Amount and toPubkey arrays must have the same length',\n );\n }\n\n const keys = mintToAccountsLayout({\n mint,\n feePayer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n tokenProgram,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: systemKeys.registeredProgramPda,\n noopProgram: systemKeys.noopProgram,\n accountCompressionAuthority: systemKeys.accountCompressionAuthority,\n accountCompressionProgram: systemKeys.accountCompressionProgram,\n merkleTree:\n outputStateTreeInfo.treeType === TreeType.StateV2\n ? outputStateTreeInfo.queue\n : outputStateTreeInfo.tree,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n solPoolPda: null,\n });\n\n const data = encodeMintToInstructionData({\n recipients: toPubkeys,\n amounts,\n lamports: null,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Mint tokens from registered SPL mint account to a compressed account\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param authorityTokenAccount The mint authority's associated token\n * account (ATA).\n * @param toPubkey Recipient owner address.\n * @param amount Amount of tokens to mint.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The mintTo instruction\n */\n static async approveAndMintTo({\n feePayer,\n mint,\n authority,\n authorityTokenAccount,\n toPubkey,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: ApproveAndMintToParams) {\n const amountBigInt: bigint = BigInt(amount.toString());\n\n /// 1. Mint to existing ATA of mintAuthority.\n const splMintToInstruction = createMintToInstruction(\n mint,\n authorityTokenAccount,\n authority,\n amountBigInt,\n [],\n tokenPoolInfo.tokenProgram,\n );\n\n /// 2. Compress from mint authority ATA to recipient compressed account\n const compressInstruction = await this.compress({\n payer: feePayer,\n owner: authority,\n source: authorityTokenAccount,\n toAddress: toPubkey,\n mint,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n return [splMintToInstruction, compressInstruction];\n }\n\n /**\n * Construct transfer instruction for compressed tokens\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Recipient owner address.\n * @param amount Amount of tokens to transfer.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns The transfer instruction\n */\n static async transfer({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n }: TransferParams): Promise<TransactionInstruction> {\n const tokenTransferOutputs: TokenTransferOutputData[] =\n createTransferOutputState(\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n );\n\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs,\n });\n\n const { mint } = parseTokenData(inputCompressedTokenAccounts);\n\n const { delegatedTransfer, authority } = parseMaybeDelegatedTransfer(\n inputCompressedTokenAccounts,\n tokenTransferOutputs,\n );\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: recentValidityProof,\n mint,\n delegatedTransfer,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: null,\n isCompress: false,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n const keys = transferAccountsLayout({\n feePayer: payer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: undefined,\n compressOrDecompressTokenAccount: undefined,\n tokenProgram: undefined,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create lookup table instructions for the token program's default\n * accounts.\n *\n * @param payer Fee payer.\n * @param authority Authority.\n * @param mints Mints.\n * @param recentSlot Recent slot.\n * @param remainingAccounts Remaining accounts.\n *\n * @returns [createInstruction, extendInstruction, option(extendInstruction2)]\n */\n static async createTokenProgramLookupTable({\n payer,\n authority,\n mints,\n recentSlot,\n remainingAccounts,\n }: CreateTokenProgramLookupTableParams) {\n const [createInstruction, lookupTableAddress] =\n AddressLookupTableProgram.createLookupTable({\n authority,\n payer: authority,\n recentSlot,\n });\n\n let optionalMintKeys: PublicKey[] = [];\n if (mints) {\n optionalMintKeys = [\n ...mints,\n ...mints.map(mint => this.deriveTokenPoolPda(mint)),\n ];\n }\n\n const extendInstruction = AddressLookupTableProgram.extendLookupTable({\n payer,\n authority,\n lookupTable: lookupTableAddress,\n addresses: [\n SystemProgram.programId,\n ComputeBudgetProgram.programId,\n this.deriveCpiAuthorityPda,\n LightSystemProgram.programId,\n CompressedTokenProgram.programId,\n defaultStaticAccountsStruct().registeredProgramPda,\n defaultStaticAccountsStruct().noopProgram,\n defaultStaticAccountsStruct().accountCompressionAuthority,\n defaultStaticAccountsStruct().accountCompressionProgram,\n defaultTestStateTreeAccounts().merkleTree,\n defaultTestStateTreeAccounts().nullifierQueue,\n defaultTestStateTreeAccounts().addressTree,\n defaultTestStateTreeAccounts().addressQueue,\n this.programId,\n TOKEN_PROGRAM_ID,\n TOKEN_2022_PROGRAM_ID,\n authority,\n ...optionalMintKeys,\n ],\n });\n\n const instructions = [createInstruction, extendInstruction];\n\n if (remainingAccounts && remainingAccounts.length > 0) {\n for (let i = 0; i < remainingAccounts.length; i += 25) {\n const chunk = remainingAccounts.slice(i, i + 25);\n const extendIx = AddressLookupTableProgram.extendLookupTable({\n payer,\n authority,\n lookupTable: lookupTableAddress,\n addresses: chunk,\n });\n instructions.push(extendIx);\n }\n }\n\n return {\n instructions,\n address: lookupTableAddress,\n };\n }\n\n /**\n * Create compress instruction\n *\n * @param payer Fee payer.\n * @param owner Owner of uncompressed token account.\n * @param source Source SPL Token account address.\n * @param toAddress Recipient owner address(es).\n * @param amount Amount of tokens to compress.\n * @param mint SPL Token mint address.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The compress instruction\n */\n static async compress({\n payer,\n owner,\n source,\n toAddress,\n amount,\n mint,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: CompressParams): Promise<TransactionInstruction> {\n let tokenTransferOutputs: TokenTransferOutputData[];\n\n const amountArray = toArray<BN | number>(amount);\n const toAddressArray = toArray(toAddress);\n\n checkTokenPoolInfo(tokenPoolInfo, mint);\n\n if (amountArray.length !== toAddressArray.length) {\n throw new Error(\n 'Amount and toAddress arrays must have the same length',\n );\n }\n if (featureFlags.isV2()) {\n const [index, bump] = this.findTokenPoolIndexAndBump(\n tokenPoolInfo.tokenPoolPda,\n mint,\n );\n const rawData: BatchCompressInstructionData = {\n pubkeys: toAddressArray,\n amounts:\n amountArray.length > 1\n ? amountArray.map(amt => bn(amt))\n : null,\n lamports: null,\n amount: amountArray.length === 1 ? bn(amountArray[0]) : null,\n index,\n bump,\n };\n\n const data = encodeBatchCompressInstructionData(rawData);\n const keys = mintToAccountsLayout({\n mint,\n feePayer: payer,\n authority: owner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n tokenProgram: tokenPoolInfo.tokenProgram,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n lightSystemProgram: LightSystemProgram.programId,\n ...defaultStaticAccountsStruct(),\n merkleTree: outputStateTreeInfo.queue,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n solPoolPda: null,\n });\n keys.push({\n pubkey: source,\n isWritable: true,\n isSigner: false,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n } else {\n tokenTransferOutputs = amountArray.map((amt, index) => {\n const amountBN = bn(amt);\n return {\n owner: toAddressArray[index],\n amount: amountBN,\n lamports: null,\n tlv: null,\n };\n });\n\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts: [],\n outputStateTreeInfo,\n rootIndices: [],\n tokenTransferOutputs,\n });\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: null,\n mint,\n delegatedTransfer: null,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: Array.isArray(amount)\n ? amount\n .map(amt => bn(amt))\n .reduce((sum, amt) => sum.add(amt), bn(0))\n : bn(amount),\n isCompress: true,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n const keys = transferAccountsLayout({\n ...defaultStaticAccountsStruct(),\n feePayer: payer,\n authority: owner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n compressOrDecompressTokenAccount: source,\n tokenProgram: tokenPoolInfo.tokenProgram,\n });\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n }\n\n /**\n * Construct decompress instruction\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Destination **uncompressed** token\n * account address. (ATA)\n * @param amount Amount of tokens to decompress.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n * @param tokenPoolInfos Token pool info.\n *\n * @returns The decompress instruction\n */\n static async decompress({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n tokenPoolInfos,\n }: DecompressParams): Promise<TransactionInstruction> {\n const amountBN = bn(amount);\n const tokenPoolInfosArray = toArray(tokenPoolInfos);\n\n const tokenTransferOutputs = createDecompressOutputState(\n inputCompressedTokenAccounts,\n amountBN,\n );\n\n /// Pack\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: tokenTransferOutputs,\n remainingAccounts: tokenPoolInfosArray\n .slice(1)\n .map(info => info.tokenPoolPda),\n });\n\n const { mint } = parseTokenData(inputCompressedTokenAccounts);\n const { delegatedTransfer, authority } = parseMaybeDelegatedTransfer(\n inputCompressedTokenAccounts,\n tokenTransferOutputs,\n );\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: recentValidityProof,\n mint,\n delegatedTransfer,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: amountBN,\n isCompress: false,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n const tokenProgram = tokenPoolInfosArray[0].tokenProgram;\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = transferAccountsLayout({\n feePayer: payer,\n authority: authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: tokenPoolInfosArray[0].tokenPoolPda,\n compressOrDecompressTokenAccount: toAddress,\n tokenProgram,\n systemProgram: SystemProgram.programId,\n });\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create `mergeTokenAccounts` instruction\n *\n * @param payer Fee payer.\n * @param owner Owner of the compressed token\n * accounts to be merged.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param mint SPL Token mint address.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async mergeTokenAccounts({\n payer,\n owner,\n inputCompressedTokenAccounts,\n mint,\n recentValidityProof,\n recentInputStateRootIndices,\n }: MergeTokenAccountsParams): Promise<TransactionInstruction[]> {\n if (inputCompressedTokenAccounts.length > 4) {\n throw new Error('Cannot merge more than 4 token accounts at once');\n }\n\n checkMint(inputCompressedTokenAccounts, mint);\n\n const ix = await this.transfer({\n payer,\n inputCompressedTokenAccounts,\n toAddress: owner,\n amount: inputCompressedTokenAccounts.reduce(\n (sum, account) => sum.add(account.parsed.amount),\n bn(0),\n ),\n recentInputStateRootIndices,\n recentValidityProof,\n });\n\n return [ix];\n }\n\n /**\n * Create `compressSplTokenAccount` instruction\n *\n * @param feePayer Fee payer.\n * @param authority SPL Token account owner.\n * @param tokenAccount SPL Token account to compress.\n * @param mint SPL Token mint address.\n * @param remainingAmount Optional: Amount to leave in token account.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns instruction\n */\n static async compressSplTokenAccount({\n feePayer,\n authority,\n tokenAccount,\n mint,\n remainingAmount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: CompressSplTokenAccountParams): Promise<TransactionInstruction> {\n checkTokenPoolInfo(tokenPoolInfo, mint);\n const remainingAccountMetas: AccountMeta[] = [\n {\n pubkey:\n outputStateTreeInfo.treeType === TreeType.StateV2\n ? outputStateTreeInfo.queue\n : outputStateTreeInfo.tree,\n isSigner: false,\n isWritable: true,\n },\n ];\n\n const data = encodeCompressSplTokenAccountInstructionData({\n owner: authority,\n remainingAmount: remainingAmount ?? null,\n cpiContext: null,\n });\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = transferAccountsLayout({\n feePayer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n compressOrDecompressTokenAccount: tokenAccount,\n tokenProgram: tokenPoolInfo.tokenProgram,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Get the program ID for a mint\n *\n * @param mint SPL Token mint address.\n * @param connection Connection.\n *\n * @returns program ID\n */\n static async getMintProgramId(\n mint: PublicKey,\n connection: Connection,\n ): Promise<PublicKey | undefined> {\n return (await connection.getAccountInfo(mint))?.owner;\n }\n\n /**\n * Create `approve` instruction to delegate compressed tokens.\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Owner to delegate to.\n * @param amount Amount of tokens to delegate.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async approve({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n }: ApproveParams): Promise<TransactionInstruction> {\n const { inputTokenDataWithContext, remainingAccountMetas } =\n packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: [],\n });\n\n const { mint, currentOwner } = parseTokenData(\n inputCompressedTokenAccounts,\n );\n\n const CHANGE_INDEX =\n inputCompressedTokenAccounts[0].compressedAccount.treeInfo\n .treeType === TreeType.StateV2\n ? 1\n : 0;\n\n const rawData: CompressedTokenInstructionDataApprove = {\n proof: recentValidityProof,\n mint,\n inputTokenDataWithContext,\n cpiContext: null,\n delegate: toAddress,\n delegatedAmount: bn(amount),\n delegateMerkleTreeIndex: CHANGE_INDEX,\n changeAccountMerkleTreeIndex: CHANGE_INDEX,\n delegateLamports: null,\n };\n\n const data = encodeApproveInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = approveAccountsLayout({\n feePayer: payer,\n authority: currentOwner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create `revoke` instruction to revoke delegation of compressed tokens.\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async revoke({\n payer,\n inputCompressedTokenAccounts,\n recentValidityProof,\n recentInputStateRootIndices,\n }: RevokeParams): Promise<TransactionInstruction> {\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const { inputTokenDataWithContext, remainingAccountMetas } =\n packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: [],\n });\n\n const { mint, currentOwner } = parseTokenData(\n inputCompressedTokenAccounts,\n );\n\n const rawData: CompressedTokenInstructionDataRevoke = {\n proof: recentValidityProof,\n mint,\n inputTokenDataWithContext,\n cpiContext: null,\n outputAccountMerkleTreeIndex:\n inputCompressedTokenAccounts[0].compressedAccount.treeInfo\n .treeType === TreeType.StateV2\n ? 2\n : 1,\n };\n const data = encodeRevokeInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n const keys = revokeAccountsLayout({\n feePayer: payer,\n authority: currentOwner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n selectMinCompressedTokenAccountsForTransfer,\n selectTokenAccountsForApprove,\n} from '../utils';\n\n/**\n * Approve a delegate to spend tokens\n *\n * @param rpc Rpc to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to delegate\n * @param owner Owner of the SPL token account.\n * @param delegate Address of the delegate\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function approve(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n delegate: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectTokenAccountsForApprove(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.approve({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress: delegate,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n toArray,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\nimport { getOrCreateAssociatedTokenAccount } from '@solana/spl-token';\n\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Mint compressed tokens to a solana address from an external mint authority\n *\n * @param rpc Rpc to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param toPubkey Address of the account to mint to\n * @param authority Minting authority\n * @param amount Amount to mint\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be inserted into. Defaults to a\n * shared state tree account.\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function approveAndMintTo(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n toPubkey: PublicKey,\n authority: Signer,\n amount: number | BN,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const authorityTokenAccount = await getOrCreateAssociatedTokenAccount(\n rpc,\n payer,\n mint,\n authority.publicKey,\n undefined,\n undefined,\n confirmOptions,\n tokenPoolInfo.tokenProgram,\n );\n\n const ixs = await CompressedTokenProgram.approveAndMintTo({\n feePayer: payer.publicKey,\n mint,\n authority: authority.publicKey,\n authorityTokenAccount: authorityTokenAccount.address,\n amount,\n toPubkey,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [authority]);\n\n const tx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 150_000 + toArray(amount).length * 20_000,\n }),\n ...ixs,\n ],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, tx, confirmOptions);\n}\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n toArray,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Compress SPL tokens\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to compress.\n * @param owner Owner of the SPL token account.\n * @param sourceTokenAccount Source SPL token account. (ATA)\n * @param toAddress Recipient owner address.\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be inserted into. Defaults to a\n * shared state tree account.\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function compress(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN | number[] | BN[],\n owner: Signer,\n sourceTokenAccount: PublicKey,\n toAddress: PublicKey | Array<PublicKey>,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const compressIx = await CompressedTokenProgram.compress({\n payer: payer.publicKey,\n owner: owner.publicKey,\n source: sourceTokenAccount,\n toAddress,\n amount,\n mint,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const blockhashCtx = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 130_000 + toArray(amount).length * 20_000,\n }),\n compressIx,\n ],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);\n}\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Compress SPL tokens into compressed token format\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param owner Owner of the token account\n * @param tokenAccount Token account to compress\n * @param remainingAmount Optional: amount to leave in token account.\n * Default: 0\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * account into\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n\n *\n * @return Signature of the confirmed transaction\n */\nexport async function compressSplTokenAccount(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: Signer,\n tokenAccount: PublicKey,\n remainingAmount?: BN,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const compressIx = await CompressedTokenProgram.compressSplTokenAccount({\n feePayer: payer.publicKey,\n authority: owner.publicKey,\n tokenAccount,\n mint,\n remainingAmount,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const blockhashCtx = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const signedTx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 150_000,\n }),\n compressIx,\n ],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);\n}\n","import {\n ConfirmOptions,\n Keypair,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n MINT_SIZE,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n} from '@solana/spl-token';\nimport {\n Rpc,\n buildAndSignTx,\n dedupeSigner,\n sendAndConfirmTx,\n} from '@lightprotocol/stateless.js';\n\n/**\n * Create and initialize a new compressed token mint\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mintAuthority Account that will control minting\n * @param decimals Location of the decimal place\n * @param keypair Optional: Mint keypair. Defaults to a random\n * keypair.\n * @param confirmOptions Options for confirming the transaction\n * @param tokenProgramId Optional: Program ID for the token. Defaults to\n * TOKEN_PROGRAM_ID.\n * @param freezeAuthority Optional: Account that will control freeze and thaw.\n * Defaults to none.\n *\n * @return Object with mint address and transaction signature\n */\nexport async function createMint(\n rpc: Rpc,\n payer: Signer,\n mintAuthority: PublicKey | Signer,\n decimals: number,\n keypair = Keypair.generate(),\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey | boolean,\n freezeAuthority?: PublicKey | Signer,\n): Promise<{ mint: PublicKey; transactionSignature: TransactionSignature }> {\n const rentExemptBalance =\n await rpc.getMinimumBalanceForRentExemption(MINT_SIZE);\n\n // If true, uses TOKEN_2022_PROGRAM_ID.\n // If false or undefined, defaults to TOKEN_PROGRAM_ID.\n // Otherwise, uses the provided tokenProgramId.\n const resolvedTokenProgramId =\n tokenProgramId === true\n ? TOKEN_2022_PROGRAM_ID\n : tokenProgramId || TOKEN_PROGRAM_ID;\n\n const ixs = await CompressedTokenProgram.createMint({\n feePayer: payer.publicKey,\n mint: keypair.publicKey,\n decimals,\n authority:\n 'secretKey' in mintAuthority\n ? mintAuthority.publicKey\n : mintAuthority,\n freezeAuthority:\n freezeAuthority && 'secretKey' in freezeAuthority\n ? freezeAuthority.publicKey\n : (freezeAuthority ?? null),\n rentExemptBalance,\n tokenProgramId: resolvedTokenProgramId,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const additionalSigners = dedupeSigner(\n payer,\n [mintAuthority, freezeAuthority].filter(\n (signer): signer is Signer =>\n signer != undefined && 'secretKey' in signer,\n ),\n );\n\n const tx = buildAndSignTx(ixs, payer, blockhash, [\n ...additionalSigners,\n keypair,\n ]);\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return { mint: keypair.publicKey, transactionSignature: txId };\n}\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionInstruction,\n TransactionSignature,\n} from '@solana/web3.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n Rpc,\n buildAndSignTx,\n sendAndConfirmTx,\n} from '@lightprotocol/stateless.js';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Register an existing mint with the CompressedToken program\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param confirmOptions Options for confirming the transaction\n * @param tokenProgramId Optional: Address of the token program. Default:\n * TOKEN_PROGRAM_ID\n *\n * @return transaction signature\n */\nexport async function createTokenPool(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey,\n): Promise<TransactionSignature> {\n tokenProgramId = tokenProgramId\n ? tokenProgramId\n : await CompressedTokenProgram.getMintProgramId(mint, rpc);\n\n const ix = await CompressedTokenProgram.createTokenPool({\n feePayer: payer.publicKey,\n mint,\n tokenProgramId,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const tx = buildAndSignTx([ix], payer, blockhash);\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n\n/**\n * Create additional token pools for an existing mint\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param numMaxAdditionalPools Number of additional token pools to create. Max\n * 3.\n * @param confirmOptions Optional: Options for confirming the transaction\n * @param tokenProgramId Optional: Address of the token program. Default:\n * TOKEN_PROGRAM_ID\n *\n * @return transaction signature\n */\nexport async function addTokenPools(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n numMaxAdditionalPools: number,\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey,\n) {\n tokenProgramId = tokenProgramId\n ? tokenProgramId\n : await CompressedTokenProgram.getMintProgramId(mint, rpc);\n const instructions: TransactionInstruction[] = [];\n\n const infos = (await getTokenPoolInfos(rpc, mint)).slice(0, 4);\n\n // Get indices of uninitialized pools\n const uninitializedIndices = [];\n for (let i = 0; i < infos.length; i++) {\n if (!infos[i].isInitialized) {\n uninitializedIndices.push(i);\n }\n }\n\n // Create instructions for requested number of pools\n for (let i = 0; i < numMaxAdditionalPools; i++) {\n if (i >= uninitializedIndices.length) {\n break;\n }\n\n instructions.push(\n await CompressedTokenProgram.addTokenPool({\n mint,\n feePayer: payer.publicKey,\n tokenProgramId,\n poolIndex: uninitializedIndices[i],\n }),\n );\n }\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const tx = buildAndSignTx(instructions, payer, blockhash);\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n","import { PublicKey, Signer, TransactionSignature } from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\n\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Create a lookup table for the token program's default accounts\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param authority Authority of the lookup table\n * @param mints Optional array of mint public keys to include in\n * the lookup table\n * @param additionalAccounts Optional array of additional account public keys\n * to include in the lookup table\n *\n * @return Object with transaction signatures and the address of the created\n * lookup table\n */\nexport async function createTokenProgramLookupTable(\n rpc: Rpc,\n payer: Signer,\n authority: Signer,\n mints?: PublicKey[],\n additionalAccounts?: PublicKey[],\n): Promise<{ txIds: TransactionSignature[]; address: PublicKey }> {\n const recentSlot = await rpc.getSlot('finalized');\n const { instructions, address } =\n await CompressedTokenProgram.createTokenProgramLookupTable({\n payer: payer.publicKey,\n authority: authority.publicKey,\n mints,\n remainingAccounts: additionalAccounts,\n recentSlot,\n });\n\n const additionalSigners = dedupeSigner(payer, [authority]);\n const txIds = [];\n\n for (const instruction of instructions) {\n const blockhashCtx = await rpc.getLatestBlockhash();\n const signedTx = buildAndSignTx(\n [instruction],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n const txId = await sendAndConfirmTx(\n rpc,\n signedTx,\n { commitment: 'finalized' },\n blockhashCtx,\n );\n txIds.push(txId);\n }\n\n return { txIds, address };\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\nimport {\n selectTokenPoolInfosForDecompression,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Decompress compressed tokens\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination **uncompressed** token account\n * address. (ATA)\n * @param tokenPoolInfos Optional: Token pool infos.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function decompress(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n tokenPoolInfos?: TokenPoolInfo[],\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n tokenPoolInfos = tokenPoolInfos ?? (await getTokenPoolInfos(rpc, mint));\n\n const selectedTokenPoolInfos = selectTokenPoolInfosForDecompression(\n tokenPoolInfos,\n amount,\n );\n\n const ix = await CompressedTokenProgram.decompress({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n tokenPoolInfos: selectedTokenPoolInfos,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n Rpc,\n dedupeSigner,\n buildAndSignTx,\n sendAndConfirmTx,\n bn,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Merge multiple compressed token accounts for a given mint into a single\n * account\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param owner Owner of the token accounts to be merged\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function mergeTokenAccounts(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: Signer,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n { mint },\n );\n\n if (compressedTokenAccounts.items.length === 0) {\n throw new Error(\n `No compressed token accounts found for mint ${mint.toBase58()}`,\n );\n }\n\n const instructions = [\n ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }),\n ];\n\n for (\n let i = 0;\n i < compressedTokenAccounts.items.slice(0, 8).length;\n i += 4\n ) {\n const batch = compressedTokenAccounts.items.slice(i, i + 4);\n\n const proof = await rpc.getValidityProof(\n batch.map(account => bn(account.compressedAccount.hash)),\n );\n\n const batchInstructions =\n await CompressedTokenProgram.mergeTokenAccounts({\n payer: payer.publicKey,\n owner: owner.publicKey,\n inputCompressedTokenAccounts: batch,\n mint,\n recentValidityProof: proof.compressedProof,\n recentInputStateRootIndices: proof.rootIndices,\n });\n\n instructions.push(...batchInstructions);\n }\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const signedTx = buildAndSignTx(\n instructions,\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Mint compressed tokens to a solana address\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param toPubkey Address of the account to mint to. Can be an\n * array of addresses if the amount is an array of\n * amounts.\n * @param authority Mint authority\n * @param amount Amount to mint. Pass an array of amounts if the\n * toPubkey is an array of addresses.\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be part of. Defaults to the\n * default state tree account.\n * @param tokenPoolInfo Optional: Token pool information\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function mintTo(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n toPubkey: PublicKey | PublicKey[],\n authority: Signer,\n amount: number | BN | number[] | BN[],\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const ix = await CompressedTokenProgram.mintTo({\n feePayer: payer.publicKey,\n mint,\n authority: authority.publicKey,\n amount,\n toPubkey,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [authority]);\n\n const tx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, tx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n ParsedTokenAccount,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Revoke one or more delegated token accounts\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param accounts Delegated compressed token accounts to revoke\n * @param owner Owner of the compressed tokens\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function revoke(\n rpc: Rpc,\n payer: Signer,\n accounts: ParsedTokenAccount[],\n owner: Signer,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n const proof = await rpc.getValidityProofV0(\n accounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n checkOwner(owner, accounts);\n checkIsDelegated(accounts);\n\n const ix = await CompressedTokenProgram.revoke({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: accounts,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n\nfunction checkOwner(owner: Signer, accounts: ParsedTokenAccount[]) {\n if (!owner.publicKey.equals(accounts[0].parsed.owner)) {\n throw new Error(\n `Owner ${owner.publicKey.toBase58()} does not match account ${accounts[0].parsed.owner.toBase58()}`,\n );\n }\n}\n\nfunction checkIsDelegated(accounts: ParsedTokenAccount[]) {\n if (accounts.some(account => account.parsed.delegate === null)) {\n throw new Error('Account is not delegated');\n }\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n StateTreeInfo,\n selectStateTreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\n\n/**\n * Transfer compressed tokens from one owner to another\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination address of the recipient\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function transfer(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.transfer({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\n\n/**\n * Transfer delegated compressed tokens to another owner\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination address of the recipient\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function transferDelegated(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts =\n await rpc.getCompressedTokenAccountsByDelegate(owner.publicKey, {\n mint,\n });\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.transfer({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\n\nimport BN from 'bn.js';\n\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\nimport {\n selectTokenPoolInfosForDecompression,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Decompress delegated compressed tokens. Remaining compressed tokens are\n * returned to the owner without delegation.\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to decompress\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination **uncompressed** token account\n * address. (ATA)\n * @param tokenPoolInfos Optional: Token pool infos.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function decompressDelegated(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n tokenPoolInfos?: TokenPoolInfo[],\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n\n const compressedTokenAccounts =\n await rpc.getCompressedTokenAccountsByDelegate(owner.publicKey, {\n mint,\n });\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const tokenPoolInfosToUse =\n tokenPoolInfos ??\n selectTokenPoolInfosForDecompression(\n await getTokenPoolInfos(rpc, mint),\n amount,\n );\n\n const ix = await CompressedTokenProgram.decompress({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n tokenPoolInfos: tokenPoolInfosToUse,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","export type LightCompressedToken = {\n version: '1.2.0';\n name: 'light_compressed_token';\n instructions: [\n {\n name: 'createTokenPool';\n docs: [\n 'This instruction creates a token pool for a given mint. Every spl mint',\n 'can have one token pool. When a token is compressed the tokens are',\n 'transferrred to the token pool, and their compressed equivalent is',\n 'minted into a Merkle tree.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [];\n },\n {\n name: 'addTokenPool';\n docs: [\n 'This instruction creates an additional token pool for a given mint.',\n 'The maximum number of token pools per mint is 5.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'existingTokenPoolPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'tokenPoolIndex';\n type: 'u8';\n },\n ];\n },\n {\n name: 'mintTo';\n docs: [\n 'Mints tokens from an spl token mint to a list of compressed accounts.',\n 'Minted tokens are transferred to a pool account owned by the compressed',\n 'token program. The instruction creates one compressed output account for',\n 'every amount and pubkey input pair. A constant amount of lamports can be',\n 'transferred to each output account to enable. A use case to add lamports',\n 'to a compressed token account is to prevent spam. This is the only way',\n 'to add lamports to a compressed token account.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n docs: ['programs'];\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'merkleTree';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'solPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n ];\n args: [\n {\n name: 'publicKeys';\n type: {\n vec: 'publicKey';\n };\n },\n {\n name: 'amounts';\n type: {\n vec: 'u64';\n };\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n ];\n },\n {\n name: 'compressSplTokenAccount';\n docs: [\n 'Compresses the balance of an spl token account sub an optional remaining',\n 'amount. This instruction does not close the spl token account. To close',\n 'the account bundle a close spl account instruction in your transaction.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'remainingAmount';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n ];\n },\n {\n name: 'transfer';\n docs: [\n 'Transfers compressed tokens from one account to another. All accounts',\n 'must be of the same mint. Additional spl tokens can be compressed or',\n 'decompressed. In one transaction only compression or decompression is',\n 'possible. Lamports can be transferred alongside tokens. If output token',\n 'accounts specify less lamports than inputs the remaining lamports are',\n 'transferred to an output compressed account. Signer must be owner or',\n 'delegate. If a delegated token account is transferred the delegate is',\n 'not preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'approve';\n docs: [\n 'Delegates an amount to a delegate. A compressed token account is either',\n 'completely delegated or not. Prior delegates are not preserved. Cannot',\n 'be called by a delegate.',\n 'The instruction creates two output accounts:',\n '1. one account with delegated amount',\n '2. one account with remaining(change) amount',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'revoke';\n docs: [\n 'Revokes a delegation. The instruction merges all inputs into one output',\n 'account. Cannot be called by a delegate. Delegates are not preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'freeze';\n docs: [\n 'Freezes compressed token accounts. Inputs must not be frozen. Creates as',\n 'many outputs as inputs. Balances and delegates are preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['that this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'thaw';\n docs: [\n 'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',\n 'as many outputs as inputs. Balances and delegates are preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['that this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'burn';\n docs: [\n 'Burns compressed tokens and spl tokens from the pool account. Delegates',\n 'can burn tokens. The output compressed token account remains delegated.',\n 'Creates one output compressed token account.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'stubIdlBuild';\n docs: [\n 'This function is a stub to allow Anchor to include the input types in',\n 'the IDL. It should not be included in production builds nor be called in',\n 'practice.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs1';\n type: {\n defined: 'CompressedTokenInstructionDataTransfer';\n };\n },\n {\n name: 'inputs2';\n type: {\n defined: 'TokenData';\n };\n },\n ];\n },\n ];\n types: [\n {\n name: 'AccountState';\n type: {\n kind: 'enum';\n variants: [\n {\n name: 'Initialized';\n },\n {\n name: 'Frozen';\n },\n ];\n };\n },\n {\n name: 'CompressedAccount';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'lamports';\n type: 'u64';\n },\n {\n name: 'address';\n type: {\n option: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'data';\n type: {\n option: {\n defined: 'CompressedAccountData';\n };\n };\n },\n ];\n };\n },\n {\n name: 'CompressedAccountData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'discriminator';\n type: {\n array: ['u8', 8];\n };\n },\n {\n name: 'data';\n type: 'bytes';\n },\n {\n name: 'dataHash';\n type: {\n array: ['u8', 32];\n };\n },\n ];\n };\n },\n {\n name: 'CompressedCpiContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'setContext';\n docs: [\n 'Is set by the program that is invoking the CPI to signal that is should',\n 'set the cpi context.',\n ];\n type: 'bool';\n },\n {\n name: 'firstSetContext';\n docs: [\n 'Is set to wipe the cpi context since someone could have set it before',\n 'with unrelated data.',\n ];\n type: 'bool';\n },\n {\n name: 'cpiContextAccountIndex';\n docs: [\n 'Index of cpi context account in remaining accounts.',\n ];\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'CompressedProof';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'a';\n type: {\n array: ['u8', 32];\n };\n },\n {\n name: 'b';\n type: {\n array: ['u8', 64];\n };\n },\n {\n name: 'c';\n type: {\n array: ['u8', 32];\n };\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataTransfer';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'delegatedTransfer';\n docs: [\n 'Is required if the signer is delegate,',\n '-> delegate is authority account,',\n 'owner = Some(owner) is the owner of the token account.',\n ];\n type: {\n option: {\n defined: 'DelegatedTransfer';\n };\n };\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'PackedTokenTransferOutputData';\n };\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'compressOrDecompressAmount';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'lamportsChangeAccountMerkleTreeIndex';\n type: {\n option: 'u8';\n };\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataRevoke';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'outputAccountMerkleTreeIndex';\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataApprove';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'delegate';\n type: 'publicKey';\n },\n {\n name: 'delegatedAmount';\n type: 'u64';\n },\n {\n name: 'delegateMerkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'changeAccountMerkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'delegateLamports';\n type: {\n option: 'u64';\n };\n },\n ];\n };\n },\n {\n name: 'DelegatedTransfer';\n docs: [\n 'Struct to provide the owner when the delegate is signer of the transaction.',\n ];\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'delegateChangeAccountIndex';\n docs: [\n 'Index of change compressed account in output compressed accounts. In',\n \"case that the delegate didn't spend the complete delegated compressed\",\n 'account balance the change compressed account will be delegated to her',\n 'as well.',\n ];\n type: {\n option: 'u8';\n };\n },\n ];\n };\n },\n {\n name: 'InputTokenDataWithContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'amount';\n type: 'u64';\n },\n {\n name: 'delegateIndex';\n type: {\n option: 'u8';\n };\n },\n {\n name: 'merkleContext';\n type: {\n defined: 'PackedMerkleContext';\n };\n },\n {\n name: 'rootIndex';\n type: 'u16';\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'InstructionDataInvoke';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext';\n type: {\n vec: {\n defined: 'PackedCompressedAccountWithMerkleContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'newAddressParams';\n type: {\n vec: {\n defined: 'NewAddressParamsPacked';\n };\n };\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'InstructionDataInvokeCpi';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'newAddressParams';\n type: {\n vec: {\n defined: 'NewAddressParamsPacked';\n };\n };\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext';\n type: {\n vec: {\n defined: 'PackedCompressedAccountWithMerkleContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n ];\n };\n },\n {\n name: 'MerkleTreeSequenceNumber';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'pubkey';\n type: 'publicKey';\n },\n {\n name: 'seq';\n type: 'u64';\n },\n ];\n };\n },\n {\n name: 'NewAddressParamsPacked';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'seed';\n type: {\n array: ['u8', 32];\n };\n },\n {\n name: 'addressQueueAccountIndex';\n type: 'u8';\n },\n {\n name: 'addressMerkleTreeAccountIndex';\n type: 'u8';\n },\n {\n name: 'addressMerkleTreeRootIndex';\n type: 'u16';\n },\n ];\n };\n },\n {\n name: 'OutputCompressedAccountWithPackedContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'compressedAccount';\n type: {\n defined: 'CompressedAccount';\n };\n },\n {\n name: 'merkleTreeIndex';\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'PackedCompressedAccountWithMerkleContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'compressedAccount';\n type: {\n defined: 'CompressedAccount';\n };\n },\n {\n name: 'merkleContext';\n type: {\n defined: 'PackedMerkleContext';\n };\n },\n {\n name: 'rootIndex';\n docs: [\n 'Index of root used in inclusion validity proof.',\n ];\n type: 'u16';\n },\n {\n name: 'readOnly';\n docs: [\n 'Placeholder to mark accounts read-only unimplemented set to false.',\n ];\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'PackedMerkleContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'merkleTreePubkeyIndex';\n type: 'u8';\n },\n {\n name: 'queuePubkeyIndex';\n type: 'u8';\n },\n {\n name: 'leafIndex';\n type: 'u32';\n },\n {\n name: 'proveByIndex';\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'PackedTokenTransferOutputData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'amount';\n type: 'u64';\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'merkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'PublicTransactionEvent';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'inputCompressedAccountHashes';\n type: {\n vec: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'outputCompressedAccountHashes';\n type: {\n vec: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'outputLeafIndices';\n type: {\n vec: 'u32';\n };\n },\n {\n name: 'sequenceNumbers';\n type: {\n vec: {\n defined: 'MerkleTreeSequenceNumber';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'pubkeyArray';\n type: {\n vec: 'publicKey';\n };\n },\n {\n name: 'message';\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'QueueIndex';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'queueId';\n docs: ['Id of queue in queue account.'];\n type: 'u8';\n },\n {\n name: 'index';\n docs: ['Index of compressed account hash in queue.'];\n type: 'u16';\n },\n ];\n };\n },\n {\n name: 'TokenData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'mint';\n docs: ['The mint associated with this account'];\n type: 'publicKey';\n },\n {\n name: 'owner';\n docs: ['The owner of this account.'];\n type: 'publicKey';\n },\n {\n name: 'amount';\n docs: ['The amount of tokens this account holds.'];\n type: 'u64';\n },\n {\n name: 'delegate';\n docs: [\n 'If `delegate` is `Some` then `delegated_amount` represents',\n 'the amount authorized by the delegate',\n ];\n type: {\n option: 'publicKey';\n };\n },\n {\n name: 'state';\n docs: [\"The account's state\"];\n type: {\n defined: 'AccountState';\n };\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n ];\n errors: [\n {\n code: 6000;\n name: 'PublicKeyAmountMissmatch';\n msg: 'public keys and amounts must be of same length';\n },\n {\n code: 6001;\n name: 'ComputeInputSumFailed';\n msg: 'ComputeInputSumFailed';\n },\n {\n code: 6002;\n name: 'ComputeOutputSumFailed';\n msg: 'ComputeOutputSumFailed';\n },\n {\n code: 6003;\n name: 'ComputeCompressSumFailed';\n msg: 'ComputeCompressSumFailed';\n },\n {\n code: 6004;\n name: 'ComputeDecompressSumFailed';\n msg: 'ComputeDecompressSumFailed';\n },\n {\n code: 6005;\n name: 'SumCheckFailed';\n msg: 'SumCheckFailed';\n },\n {\n code: 6006;\n name: 'DecompressRecipientUndefinedForDecompress';\n msg: 'DecompressRecipientUndefinedForDecompress';\n },\n {\n code: 6007;\n name: 'CompressedPdaUndefinedForDecompress';\n msg: 'CompressedPdaUndefinedForDecompress';\n },\n {\n code: 6008;\n name: 'DeCompressAmountUndefinedForDecompress';\n msg: 'DeCompressAmountUndefinedForDecompress';\n },\n {\n code: 6009;\n name: 'CompressedPdaUndefinedForCompress';\n msg: 'CompressedPdaUndefinedForCompress';\n },\n {\n code: 6010;\n name: 'DeCompressAmountUndefinedForCompress';\n msg: 'DeCompressAmountUndefinedForCompress';\n },\n {\n code: 6011;\n name: 'DelegateSignerCheckFailed';\n msg: 'DelegateSignerCheckFailed';\n },\n {\n code: 6012;\n name: 'MintTooLarge';\n msg: 'Minted amount greater than u64::MAX';\n },\n {\n code: 6013;\n name: 'SplTokenSupplyMismatch';\n msg: 'SplTokenSupplyMismatch';\n },\n {\n code: 6014;\n name: 'HeapMemoryCheckFailed';\n msg: 'HeapMemoryCheckFailed';\n },\n {\n code: 6015;\n name: 'InstructionNotCallable';\n msg: 'The instruction is not callable';\n },\n {\n code: 6016;\n name: 'ArithmeticUnderflow';\n msg: 'ArithmeticUnderflow';\n },\n {\n code: 6017;\n name: 'HashToFieldError';\n msg: 'HashToFieldError';\n },\n {\n code: 6018;\n name: 'InvalidAuthorityMint';\n msg: 'Expected the authority to be also a mint authority';\n },\n {\n code: 6019;\n name: 'InvalidFreezeAuthority';\n msg: 'Provided authority is not the freeze authority';\n },\n {\n code: 6020;\n name: 'InvalidDelegateIndex';\n },\n {\n code: 6021;\n name: 'TokenPoolPdaUndefined';\n },\n {\n code: 6022;\n name: 'IsTokenPoolPda';\n msg: 'Compress or decompress recipient is the same account as the token pool pda.';\n },\n {\n code: 6023;\n name: 'InvalidTokenPoolPda';\n },\n {\n code: 6024;\n name: 'NoInputTokenAccountsProvided';\n },\n {\n code: 6025;\n name: 'NoInputsProvided';\n },\n {\n code: 6026;\n name: 'MintHasNoFreezeAuthority';\n },\n {\n code: 6027;\n name: 'MintWithInvalidExtension';\n },\n {\n code: 6028;\n name: 'InsufficientTokenAccountBalance';\n msg: 'The token account balance is less than the remaining amount.';\n },\n {\n code: 6029;\n name: 'InvalidTokenPoolBump';\n msg: 'Max number of token pools reached.';\n },\n {\n code: 6030;\n name: 'FailedToDecompress';\n },\n {\n code: 6031;\n name: 'FailedToBurnSplTokensFromTokenPool';\n },\n {\n code: 6032;\n name: 'NoMatchingBumpFound';\n },\n ];\n};\nexport const IDL: LightCompressedToken = {\n version: '1.2.0',\n name: 'light_compressed_token',\n instructions: [\n {\n name: 'createTokenPool',\n docs: [\n 'This instruction creates a token pool for a given mint. Every spl mint',\n 'can have one token pool. When a token is compressed the tokens are',\n 'transferrred to the token pool, and their compressed equivalent is',\n 'minted into a Merkle tree.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [],\n },\n {\n name: 'addTokenPool',\n docs: [\n 'This instruction creates an additional token pool for a given mint.',\n 'The maximum number of token pools per mint is 5.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'existingTokenPoolPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'tokenPoolIndex',\n type: 'u8',\n },\n ],\n },\n {\n name: 'mintTo',\n docs: [\n 'Mints tokens from an spl token mint to a list of compressed accounts.',\n 'Minted tokens are transferred to a pool account owned by the compressed',\n 'token program. The instruction creates one compressed output account for',\n 'every amount and pubkey input pair. A constant amount of lamports can be',\n 'transferred to each output account to enable. A use case to add lamports',\n 'to a compressed token account is to prevent spam. This is the only way',\n 'to add lamports to a compressed token account.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n docs: ['programs'],\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'merkleTree',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'solPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n ],\n args: [\n {\n name: 'publicKeys',\n type: {\n vec: 'publicKey',\n },\n },\n {\n name: 'amounts',\n type: {\n vec: 'u64',\n },\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n ],\n },\n {\n name: 'compressSplTokenAccount',\n docs: [\n 'Compresses the balance of an spl token account sub an optional remaining',\n 'amount. This instruction does not close the spl token account. To close',\n 'the account bundle a close spl account instruction in your transaction.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'remainingAmount',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n ],\n },\n {\n name: 'transfer',\n docs: [\n 'Transfers compressed tokens from one account to another. All accounts',\n 'must be of the same mint. Additional spl tokens can be compressed or',\n 'decompressed. In one transaction only compression or decompression is',\n 'possible. Lamports can be transferred alongside tokens. If output token',\n 'accounts specify less lamports than inputs the remaining lamports are',\n 'transferred to an output compressed account. Signer must be owner or',\n 'delegate. If a delegated token account is transferred the delegate is',\n 'not preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'approve',\n docs: [\n 'Delegates an amount to a delegate. A compressed token account is either',\n 'completely delegated or not. Prior delegates are not preserved. Cannot',\n 'be called by a delegate.',\n 'The instruction creates two output accounts:',\n '1. one account with delegated amount',\n '2. one account with remaining(change) amount',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'revoke',\n docs: [\n 'Revokes a delegation. The instruction merges all inputs into one output',\n 'account. Cannot be called by a delegate. Delegates are not preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'freeze',\n docs: [\n 'Freezes compressed token accounts. Inputs must not be frozen. Creates as',\n 'many outputs as inputs. Balances and delegates are preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['that this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'thaw',\n docs: [\n 'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',\n 'as many outputs as inputs. Balances and delegates are preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['that this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'burn',\n docs: [\n 'Burns compressed tokens and spl tokens from the pool account. Delegates',\n 'can burn tokens. The output compressed token account remains delegated.',\n 'Creates one output compressed token account.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'stubIdlBuild',\n docs: [\n 'This function is a stub to allow Anchor to include the input types in',\n 'the IDL. It should not be included in production builds nor be called in',\n 'practice.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs1',\n type: {\n defined: 'CompressedTokenInstructionDataTransfer',\n },\n },\n {\n name: 'inputs2',\n type: {\n defined: 'TokenData',\n },\n },\n ],\n },\n ],\n types: [\n {\n name: 'AccountState',\n type: {\n kind: 'enum',\n variants: [\n {\n name: 'Initialized',\n },\n {\n name: 'Frozen',\n },\n ],\n },\n },\n {\n name: 'CompressedAccount',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'lamports',\n type: 'u64',\n },\n {\n name: 'address',\n type: {\n option: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'data',\n type: {\n option: {\n defined: 'CompressedAccountData',\n },\n },\n },\n ],\n },\n },\n {\n name: 'CompressedAccountData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'discriminator',\n type: {\n array: ['u8', 8],\n },\n },\n {\n name: 'data',\n type: 'bytes',\n },\n {\n name: 'dataHash',\n type: {\n array: ['u8', 32],\n },\n },\n ],\n },\n },\n {\n name: 'CompressedCpiContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'setContext',\n docs: [\n 'Is set by the program that is invoking the CPI to signal that is should',\n 'set the cpi context.',\n ],\n type: 'bool',\n },\n {\n name: 'firstSetContext',\n docs: [\n 'Is set to wipe the cpi context since someone could have set it before',\n 'with unrelated data.',\n ],\n type: 'bool',\n },\n {\n name: 'cpiContextAccountIndex',\n docs: [\n 'Index of cpi context account in remaining accounts.',\n ],\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'CompressedProof',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'a',\n type: {\n array: ['u8', 32],\n },\n },\n {\n name: 'b',\n type: {\n array: ['u8', 64],\n },\n },\n {\n name: 'c',\n type: {\n array: ['u8', 32],\n },\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataTransfer',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'delegatedTransfer',\n docs: [\n 'Is required if the signer is delegate,',\n '-> delegate is authority account,',\n 'owner = Some(owner) is the owner of the token account.',\n ],\n type: {\n option: {\n defined: 'DelegatedTransfer',\n },\n },\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined: 'PackedTokenTransferOutputData',\n },\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'compressOrDecompressAmount',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'lamportsChangeAccountMerkleTreeIndex',\n type: {\n option: 'u8',\n },\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataRevoke',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'outputAccountMerkleTreeIndex',\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataApprove',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'delegate',\n type: 'publicKey',\n },\n {\n name: 'delegatedAmount',\n type: 'u64',\n },\n {\n name: 'delegateMerkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'changeAccountMerkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'delegateLamports',\n type: {\n option: 'u64',\n },\n },\n ],\n },\n },\n {\n name: 'DelegatedTransfer',\n docs: [\n 'Struct to provide the owner when the delegate is signer of the transaction.',\n ],\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'delegateChangeAccountIndex',\n docs: [\n 'Index of change compressed account in output compressed accounts. In',\n \"case that the delegate didn't spend the complete delegated compressed\",\n 'account balance the change compressed account will be delegated to her',\n 'as well.',\n ],\n type: {\n option: 'u8',\n },\n },\n ],\n },\n },\n {\n name: 'InputTokenDataWithContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'amount',\n type: 'u64',\n },\n {\n name: 'delegateIndex',\n type: {\n option: 'u8',\n },\n },\n {\n name: 'merkleContext',\n type: {\n defined: 'PackedMerkleContext',\n },\n },\n {\n name: 'rootIndex',\n type: 'u16',\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'InstructionDataInvoke',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext',\n type: {\n vec: {\n defined:\n 'PackedCompressedAccountWithMerkleContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'newAddressParams',\n type: {\n vec: {\n defined: 'NewAddressParamsPacked',\n },\n },\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'InstructionDataInvokeCpi',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'newAddressParams',\n type: {\n vec: {\n defined: 'NewAddressParamsPacked',\n },\n },\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext',\n type: {\n vec: {\n defined:\n 'PackedCompressedAccountWithMerkleContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n ],\n },\n },\n {\n name: 'MerkleTreeSequenceNumber',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'pubkey',\n type: 'publicKey',\n },\n {\n name: 'seq',\n type: 'u64',\n },\n ],\n },\n },\n {\n name: 'NewAddressParamsPacked',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'seed',\n type: {\n array: ['u8', 32],\n },\n },\n {\n name: 'addressQueueAccountIndex',\n type: 'u8',\n },\n {\n name: 'addressMerkleTreeAccountIndex',\n type: 'u8',\n },\n {\n name: 'addressMerkleTreeRootIndex',\n type: 'u16',\n },\n ],\n },\n },\n {\n name: 'OutputCompressedAccountWithPackedContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'compressedAccount',\n type: {\n defined: 'CompressedAccount',\n },\n },\n {\n name: 'merkleTreeIndex',\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'PackedCompressedAccountWithMerkleContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'compressedAccount',\n type: {\n defined: 'CompressedAccount',\n },\n },\n {\n name: 'merkleContext',\n type: {\n defined: 'PackedMerkleContext',\n },\n },\n {\n name: 'rootIndex',\n docs: [\n 'Index of root used in inclusion validity proof.',\n ],\n type: 'u16',\n },\n {\n name: 'readOnly',\n docs: [\n 'Placeholder to mark accounts read-only unimplemented set to false.',\n ],\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'PackedMerkleContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'merkleTreePubkeyIndex',\n type: 'u8',\n },\n {\n name: 'queuePubkeyIndex',\n type: 'u8',\n },\n {\n name: 'leafIndex',\n type: 'u32',\n },\n {\n name: 'proveByIndex',\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'PackedTokenTransferOutputData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'amount',\n type: 'u64',\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'merkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'PublicTransactionEvent',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'inputCompressedAccountHashes',\n type: {\n vec: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'outputCompressedAccountHashes',\n type: {\n vec: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'outputLeafIndices',\n type: {\n vec: 'u32',\n },\n },\n {\n name: 'sequenceNumbers',\n type: {\n vec: {\n defined: 'MerkleTreeSequenceNumber',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'pubkeyArray',\n type: {\n vec: 'publicKey',\n },\n },\n {\n name: 'message',\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'QueueIndex',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'queueId',\n docs: ['Id of queue in queue account.'],\n type: 'u8',\n },\n {\n name: 'index',\n docs: ['Index of compressed account hash in queue.'],\n type: 'u16',\n },\n ],\n },\n },\n {\n name: 'TokenData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'mint',\n docs: ['The mint associated with this account'],\n type: 'publicKey',\n },\n {\n name: 'owner',\n docs: ['The owner of this account.'],\n type: 'publicKey',\n },\n {\n name: 'amount',\n docs: ['The amount of tokens this account holds.'],\n type: 'u64',\n },\n {\n name: 'delegate',\n docs: [\n 'If `delegate` is `Some` then `delegated_amount` represents',\n 'the amount authorized by the delegate',\n ],\n type: {\n option: 'publicKey',\n },\n },\n {\n name: 'state',\n docs: [\"The account's state\"],\n type: {\n defined: 'AccountState',\n },\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n ],\n errors: [\n {\n code: 6000,\n name: 'PublicKeyAmountMissmatch',\n msg: 'public keys and amounts must be of same length',\n },\n {\n code: 6001,\n name: 'ComputeInputSumFailed',\n msg: 'ComputeInputSumFailed',\n },\n {\n code: 6002,\n name: 'ComputeOutputSumFailed',\n msg: 'ComputeOutputSumFailed',\n },\n {\n code: 6003,\n name: 'ComputeCompressSumFailed',\n msg: 'ComputeCompressSumFailed',\n },\n {\n code: 6004,\n name: 'ComputeDecompressSumFailed',\n msg: 'ComputeDecompressSumFailed',\n },\n {\n code: 6005,\n name: 'SumCheckFailed',\n msg: 'SumCheckFailed',\n },\n {\n code: 6006,\n name: 'DecompressRecipientUndefinedForDecompress',\n msg: 'DecompressRecipientUndefinedForDecompress',\n },\n {\n code: 6007,\n name: 'CompressedPdaUndefinedForDecompress',\n msg: 'CompressedPdaUndefinedForDecompress',\n },\n {\n code: 6008,\n name: 'DeCompressAmountUndefinedForDecompress',\n msg: 'DeCompressAmountUndefinedForDecompress',\n },\n {\n code: 6009,\n name: 'CompressedPdaUndefinedForCompress',\n msg: 'CompressedPdaUndefinedForCompress',\n },\n {\n code: 6010,\n name: 'DeCompressAmountUndefinedForCompress',\n msg: 'DeCompressAmountUndefinedForCompress',\n },\n {\n code: 6011,\n name: 'DelegateSignerCheckFailed',\n msg: 'DelegateSignerCheckFailed',\n },\n {\n code: 6012,\n name: 'MintTooLarge',\n msg: 'Minted amount greater than u64::MAX',\n },\n {\n code: 6013,\n name: 'SplTokenSupplyMismatch',\n msg: 'SplTokenSupplyMismatch',\n },\n {\n code: 6014,\n name: 'HeapMemoryCheckFailed',\n msg: 'HeapMemoryCheckFailed',\n },\n {\n code: 6015,\n name: 'InstructionNotCallable',\n msg: 'The instruction is not callable',\n },\n {\n code: 6016,\n name: 'ArithmeticUnderflow',\n msg: 'ArithmeticUnderflow',\n },\n {\n code: 6017,\n name: 'HashToFieldError',\n msg: 'HashToFieldError',\n },\n {\n code: 6018,\n name: 'InvalidAuthorityMint',\n msg: 'Expected the authority to be also a mint authority',\n },\n {\n code: 6019,\n name: 'InvalidFreezeAuthority',\n msg: 'Provided authority is not the freeze authority',\n },\n {\n code: 6020,\n name: 'InvalidDelegateIndex',\n },\n {\n code: 6021,\n name: 'TokenPoolPdaUndefined',\n },\n {\n code: 6022,\n name: 'IsTokenPoolPda',\n msg: 'Compress or decompress recipient is the same account as the token pool pda.',\n },\n {\n code: 6023,\n name: 'InvalidTokenPoolPda',\n },\n {\n code: 6024,\n name: 'NoInputTokenAccountsProvided',\n },\n {\n code: 6025,\n name: 'NoInputsProvided',\n },\n {\n code: 6026,\n name: 'MintHasNoFreezeAuthority',\n },\n {\n code: 6027,\n name: 'MintWithInvalidExtension',\n },\n {\n code: 6028,\n name: 'InsufficientTokenAccountBalance',\n msg: 'The token account balance is less than the remaining amount.',\n },\n {\n code: 6029,\n name: 'InvalidTokenPoolBump',\n msg: 'Max number of token pools reached.',\n },\n {\n code: 6030,\n name: 'FailedToDecompress',\n },\n {\n code: 6031,\n name: 'FailedToBurnSplTokensFromTokenPool',\n },\n {\n code: 6032,\n name: 'NoMatchingBumpFound',\n },\n ],\n};\n","import { PublicKey } from '@solana/web3.js';\nimport BN from 'bn.js';\nimport { Buffer } from 'buffer';\nimport {\n ValidityProof,\n PackedMerkleContextLegacy,\n CompressedCpiContext,\n} from '@lightprotocol/stateless.js';\nimport { TokenPoolInfo } from './utils/get-token-pool-infos';\n\nexport type TokenTransferOutputData = {\n /**\n * The owner of the output token account\n */\n owner: PublicKey;\n /**\n * The amount of tokens of the output token account\n */\n amount: BN;\n /**\n * lamports associated with the output token account\n */\n lamports: BN | null;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type PackedTokenTransferOutputData = {\n /**\n * The owner of the output token account\n */\n owner: PublicKey;\n /**\n * The amount of tokens of the output token account\n */\n amount: BN;\n /**\n * lamports associated with the output token account\n */\n lamports: BN | null;\n /**\n * Merkle tree pubkey index in remaining accounts\n */\n merkleTreeIndex: number;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type InputTokenDataWithContext = {\n amount: BN;\n delegateIndex: number | null;\n merkleContext: PackedMerkleContextLegacy;\n rootIndex: number;\n lamports: BN | null;\n tlv: Buffer | null;\n};\n\nexport type DelegatedTransfer = {\n owner: PublicKey;\n delegateChangeAccountIndex: number | null;\n};\n\nexport type BatchCompressInstructionData = {\n pubkeys: PublicKey[];\n amounts: BN[] | null;\n lamports: BN | null;\n amount: BN | null;\n index: number;\n bump: number;\n};\n\nexport type MintToInstructionData = {\n recipients: PublicKey[];\n amounts: BN[];\n lamports: BN | null;\n};\nexport type CompressSplTokenAccountInstructionData = {\n owner: PublicKey;\n remainingAmount: BN | null;\n cpiContext: CompressedCpiContext | null;\n};\n\nexport function isSingleTokenPoolInfo(\n tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[],\n): tokenPoolInfos is TokenPoolInfo {\n return !Array.isArray(tokenPoolInfos);\n}\n\nexport type CompressedTokenInstructionDataTransfer = {\n /**\n * Validity proof\n */\n proof: ValidityProof | null;\n /**\n * The mint of the transfer\n */\n mint: PublicKey;\n /**\n * Whether the signer is a delegate\n */\n delegatedTransfer: DelegatedTransfer | null;\n /**\n * Input token data with packed merkle context\n */\n inputTokenDataWithContext: InputTokenDataWithContext[];\n /**\n * Data of the output token accounts\n */\n outputCompressedAccounts: PackedTokenTransferOutputData[];\n /**\n * Whether it's a compress or decompress action if compressOrDecompressAmount is non-null\n */\n isCompress: boolean;\n /**\n * If null, it's a transfer.\n * If some, the amount that is being deposited into (compress) or withdrawn from (decompress) the token escrow\n */\n compressOrDecompressAmount: BN | null;\n /**\n * CPI context if\n */\n cpiContext: CompressedCpiContext | null;\n /**\n * The index of the Merkle tree for a lamport change account.\n */\n lamportsChangeAccountMerkleTreeIndex: number | null;\n};\n\nexport type TokenData = {\n /**\n * The mint associated with this account\n */\n mint: PublicKey;\n /**\n * The owner of this account\n */\n owner: PublicKey;\n /**\n * The amount of tokens this account holds\n */\n amount: BN;\n /**\n * If `delegate` is `Some` then `delegated_amount` represents the amount\n * authorized by the delegate\n */\n delegate: PublicKey | null;\n /**\n * The account's state\n */\n state: number;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type CompressedTokenInstructionDataApprove = {\n proof: ValidityProof | null;\n mint: PublicKey;\n inputTokenDataWithContext: InputTokenDataWithContext[];\n cpiContext: CompressedCpiContext | null;\n delegate: PublicKey;\n delegatedAmount: BN;\n delegateMerkleTreeIndex: number;\n changeAccountMerkleTreeIndex: number;\n delegateLamports: BN | null;\n};\n\nexport type CompressedTokenInstructionDataRevoke = {\n proof: ValidityProof | null;\n mint: PublicKey;\n inputTokenDataWithContext: InputTokenDataWithContext[];\n cpiContext: CompressedCpiContext | null;\n outputAccountMerkleTreeIndex: number;\n};\n"],"names":["POOL_SEED","Buffer","from","CPI_AUTHORITY_SEED","SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE","CREATE_TOKEN_POOL_DISCRIMINATOR","MINT_TO_DISCRIMINATOR","BATCH_COMPRESS_DISCRIMINATOR","TRANSFER_DISCRIMINATOR","COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR","APPROVE_DISCRIMINATOR","REVOKE_DISCRIMINATOR","ADD_TOKEN_POOL_DISCRIMINATOR","checkTokenPoolInfo","tokenPoolInfo","mint","equals","Error","isInitialized","toBase58","async","getTokenPoolInfos","rpc","commitment","addressesAndBumps","Array","length","_","i","CompressedTokenProgram","deriveTokenPoolPdaWithIndex","accountInfos","getMultipleAccountsInfo","map","addressAndBump","parsedInfos","unpackAccount","owner","tokenProgram","parsedInfo","tokenPoolPda","address","activity","undefined","balance","bn","amount","toString","poolIndex","bump","Action","shuffleArray","array","j","Math","floor","random","selectTokenPoolInfo","infos","filteredInfos","filter","info","selectTokenPoolInfosForDecompression","decompressAmount","sufficientBalanceInfo","find","gte","mul","sort","a","b","every","isZero","ERROR_NO_ACCOUNTS_FOUND","selectTokenAccountsForApprove","accounts","approveAmount","maxInputs","exactMatch","account","parsed","eq","compressedAccount","lamports","selectMinCompressedTokenAccountsForTransfer","selectMinCompressedTokenAccountsForDecompression","selectedAccounts","total","totalLamports","maxPossibleAmount","transferAmount","accumulatedAmount","accumulatedLamports","selectMinCompressedTokenAccountsForTransferOrPartial","lt","totalBalance","reduce","acc","add","cmp","push","slice","console","log","selectSmartCompressedTokenAccountsForTransfer","selectSmartCompressedTokenAccountsForTransferOrPartial","nonZeroAccounts","remainingAccounts","smallestAccount","min","max","packCompressedTokenAccounts","params","inputCompressedTokenAccounts","outputStateTreeInfo","rootIndices","tokenTransferOutputs","_remainingAccounts","delegateIndex","delegate","getIndexOrAdd","packedInputTokenData","forEach","index","merkleTreePubkeyIndex","treeInfo","tree","queuePubkeyIndex","queue","merkleContext","leafIndex","proveByIndex","rootIndex","tlv","activeTreeInfo","nextTreeInfo","activeTreeOrQueue","treeType","TreeType","StateV2","featureFlags","isV2","paddedOutputStateMerkleTrees","padOutputStateMerkleTrees","packedOutputTokenData","merkleTreeIndex","remainingAccountMetas","pubkey","isWritable","isSigner","inputTokenDataWithContext","checkMint","compressedTokenAccounts","CompressedProofLayout","struct","u8","PackedTokenTransferOutputDataLayout","publicKey","u64","option","vecU8","InputTokenDataWithContextLayout","u32","bool","u16","DelegatedTransferLayout","CpiContextLayout","CompressedTokenInstructionDataTransferLayout","vec","mintToLayout","batchCompressLayout","compressSplTokenAccountInstructionDataLayout","encodeMintToInstructionData","data","buffer","alloc","len","encode","recipients","amounts","concat","Uint8Array","subarray","decodeMintToInstructionData","decode","encodeBatchCompressInstructionData","lengthBuffer","writeUInt32LE","dataBuffer","decodeBatchCompressInstructionData","encodeCompressSplTokenAccountInstructionData","remainingAmount","cpiContext","decodeCompressSplTokenAccountInstructionData","encodeTransferInstructionData","decodeTransferInstructionData","createTokenPoolAccountsLayout","feePayer","systemProgram","cpiAuthorityPda","addTokenPoolAccountsLayout","existingTokenPoolPda","mintToAccountsLayout","defaultPubkey","programId","authority","lightSystemProgram","registeredProgramPda","noopProgram","accountCompressionAuthority","accountCompressionProgram","merkleTree","selfProgram","solPoolPda","transferAccountsLayout","compressOrDecompressTokenAccount","approveAccountsLayout","revokeAccountsLayout","freezeAccountsLayout","thawAccountsLayout","CompressedTokenInstructionDataApproveLayout","CompressedTokenInstructionDataRevokeLayout","emptyProof","fill","c","isEmptyProof","proof","encodeApproveInstructionData","proofOption","decodeApproveInstructionData","encodeRevokeInstructionData","decodeRevokeInstructionData","sumUpTokenAmount","validateSameTokenOwner","parseTokenData","currentOwner","parseMaybeDelegatedTransfer","inputs","outputs","delegatedAccountsIndex","findIndex","delegatedTransfer","delegateChangeAccountIndex","createTransferOutputState","toAddress","inputAmount","inputLamports","sumUpLamports","changeAmount","sub","validateSufficientBalance","validateSameOwner","createDecompressOutputState","constructor","static","PublicKey","setProgramId","this","deriveTokenPoolPda","seeds","toBuffer","findProgramAddressSync","findTokenPoolIndexAndBump","poolPda","derivedPda","deriveCpiAuthorityPda","createMint","freezeAuthority","decimals","rentExemptBalance","tokenProgramId","mintSize","TOKEN_PROGRAM_ID","SystemProgram","createAccount","fromPubkey","newAccountPubkey","space","MINT_SIZE","createInitializeMint2Instruction","createTokenPool","keys","TransactionInstruction","addTokenPool","mintTo","toPubkey","systemKeys","defaultStaticAccountsStruct","toArray","toPubkeys","LightSystemProgram","approveAndMintTo","authorityTokenAccount","amountBigInt","BigInt","createMintToInstruction","compress","payer","source","transfer","recentValidityProof","recentInputStateRootIndices","outputCompressedAccounts","compressOrDecompressAmount","isCompress","lamportsChangeAccountMerkleTreeIndex","createTokenProgramLookupTable","mints","recentSlot","createInstruction","lookupTableAddress","AddressLookupTableProgram","createLookupTable","optionalMintKeys","instructions","extendLookupTable","lookupTable","addresses","ComputeBudgetProgram","defaultTestStateTreeAccounts","nullifierQueue","addressTree","addressQueue","TOKEN_2022_PROGRAM_ID","chunk","extendIx","amountArray","toAddressArray","pubkeys","amt","amountBN","isArray","sum","decompress","tokenPoolInfos","tokenPoolInfosArray","mergeTokenAccounts","compressSplTokenAccount","tokenAccount","getMintProgramId","connection","getAccountInfo","approve","CHANGE_INDEX","delegatedAmount","delegateMerkleTreeIndex","changeAccountMerkleTreeIndex","delegateLamports","revoke","outputAccountMerkleTreeIndex","confirmOptions","getCompressedTokenAccountsByOwner","inputAccounts","items","getValidityProofV0","hash","ix","compressedProof","blockhash","getLatestBlockhash","additionalSigners","dedupeSigner","signedTx","buildAndSignTx","setComputeUnitLimit","units","sendAndConfirmTx","selectStateTreeInfo","getStateTreeInfos","getOrCreateAssociatedTokenAccount","ixs","tx","sourceTokenAccount","compressIx","blockhashCtx","mintAuthority","keypair","Keypair","generate","getMinimumBalanceForRentExemption","resolvedTokenProgramId","signer","txId","transactionSignature","addTokenPools","numMaxAdditionalPools","uninitializedIndices","additionalAccounts","getSlot","txIds","instruction","selectedTokenPoolInfos","batch","getValidityProof","batchInstructions","checkOwner","some","checkIsDelegated","transferDelegated","getCompressedTokenAccountsByDelegate","decompressDelegated","tokenPoolInfosToUse","IDL","version","name","docs","isMut","args","type","isOptional","defined","types","kind","variants","fields","errors","code","msg","isSingleTokenPoolInfo"],"mappings":"kqsBACa,MAAAA,GAAYC,GAAOC,KAAK,QAExBC,GAAqBF,GAAOC,KAAK,iBAEjCE,GAAqC,QAErCC,GAAkCJ,GAAOC,KAAK,CACvD,GAAI,IAAK,GAAI,IAAK,IAAK,IAAK,IAAK,MAExBI,GAAwBL,GAAOC,KAAK,CAC7C,IAAK,GAAI,GAAI,IAAK,GAAI,IAAK,IAAK,MAEvBK,GAA+BN,GAAOC,KAAK,CACpD,GAAI,IAAK,IAAK,GAAI,IAAK,GAAI,IAAK,MAEvBM,GAAyBP,GAAOC,KAAK,CAC9C,IAAK,GA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NZ,KAAM,oCACNa,IAAK,qCAET,CACID,KAAM,KACNZ,KAAM,uCACNa,IAAK,wCAET,CACID,KAAM,KACNZ,KAAM,4BACNa,IAAK,6BAET,CACID,KAAM,KACNZ,KAAM,eACNa,IAAK,uCAET,CACID,KAAM,KACNZ,KAAM,yBACNa,IAAK,0BAET,CACID,KAAM,KACNZ,KAAM,wBACNa,IAAK,yBAET,CACID,KAAM,KACNZ,KAAM,yBACNa,IAAK,mCAET,CACID,KAAM,KACNZ,KAAM,sBACNa,IAAK,uBAET,CACID,KAAM,KACNZ,KAAM,mBACNa,IAAK,oBAET,CACID,KAAM,KACNZ,KAAM,uBACNa,IAAK,sDAET,CACID,KAAM,KACNZ,KAAM,yBACNa,IAAK,kDAET,CACID,KAAM,KACNZ,KAAM,wBAEV,CACIY,KAAM,KACNZ,KAAM,yBAEV,CACIY,KAAM,KACNZ,KAAM,iBACNa,IAAK,+EAET,CACID,KAAM,KACNZ,KAAM,uBAEV,CACIY,KAAM,KACNZ,KAAM,gCAEV,CACIY,KAAM,KACNZ,KAAM,oBAEV,CACIY,KAAM,KACNZ,KAAM,4BAEV,CACIY,KAAM,KACNZ,KAAM,4BAEV,CACIY,KAAM,KACNZ,KAAM,kCACNa,IAAK,gEAET,CACID,KAAM,KACNZ,KAAM,uBACNa,IAAK,sCAET,CACID,KAAM,KACNZ,KAAM,sBAEV,CACIY,KAAM,KACNZ,KAAM,sCAEV,CACIY,KAAM,KACNZ,KAAM,yBC3/GZ,SAAUc,GACZpF,GAEA,OAAQrT,MAAMkT,QAAQG,EAC1B"}
@@ -680,17 +680,17 @@ declare function packCompressedTokenAccounts(params: PackCompressedTokenAccounts
680
680
  */
681
681
  declare function checkMint(compressedTokenAccounts: ParsedTokenAccount[], mint: PublicKey): boolean;
682
682
 
683
- declare const POOL_SEED: Buffer;
684
- declare const CPI_AUTHORITY_SEED: Buffer;
683
+ declare const POOL_SEED: Buffer<ArrayBuffer>;
684
+ declare const CPI_AUTHORITY_SEED: Buffer<ArrayBuffer>;
685
685
  declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
686
- declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer;
687
- declare const MINT_TO_DISCRIMINATOR: Buffer;
688
- declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer;
689
- declare const TRANSFER_DISCRIMINATOR: Buffer;
690
- declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer;
691
- declare const APPROVE_DISCRIMINATOR: Buffer;
692
- declare const REVOKE_DISCRIMINATOR: Buffer;
693
- declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer;
686
+ declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer<ArrayBuffer>;
687
+ declare const MINT_TO_DISCRIMINATOR: Buffer<ArrayBuffer>;
688
+ declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer<ArrayBuffer>;
689
+ declare const TRANSFER_DISCRIMINATOR: Buffer<ArrayBuffer>;
690
+ declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer<ArrayBuffer>;
691
+ declare const APPROVE_DISCRIMINATOR: Buffer<ArrayBuffer>;
692
+ declare const REVOKE_DISCRIMINATOR: Buffer<ArrayBuffer>;
693
+ declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer<ArrayBuffer>;
694
694
 
695
695
  type LightCompressedToken = {
696
696
  version: '1.2.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/compressed-token",
3
- "version": "0.22.0",
3
+ "version": "0.22.1-alpha.2",
4
4
  "description": "JS client to interact with the compressed-token program",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/node/index.cjs",
@@ -31,7 +31,7 @@
31
31
  "peerDependencies": {
32
32
  "@solana/spl-token": ">=0.3.9",
33
33
  "@solana/web3.js": ">=1.73.5",
34
- "@lightprotocol/stateless.js": "0.22.0"
34
+ "@lightprotocol/stateless.js": "0.22.1-alpha.1"
35
35
  },
36
36
  "dependencies": {
37
37
  "@coral-xyz/borsh": "^0.29.0",
@@ -41,6 +41,7 @@
41
41
  "devDependencies": {
42
42
  "@coral-xyz/anchor": "^0.29.0",
43
43
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
44
+ "@eslint/js": "9.36.0",
44
45
  "@lightprotocol/hasher.rs": "0.2.1",
45
46
  "@rollup/plugin-alias": "^5.1.0",
46
47
  "@rollup/plugin-babel": "^6.0.4",
@@ -51,14 +52,14 @@
51
52
  "@rollup/plugin-terser": "^0.4.4",
52
53
  "@rollup/plugin-typescript": "^11.1.6",
53
54
  "@solana/spl-token": "0.4.8",
54
- "@solana/web3.js": "1.98.0",
55
+ "@solana/web3.js": "1.98.4",
55
56
  "@types/bn.js": "^5.1.5",
56
57
  "@types/node": "^22.5.5",
57
- "@typescript-eslint/eslint-plugin": "^7.13.1",
58
- "@typescript-eslint/parser": "^7.13.1",
58
+ "@typescript-eslint/eslint-plugin": "^8.44.0",
59
+ "@typescript-eslint/parser": "^8.44.0",
59
60
  "add": "^2.0.6",
60
61
  "crypto-browserify": "^3.12.0",
61
- "eslint": "^8.56.0",
62
+ "eslint": "^9.36.0",
62
63
  "eslint-plugin-import": "^2.30.0",
63
64
  "eslint-plugin-n": "^17.10.2",
64
65
  "eslint-plugin-promise": "^7.1.0",
@@ -73,8 +74,7 @@
73
74
  "ts-node": "^10.9.2",
74
75
  "tslib": "^2.7.0",
75
76
  "typescript": "^5.6.2",
76
- "vitest": "^2.1.1",
77
- "@lightprotocol/programs": "0.3.0"
77
+ "vitest": "^2.1.1"
78
78
  },
79
79
  "keywords": [
80
80
  "zk",
@@ -91,6 +91,16 @@
91
91
  "{workspaceRoot}/target/idl",
92
92
  "{workspaceRoot}/target/types"
93
93
  ]
94
+ },
95
+ "build-ci": {
96
+ "dependsOn": [
97
+ "@lightprotocol/stateless.js:build-ci"
98
+ ]
99
+ },
100
+ "test-ci": {
101
+ "dependsOn": [
102
+ "@lightprotocol/stateless.js:test-ci"
103
+ ]
94
104
  }
95
105
  }
96
106
  },
@@ -130,6 +140,8 @@
130
140
  "build:v2": "LIGHT_PROTOCOL_VERSION=V2 pnpm build:stateless:v2 && LIGHT_PROTOCOL_VERSION=V2 pnpm build:bundle",
131
141
  "build:stateless:v1": "cd ../stateless.js && pnpm build:v1",
132
142
  "build:stateless:v2": "cd ../stateless.js && pnpm build:v2",
143
+ "build-ci": "if [ \"$LIGHT_PROTOCOL_VERSION\" = \"V2\" ]; then LIGHT_PROTOCOL_VERSION=V2 pnpm build:bundle; else LIGHT_PROTOCOL_VERSION=V1 pnpm build:bundle; fi",
144
+ "test-ci": "pnpm test",
133
145
  "format": "prettier --write .",
134
146
  "lint": "eslint ."
135
147
  }