@lightprotocol/compressed-token 0.19.0 → 0.20.1
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 +2 -2
- package/dist/cjs/browser/index.cjs +5798 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +4531 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/types/index.d.ts +329 -108
- package/package.json +2 -2
package/dist/cjs/node/index.cjs
CHANGED
|
@@ -1,2 +1,4532 @@
|
|
|
1
|
-
"use strict";var t=require("@lightprotocol/stateless.js"),e=require("@solana/web3.js"),i=require("@solana/spl-token"),n=require("@coral-xyz/borsh"),r=require("buffer");function o(e){const{inputCompressedTokenAccounts:i,outputStateTrees:n,remainingAccounts:r=[],rootIndices:o,tokenTransferOutputs:s}=e,a=r.slice();let u=null;i.length>0&&i[0].parsed.delegate&&(u=t.getIndexOrAdd(a,i[0].parsed.delegate));const m=[];i.forEach(((e,i)=>{const n=t.getIndexOrAdd(a,e.compressedAccount.merkleTree),r=t.getIndexOrAdd(a,e.compressedAccount.nullifierQueue);m.push({amount:e.parsed.amount,delegateIndex:u,merkleContext:{merkleTreePubkeyIndex:n,nullifierQueuePubkeyIndex:r,leafIndex:e.compressedAccount.leafIndex,queueIndex:null},rootIndex:o[i],lamports:e.compressedAccount.lamports.eq(t.bn(0))?null:e.compressedAccount.lamports,tlv:null})}));const h=t.padOutputStateMerkleTrees(n,s.length,i.map((t=>t.compressedAccount))),l=[];h.forEach(((e,i)=>{var n;const r=t.getIndexOrAdd(a,e);l.push({owner:s[i].owner,amount:s[i].amount,lamports:(null===(n=s[i].lamports)||void 0===n?void 0:n.eq(t.bn(0)))?null:s[i].lamports,merkleTreeIndex:r,tlv:null})}));const d=a.map((t=>({pubkey:t,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:m,remainingAccountMetas:d,packedOutputTokenData:l}}const s=Buffer.from("pool"),a=Buffer.from("cpi_authority"),u=Buffer.from([23,169,27,122,147,169,209,152]),m=Buffer.from([241,34,48,186,37,179,123,192]),h=Buffer.from([163,52,200,231,140,3,69,186]),l=Buffer.from([112,230,105,101,145,202,157,97]);var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function p(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:1}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:1,get:function(){return t[e]}})})),i}var g={exports:{}},f=p(Object.freeze({__proto__:null,default:{}}));!function(t,e){function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var o;"object"==typeof g?g.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:f.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void i(0,"Invalid character in "+t)}function a(t,e,i){var n=s(t,i);return i-1>=e&&(n|=s(t,i-1)<<4),n}function u(t,e,n,r){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var m=t.charCodeAt(u)-48;o*=r,s=m>=49?m-49+10:m>=17?m-17+10:m,i(m>=0&&s<r,"Invalid character"),o+=s}return o}function m(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(r.isBN=function(t){return t instanceof r?1:null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r<t.length&&(16===e?this._parseHex(t,r,n):(this._parseBase(t,e,r),"le"===n&&this._initArray(this.toArray(),e,n)))},r.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},r.prototype._initArray=function(t,e,n){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,s,a=0;if("be"===n)for(r=t.length-1,o=0;r>=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(r=0,o=0;r<t.length;r+=3)s=t[r]|t[r+1]<<8|t[r+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},r.prototype._parseHex=function(t,e,i){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var r,o=0,s=0;if("be"===i)for(n=t.length-1;n>=e;n-=2)r=a(t,e,n)<<o,this.words[s]|=67108863&r,o>=18?(o-=18,s+=1,this.words[s]|=r>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)r=a(t,e,n)<<o,this.words[s]|=67108863&r,o>=18?(o-=18,s+=1,this.words[s]|=r>>>26):o+=8;this._strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var n=0,r=1;r<=67108863;r*=e)n++;n--,r=r/e|0;for(var o=t.length-i,s=o%n,a=Math.min(o,o-s)+i,m=0,h=i;h<a;h+=n)m=u(t,h,h+n,e),this.imuln(r),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m);if(0!==s){var l=1;for(m=u(t,h,t.length,e),h=0;h<s;h++)l*=e;this.imuln(l),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m)}this._strip()},r.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},r.prototype._move=function(t){m(t,this)},r.prototype.clone=function(){var t=new r(null);return this.copy(t),t},r.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},r.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(t){r.prototype.inspect=h}else r.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(t,e,i){i.negative=e.negative^t.negative;var n=t.length+e.length|0;i.length=n,n=n-1|0;var r=0|t.words[0],o=0|e.words[0],s=r*o,a=67108863&s,u=s/67108864|0;i.words[0]=a;for(var m=1;m<n;m++){for(var h=u>>>26,l=67108863&u,d=Math.min(m,e.length-1),c=Math.max(0,m-t.length+1);c<=d;c++){var p=m-c|0;h+=(s=(r=0|t.words[p])*(o=0|e.words[c])+l)/67108864|0,l=67108863&s}i.words[m]=0|l,u=0|h}return 0!==u?i.words[m]=0|u:i.length--,i._strip()}r.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var r=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<r|o)).toString(16);o=a>>>24-r&16777215,(r+=2)>=26&&(r-=26,s--),n=0!==o||s!==this.length-1?l[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var m=d[t],h=c[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(h).toString(t);n=(p=p.idivn(h)).isZero()?g+n:l[m-g.length]+g+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}i(0,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(0,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16,2)},o&&(r.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,n){this._strip();var r=this.byteLength(),o=n||Math.max(1,r);i(r<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,r),s},r.prototype._toArrayLikeLE=function(t){for(var e=0,i=0,n=0,r=0;n<this.length;n++){var o=this.words[n]<<r|i;t[e++]=255&o,e<t.length&&(t[e++]=o>>8&255),e<t.length&&(t[e++]=o>>16&255),6===r?(e<t.length&&(t[e++]=o>>24&255),i=0,r=0):(i=o>>>24,r+=2)}if(e<t.length)for(t[e++]=i;e<t.length;)t[e++]=0},r.prototype._toArrayLikeBE=function(t){for(var e=t.length-1,i=0,n=0,r=0;n<this.length;n++){var o=this.words[n]<<r|i;t[e--]=255&o,e>=0&&(t[e--]=o>>8&255),e>=0&&(t[e--]=o>>16&255),6===r?(e>=0&&(t[e--]=o>>24&255),i=0,r=0):(i=o>>>24,r+=2)}if(e>=0)for(t[e--]=i;e>=0;)t[e--]=0},Math.clz32?r.prototype._countBits=function(t){return 32-Math.clz32(t)}:r.prototype._countBits=function(t){var e=t,i=0;return e>=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var i=this._zeroBits(this.words[e]);if(t+=i,26!==i)break}return t},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},r.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return 0!==this.negative},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},r.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},r.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;i<e.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=e.length,this._strip()},r.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},r.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var n=0;n<i.length;n++)this.words[n]=e.words[n]^i.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},r.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},r.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var r=0;r<e;r++)this.words[r]=67108863&~this.words[r];return n>0&&(this.words[r]=~this.words[r]&67108863>>26-n),this._strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var n=t/26|0,r=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<r:this.words[n]&~(1<<r),this._strip()},r.prototype.iadd=function(t){var e,i,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(i=this,n=t):(i=t,n=this);for(var r=0,o=0;o<n.length;o++)e=(0|i.words[o])+(0|n.words[o])+r,this.words[o]=67108863&e,r=e>>>26;for(;0!==r&&o<i.length;o++)e=(0|i.words[o])+r,this.words[o]=67108863&e,r=e>>>26;if(this.length=i.length,0!==r)this.words[this.length]=r,this.length++;else if(i!==this)for(;o<i.length;o++)this.words[o]=i.words[o];return this},r.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,n,r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(i=this,n=t):(i=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|i.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<i.length;s++)o=(e=(0|i.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<i.length&&i!==this)for(;s<i.length;s++)this.words[s]=i.words[s];return this.length=Math.max(this.length,s),i!==this&&(this.negative=1),this._strip()},r.prototype.sub=function(t){return this.clone().isub(t)};var y=function(t,e,i){var n,r,o,s=t.words,a=e.words,u=i.words,m=0,h=0|s[0],l=8191&h,d=h>>>13,c=0|s[1],p=8191&c,g=c>>>13,f=0|s[2],y=8191&f,M=f>>>13,v=0|s[3],w=8191&v,k=v>>>13,b=0|s[4],P=8191&b,S=b>>>13,A=0|s[5],T=8191&A,C=A>>>13,I=0|s[6],x=8191&I,_=I>>>13,O=0|s[7],D=8191&O,E=O>>>13,B=0|s[8],K=8191&B,L=B>>>13,R=0|s[9],N=8191&R,W=R>>>13,q=0|a[0],F=8191&q,U=q>>>13,z=0|a[1],Z=8191&z,H=z>>>13,j=0|a[2],Q=8191&j,V=j>>>13,G=0|a[3],$=8191&G,X=G>>>13,Y=0|a[4],J=8191&Y,tt=Y>>>13,et=0|a[5],it=8191&et,nt=et>>>13,rt=0|a[6],ot=8191&rt,st=rt>>>13,at=0|a[7],ut=8191&at,mt=at>>>13,ht=0|a[8],lt=8191&ht,dt=ht>>>13,ct=0|a[9],pt=8191&ct,gt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var ft=(m+(n=Math.imul(l,F))|0)+((8191&(r=(r=Math.imul(l,U))+Math.imul(d,F)|0))<<13)|0;m=((o=Math.imul(d,U))+(r>>>13)|0)+(ft>>>26)|0,ft&=67108863,n=Math.imul(p,F),r=(r=Math.imul(p,U))+Math.imul(g,F)|0,o=Math.imul(g,U);var yt=(m+(n=n+Math.imul(l,Z)|0)|0)+((8191&(r=(r=r+Math.imul(l,H)|0)+Math.imul(d,Z)|0))<<13)|0;m=((o=o+Math.imul(d,H)|0)+(r>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,F),r=(r=Math.imul(y,U))+Math.imul(M,F)|0,o=Math.imul(M,U),n=n+Math.imul(p,Z)|0,r=(r=r+Math.imul(p,H)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,H)|0;var Mt=(m+(n=n+Math.imul(l,Q)|0)|0)+((8191&(r=(r=r+Math.imul(l,V)|0)+Math.imul(d,Q)|0))<<13)|0;m=((o=o+Math.imul(d,V)|0)+(r>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(w,F),r=(r=Math.imul(w,U))+Math.imul(k,F)|0,o=Math.imul(k,U),n=n+Math.imul(y,Z)|0,r=(r=r+Math.imul(y,H)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,H)|0,n=n+Math.imul(p,Q)|0,r=(r=r+Math.imul(p,V)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,V)|0;var vt=(m+(n=n+Math.imul(l,$)|0)|0)+((8191&(r=(r=r+Math.imul(l,X)|0)+Math.imul(d,$)|0))<<13)|0;m=((o=o+Math.imul(d,X)|0)+(r>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(P,F),r=(r=Math.imul(P,U))+Math.imul(S,F)|0,o=Math.imul(S,U),n=n+Math.imul(w,Z)|0,r=(r=r+Math.imul(w,H)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,H)|0,n=n+Math.imul(y,Q)|0,r=(r=r+Math.imul(y,V)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(p,$)|0,r=(r=r+Math.imul(p,X)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,X)|0;var wt=(m+(n=n+Math.imul(l,J)|0)|0)+((8191&(r=(r=r+Math.imul(l,tt)|0)+Math.imul(d,J)|0))<<13)|0;m=((o=o+Math.imul(d,tt)|0)+(r>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(T,F),r=(r=Math.imul(T,U))+Math.imul(C,F)|0,o=Math.imul(C,U),n=n+Math.imul(P,Z)|0,r=(r=r+Math.imul(P,H)|0)+Math.imul(S,Z)|0,o=o+Math.imul(S,H)|0,n=n+Math.imul(w,Q)|0,r=(r=r+Math.imul(w,V)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,V)|0,n=n+Math.imul(y,$)|0,r=(r=r+Math.imul(y,X)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(p,J)|0,r=(r=r+Math.imul(p,tt)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,tt)|0;var kt=(m+(n=n+Math.imul(l,it)|0)|0)+((8191&(r=(r=r+Math.imul(l,nt)|0)+Math.imul(d,it)|0))<<13)|0;m=((o=o+Math.imul(d,nt)|0)+(r>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(x,F),r=(r=Math.imul(x,U))+Math.imul(_,F)|0,o=Math.imul(_,U),n=n+Math.imul(T,Z)|0,r=(r=r+Math.imul(T,H)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,H)|0,n=n+Math.imul(P,Q)|0,r=(r=r+Math.imul(P,V)|0)+Math.imul(S,Q)|0,o=o+Math.imul(S,V)|0,n=n+Math.imul(w,$)|0,r=(r=r+Math.imul(w,X)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(y,J)|0,r=(r=r+Math.imul(y,tt)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(p,it)|0,r=(r=r+Math.imul(p,nt)|0)+Math.imul(g,it)|0,o=o+Math.imul(g,nt)|0;var bt=(m+(n=n+Math.imul(l,ot)|0)|0)+((8191&(r=(r=r+Math.imul(l,st)|0)+Math.imul(d,ot)|0))<<13)|0;m=((o=o+Math.imul(d,st)|0)+(r>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(D,F),r=(r=Math.imul(D,U))+Math.imul(E,F)|0,o=Math.imul(E,U),n=n+Math.imul(x,Z)|0,r=(r=r+Math.imul(x,H)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,H)|0,n=n+Math.imul(T,Q)|0,r=(r=r+Math.imul(T,V)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,V)|0,n=n+Math.imul(P,$)|0,r=(r=r+Math.imul(P,X)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,X)|0,n=n+Math.imul(w,J)|0,r=(r=r+Math.imul(w,tt)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(y,it)|0,r=(r=r+Math.imul(y,nt)|0)+Math.imul(M,it)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(p,ot)|0,r=(r=r+Math.imul(p,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0;var Pt=(m+(n=n+Math.imul(l,ut)|0)|0)+((8191&(r=(r=r+Math.imul(l,mt)|0)+Math.imul(d,ut)|0))<<13)|0;m=((o=o+Math.imul(d,mt)|0)+(r>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(K,F),r=(r=Math.imul(K,U))+Math.imul(L,F)|0,o=Math.imul(L,U),n=n+Math.imul(D,Z)|0,r=(r=r+Math.imul(D,H)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(x,Q)|0,r=(r=r+Math.imul(x,V)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(T,$)|0,r=(r=r+Math.imul(T,X)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(P,J)|0,r=(r=r+Math.imul(P,tt)|0)+Math.imul(S,J)|0,o=o+Math.imul(S,tt)|0,n=n+Math.imul(w,it)|0,r=(r=r+Math.imul(w,nt)|0)+Math.imul(k,it)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(y,ot)|0,r=(r=r+Math.imul(y,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(p,ut)|0,r=(r=r+Math.imul(p,mt)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,mt)|0;var St=(m+(n=n+Math.imul(l,lt)|0)|0)+((8191&(r=(r=r+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;m=((o=o+Math.imul(d,dt)|0)+(r>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(N,F),r=(r=Math.imul(N,U))+Math.imul(W,F)|0,o=Math.imul(W,U),n=n+Math.imul(K,Z)|0,r=(r=r+Math.imul(K,H)|0)+Math.imul(L,Z)|0,o=o+Math.imul(L,H)|0,n=n+Math.imul(D,Q)|0,r=(r=r+Math.imul(D,V)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(x,$)|0,r=(r=r+Math.imul(x,X)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(T,J)|0,r=(r=r+Math.imul(T,tt)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(P,it)|0,r=(r=r+Math.imul(P,nt)|0)+Math.imul(S,it)|0,o=o+Math.imul(S,nt)|0,n=n+Math.imul(w,ot)|0,r=(r=r+Math.imul(w,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(y,ut)|0,r=(r=r+Math.imul(y,mt)|0)+Math.imul(M,ut)|0,o=o+Math.imul(M,mt)|0,n=n+Math.imul(p,lt)|0,r=(r=r+Math.imul(p,dt)|0)+Math.imul(g,lt)|0,o=o+Math.imul(g,dt)|0;var At=(m+(n=n+Math.imul(l,pt)|0)|0)+((8191&(r=(r=r+Math.imul(l,gt)|0)+Math.imul(d,pt)|0))<<13)|0;m=((o=o+Math.imul(d,gt)|0)+(r>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,Z),r=(r=Math.imul(N,H))+Math.imul(W,Z)|0,o=Math.imul(W,H),n=n+Math.imul(K,Q)|0,r=(r=r+Math.imul(K,V)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,V)|0,n=n+Math.imul(D,$)|0,r=(r=r+Math.imul(D,X)|0)+Math.imul(E,$)|0,o=o+Math.imul(E,X)|0,n=n+Math.imul(x,J)|0,r=(r=r+Math.imul(x,tt)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(T,it)|0,r=(r=r+Math.imul(T,nt)|0)+Math.imul(C,it)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(P,ot)|0,r=(r=r+Math.imul(P,st)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,st)|0,n=n+Math.imul(w,ut)|0,r=(r=r+Math.imul(w,mt)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,mt)|0,n=n+Math.imul(y,lt)|0,r=(r=r+Math.imul(y,dt)|0)+Math.imul(M,lt)|0,o=o+Math.imul(M,dt)|0;var Tt=(m+(n=n+Math.imul(p,pt)|0)|0)+((8191&(r=(r=r+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;m=((o=o+Math.imul(g,gt)|0)+(r>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,Q),r=(r=Math.imul(N,V))+Math.imul(W,Q)|0,o=Math.imul(W,V),n=n+Math.imul(K,$)|0,r=(r=r+Math.imul(K,X)|0)+Math.imul(L,$)|0,o=o+Math.imul(L,X)|0,n=n+Math.imul(D,J)|0,r=(r=r+Math.imul(D,tt)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(x,it)|0,r=(r=r+Math.imul(x,nt)|0)+Math.imul(_,it)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(T,ot)|0,r=(r=r+Math.imul(T,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(P,ut)|0,r=(r=r+Math.imul(P,mt)|0)+Math.imul(S,ut)|0,o=o+Math.imul(S,mt)|0,n=n+Math.imul(w,lt)|0,r=(r=r+Math.imul(w,dt)|0)+Math.imul(k,lt)|0,o=o+Math.imul(k,dt)|0;var Ct=(m+(n=n+Math.imul(y,pt)|0)|0)+((8191&(r=(r=r+Math.imul(y,gt)|0)+Math.imul(M,pt)|0))<<13)|0;m=((o=o+Math.imul(M,gt)|0)+(r>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,$),r=(r=Math.imul(N,X))+Math.imul(W,$)|0,o=Math.imul(W,X),n=n+Math.imul(K,J)|0,r=(r=r+Math.imul(K,tt)|0)+Math.imul(L,J)|0,o=o+Math.imul(L,tt)|0,n=n+Math.imul(D,it)|0,r=(r=r+Math.imul(D,nt)|0)+Math.imul(E,it)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(x,ot)|0,r=(r=r+Math.imul(x,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(T,ut)|0,r=(r=r+Math.imul(T,mt)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,mt)|0,n=n+Math.imul(P,lt)|0,r=(r=r+Math.imul(P,dt)|0)+Math.imul(S,lt)|0,o=o+Math.imul(S,dt)|0;var It=(m+(n=n+Math.imul(w,pt)|0)|0)+((8191&(r=(r=r+Math.imul(w,gt)|0)+Math.imul(k,pt)|0))<<13)|0;m=((o=o+Math.imul(k,gt)|0)+(r>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,J),r=(r=Math.imul(N,tt))+Math.imul(W,J)|0,o=Math.imul(W,tt),n=n+Math.imul(K,it)|0,r=(r=r+Math.imul(K,nt)|0)+Math.imul(L,it)|0,o=o+Math.imul(L,nt)|0,n=n+Math.imul(D,ot)|0,r=(r=r+Math.imul(D,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(x,ut)|0,r=(r=r+Math.imul(x,mt)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,mt)|0,n=n+Math.imul(T,lt)|0,r=(r=r+Math.imul(T,dt)|0)+Math.imul(C,lt)|0,o=o+Math.imul(C,dt)|0;var xt=(m+(n=n+Math.imul(P,pt)|0)|0)+((8191&(r=(r=r+Math.imul(P,gt)|0)+Math.imul(S,pt)|0))<<13)|0;m=((o=o+Math.imul(S,gt)|0)+(r>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,it),r=(r=Math.imul(N,nt))+Math.imul(W,it)|0,o=Math.imul(W,nt),n=n+Math.imul(K,ot)|0,r=(r=r+Math.imul(K,st)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,st)|0,n=n+Math.imul(D,ut)|0,r=(r=r+Math.imul(D,mt)|0)+Math.imul(E,ut)|0,o=o+Math.imul(E,mt)|0,n=n+Math.imul(x,lt)|0,r=(r=r+Math.imul(x,dt)|0)+Math.imul(_,lt)|0,o=o+Math.imul(_,dt)|0;var _t=(m+(n=n+Math.imul(T,pt)|0)|0)+((8191&(r=(r=r+Math.imul(T,gt)|0)+Math.imul(C,pt)|0))<<13)|0;m=((o=o+Math.imul(C,gt)|0)+(r>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(N,ot),r=(r=Math.imul(N,st))+Math.imul(W,ot)|0,o=Math.imul(W,st),n=n+Math.imul(K,ut)|0,r=(r=r+Math.imul(K,mt)|0)+Math.imul(L,ut)|0,o=o+Math.imul(L,mt)|0,n=n+Math.imul(D,lt)|0,r=(r=r+Math.imul(D,dt)|0)+Math.imul(E,lt)|0,o=o+Math.imul(E,dt)|0;var Ot=(m+(n=n+Math.imul(x,pt)|0)|0)+((8191&(r=(r=r+Math.imul(x,gt)|0)+Math.imul(_,pt)|0))<<13)|0;m=((o=o+Math.imul(_,gt)|0)+(r>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(N,ut),r=(r=Math.imul(N,mt))+Math.imul(W,ut)|0,o=Math.imul(W,mt),n=n+Math.imul(K,lt)|0,r=(r=r+Math.imul(K,dt)|0)+Math.imul(L,lt)|0,o=o+Math.imul(L,dt)|0;var Dt=(m+(n=n+Math.imul(D,pt)|0)|0)+((8191&(r=(r=r+Math.imul(D,gt)|0)+Math.imul(E,pt)|0))<<13)|0;m=((o=o+Math.imul(E,gt)|0)+(r>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(N,lt),r=(r=Math.imul(N,dt))+Math.imul(W,lt)|0,o=Math.imul(W,dt);var Et=(m+(n=n+Math.imul(K,pt)|0)|0)+((8191&(r=(r=r+Math.imul(K,gt)|0)+Math.imul(L,pt)|0))<<13)|0;m=((o=o+Math.imul(L,gt)|0)+(r>>>13)|0)+(Et>>>26)|0,Et&=67108863;var Bt=(m+(n=Math.imul(N,pt))|0)+((8191&(r=(r=Math.imul(N,gt))+Math.imul(W,pt)|0))<<13)|0;return m=((o=Math.imul(W,gt))+(r>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,u[0]=ft,u[1]=yt,u[2]=Mt,u[3]=vt,u[4]=wt,u[5]=kt,u[6]=bt,u[7]=Pt,u[8]=St,u[9]=At,u[10]=Tt,u[11]=Ct,u[12]=It,u[13]=xt,u[14]=_t,u[15]=Ot,u[16]=Dt,u[17]=Et,u[18]=Bt,0!==m&&(u[19]=m,i.length++),i};function M(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var n=0,r=0,o=0;o<i.length-1;o++){var s=r;r=0;for(var a=67108863&n,u=Math.min(o,e.length-1),m=Math.max(0,o-t.length+1);m<=u;m++){var h=o-m,l=(0|t.words[h])*(0|e.words[m]),d=67108863&l;a=67108863&(d=d+a|0),r+=(s=(s=s+(l/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}i.words[o]=a,n=s,s=r}return 0!==n?i.words[o]=n:i.length--,i._strip()}function v(t,e,i){return M(t,e,i)}Math.imul||(y=p),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?y(this,t,e):i<63?p(this,t,e):i<1024?M(this,t,e):v(this,t,e)},r.prototype.mul=function(t){var e=new r(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},r.prototype.mulf=function(t){var e=new r(null);return e.words=new Array(this.length+t.length),v(this,t,e)},r.prototype.imul=function(t){return this.clone().mulTo(t,this)},r.prototype.imuln=function(t){var e=t<0;e&&(t=-t),i("number"==typeof t),i(t<67108864);for(var n=0,r=0;r<this.length;r++){var o=(0|this.words[r])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[r]=67108863&s}return 0!==n&&(this.words[r]=n,this.length++),e?this.ineg():this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i<e.length;i++){var n=i/26|0,r=i%26;e[i]=t.words[n]>>>r&1}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n<e.length&&0===e[n];n++,i=i.sqr());if(++n<e.length)for(var o=i.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(i=i.mul(o));return i},r.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,n=t%26,r=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e<r;e++)this.words[e]=0;this.length+=r}return this._strip()},r.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},r.prototype.iushrn=function(t,e,n){var r;i("number"==typeof t&&t>=0),r=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(r-=s,r=Math.max(0,r),u){for(var m=0;m<s;m++)u.words[m]=this.words[m];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,m=0;m<this.length;m++)this.words[m]=this.words[m+s];else this.words[0]=0,this.length=1;var h=0;for(m=this.length-1;m>=0&&(0!==h||m>=r);m--){var l=0|this.words[m];this.words[m]=h<<26-o|l>>>o,h=l&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(t,e,n){return i(0===this.negative),this.iushrn(t,e,n)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,r=1<<e;return this.length<=n?0:!!(this.words[n]&r)},r.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var r=67108863^67108863>>>e<<e;this.words[this.length-1]&=r}return this._strip()},r.prototype.maskn=function(t){return this.clone().imaskn(t)},r.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},r.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},r.prototype.addn=function(t){return this.clone().iaddn(t)},r.prototype.subn=function(t){return this.clone().isubn(t)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(t,e,n){var r,o,s=t.length+n;this._expand(s);var a=0;for(r=0;r<t.length;r++){o=(0|this.words[r+n])+a;var u=(0|t.words[r])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[r+n]=67108863&o}for(;r<this.length-n;r++)a=(o=(0|this.words[r+n])+a)>>26,this.words[r+n]=67108863&o;if(0===a)return this._strip();for(i(-1===a),a=0,r=0;r<this.length;r++)a=(o=-(0|this.words[r])+a)>>26,this.words[r]=67108863&o;return this.negative=1,this._strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!=(i=26-this._countBits(s))&&(o=o.ushln(i),n.iushln(i),s=0|o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==e){(a=new r(null)).length=u+1,a.words=new Array(a.length);for(var m=0;m<a.length;m++)a.words[m]=0}var h=n.clone()._ishlnsubmul(o,1,u);0===h.negative&&(n=h,a&&(a.words[u]=1));for(var l=u-1;l>=0;l--){var d=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(o,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a._strip(),n._strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,n){return i(!t.isZero()),this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},r.prototype.div=function(t){return this.divmod(t,"div",0).div},r.prototype.mod=function(t){return this.divmod(t,"mod",0).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",1).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),r=t.andln(1),o=i.cmp(n);return o<0||1===r&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var n=(1<<26)%t,r=0,o=this.length-1;o>=0;o--)r=(n*r+(0|this.words[o]))%t;return e?-r:r},r.prototype.modn=function(t){return this.modrn(t)},r.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var n=0,r=this.length-1;r>=0;r--){var o=(0|this.words[r])+67108864*n;this.words[r]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new r(1),s=new r(0),a=new r(0),u=new r(1),m=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++m;for(var h=n.clone(),l=e.clone();!e.isZero();){for(var d=0,c=1;0==(e.words[0]&c)&&d<26;++d,c<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(h),s.isub(l)),o.iushrn(1),s.iushrn(1);for(var p=0,g=1;0==(n.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(l)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(m)}},r.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new r(1),a=new r(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var m=0,h=1;0==(e.words[0]&h)&&m<26;++m,h<<=1);if(m>0)for(e.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,d=1;0==(n.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var n=0;e.isEven()&&i.isEven();n++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var r=e.cmp(i);if(r<0){var o=e;e=i,i=o}else if(0===r||0===i.cmpn(1))break;e.isub(i)}return i.iushln(n)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,n=(t-e)/26,r=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=r,this;for(var o=r,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),i(t<=67108863,"Number is too big");var r=0|this.words[0];e=r===t?0:r<t?-1:1}return 0!==this.negative?0|-e:e},r.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},r.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,i=this.length-1;i>=0;i--){var n=0|this.words[i],r=0|t.words[i];if(n!==r){n<r?e=-1:n>r&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new T(t)},r.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},r.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},r.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},r.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},r.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},r.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},r.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function k(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){k.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P(){k.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){k.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){k.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function T(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function C(t){T.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}k.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},k.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:i.ucmp(this.p);return 0===n?(i.words[0]=0,i.length=1):n>0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},k.prototype.split=function(t,e){t.iushrn(this.n,0,e)},k.prototype.imulK=function(t){return t.imul(this.k)},n(b,k),b.prototype.split=function(t,e){for(var i=4194303,n=Math.min(t.length,9),r=0;r<n;r++)e.words[r]=t.words[r];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&i,r=10;r<t.length;r++){var s=0|t.words[r];t.words[r-10]=(s&i)<<4|o>>>22,o=s}o>>>=22,t.words[r-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i<t.length;i++){var n=0|t.words[i];e+=977*n,t.words[i]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(P,k),n(S,k),n(A,k),A.prototype.imulK=function(t){for(var e=0,i=0;i<t.length;i++){var n=19*(0|t.words[i])+e,r=67108863&n;n>>>=26,t.words[i]=r,e=n}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new P;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new A}return w[t]=e,e},T.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},T.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},T.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(m(t,t.umod(this.m)._forceRed(this)),t)},T.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},T.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},T.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},T.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},T.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},T.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},T.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},T.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},T.prototype.isqr=function(t){return this.imul(t,t.clone())},T.prototype.sqr=function(t){return this.mul(t,t)},T.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var n=this.m.add(new r(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);i(!o.isZero());var a=new r(1).toRed(this),u=a.redNeg(),m=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,m).cmp(u);)h.redIAdd(u);for(var l=this.pow(h,o),d=this.pow(t,o.addn(1).iushrn(1)),c=this.pow(t,o),p=s;0!==c.cmp(a);){for(var g=c,f=0;0!==g.cmp(a);f++)g=g.redSqr();i(f<p);var y=this.pow(l,new r(1).iushln(p-f-1));d=d.redMul(y),l=y.redSqr(),c=c.redMul(l),p=f}return d},T.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},T.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n<i.length;n++)i[n]=this.mul(i[n-1],t);var o=i[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var m=e.words[n],h=u-1;h>=0;h--){var l=m>>h&1;o!==i[0]&&(o=this.sqr(o)),0!==l||0!==s?(s<<=1,s|=l,(4==++a||0===n&&0===h)&&(o=this.mul(o,i[s]),a=0,s=0)):a=0}u=26}return o},T.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},T.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new C(t)},n(C,T),C.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},C.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},C.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=i.isub(n).iushrn(this.shift),o=r;return r.cmp(this.m)>=0?o=r.isub(this.m):r.cmpn(0)<0&&(o=r.iadd(this.m)),o._forceRed(this)},C.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=i.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},C.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,d);var y=c(g.exports);const M=n.struct([n.array(n.u8(),32,"a"),n.array(n.u8(),64,"b"),n.array(n.u8(),32,"c")]),v=n.struct([n.publicKey("owner"),n.u64("amount"),n.option(n.u64(),"lamports"),n.u8("merkleTreeIndex"),n.option(n.vecU8(),"tlv")]),w=n.struct([n.u8("queueId"),n.u16("index")]),k=n.struct([n.u64("amount"),n.option(n.u8(),"delegateIndex"),n.struct([n.u8("merkleTreePubkeyIndex"),n.u8("nullifierQueuePubkeyIndex"),n.u32("leafIndex"),n.option(w,"queueIndex")],"merkleContext"),n.u16("rootIndex"),n.option(n.u64(),"lamports"),n.option(n.vecU8(),"tlv")]),b=n.struct([n.publicKey("owner"),n.option(n.u8(),"delegateChangeAccountIndex")]),P=n.struct([n.bool("setContext"),n.bool("firstSetContext"),n.u8("cpiContextAccountIndex")]),S=n.struct([n.option(M,"proof"),n.publicKey("mint"),n.option(b,"delegatedTransfer"),n.vec(k,"inputTokenDataWithContext"),n.vec(v,"outputCompressedAccounts"),n.bool("isCompress"),n.option(n.u64(),"compressOrDecompressAmount"),n.option(P,"cpiContext"),n.option(n.u8(),"lamportsChangeAccountMerkleTreeIndex")]),A=n.struct([n.vec(n.publicKey(),"recipients"),n.vec(n.u64(),"amounts"),n.option(n.u64(),"lamports")]),T=n.struct([n.publicKey("owner"),n.option(n.u64(),"remainingAmount"),n.option(P,"cpiContext")]);function C(t){const e=r.Buffer.alloc(1e3),i=A.encode({recipients:t.recipients,amounts:t.amounts,lamports:t.lamports},e);return r.Buffer.concat([m,e.slice(0,i)])}function I(t){const e=r.Buffer.alloc(1e3),i=T.encode({owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext},e);return r.Buffer.concat([l,e.slice(0,i)])}function x(t){const e=r.Buffer.alloc(1e3),i=S.encode(t,e),n=r.Buffer.alloc(4);return n.writeUInt32LE(i,0),r.Buffer.concat([h,n,e.slice(0,i)])}const _=t=>{const{feePayer:e,tokenPoolPda:i,systemProgram:n,mint:r,tokenProgram:o,cpiAuthorityPda:s}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:i,isSigner:0,isWritable:1},{pubkey:n,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:1},{pubkey:o,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},O=t=>{const e=N.programId,{feePayer:i,authority:n,cpiAuthorityPda:r,mint:o,tokenPoolPda:s,tokenProgram:a,lightSystemProgram:u,registeredProgramPda:m,noopProgram:h,accountCompressionAuthority:l,accountCompressionProgram:d,merkleTree:c,selfProgram:p,systemProgram:g,solPoolPda:f}=t;return[{pubkey:i,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:s,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:1},{pubkey:p,isSigner:0,isWritable:0},{pubkey:g,isSigner:0,isWritable:0},{pubkey:null!=f?f:e,isSigner:0,isWritable:1}]},D=t=>{const e=N.programId,{feePayer:i,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:u,accountCompressionProgram:m,selfProgram:h,tokenPoolPda:l,compressOrDecompressTokenAccount:d,tokenProgram:c,systemProgram:p}=t;return[{pubkey:i,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0},{pubkey:null!=l?l:e,isSigner:0,isWritable:1},{pubkey:null!=d?d:e,isSigner:0,isWritable:1},{pubkey:null!=c?c:e,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0}]},E=e=>e.reduce(((t,e)=>t.add(e.parsed.amount)),t.bn(0)),B=t=>{const e=t[0].parsed.owner;t.forEach((t=>{if(!t.parsed.owner.equals(e))throw new Error("Token accounts must be owned by the same owner")}))},K=t=>({mint:t[0].parsed.mint,currentOwner:t[0].parsed.owner,delegate:t[0].parsed.delegate});function L(e,i,n){n=t.bn(n);const r=E(e),o=t.sumUpLamports(e.map((t=>t.compressedAccount))),s=r.sub(n);return t.validateSufficientBalance(s),s.eq(t.bn(0))&&o.eq(t.bn(0))?[{owner:i,amount:n,lamports:o,tlv:null}]:(t.validateSameOwner(e.map((t=>t.compressedAccount))),B(e),[{owner:e[0].parsed.owner,amount:s,lamports:o,tlv:null},{owner:i,amount:n,lamports:t.bn(0),tlv:null}])}function R(e,i){i=t.bn(i);const n=t.sumUpLamports(e.map((t=>t.compressedAccount))),r=E(e).sub(i);return t.validateSufficientBalance(r),r.eq(t.bn(0))&&n.eq(t.bn(0))?[]:(t.validateSameOwner(e.map((t=>t.compressedAccount))),B(e),[{owner:e[0].parsed.owner,amount:r,lamports:n,tlv:null}])}class N{constructor(){}static setProgramId(t){this.programId="string"==typeof t?new e.PublicKey(t):t}static deriveTokenPoolPda(t){const i=[s,t.toBuffer()],[n,r]=e.PublicKey.findProgramAddressSync(i,this.programId);return n}static get deriveCpiAuthorityPda(){const[t,i]=e.PublicKey.findProgramAddressSync([a],this.programId);return t}static async createMint(t){const{mint:n,authority:r,feePayer:o,rentExemptBalance:s,tokenProgramId:a,freezeAuthority:u,mintSize:m}=t,h=null!=a?a:i.TOKEN_PROGRAM_ID;return[e.SystemProgram.createAccount({fromPubkey:o,lamports:s,newAccountPubkey:n,programId:h,space:null!=m?m:i.MINT_SIZE}),i.createInitializeMint2Instruction(n,t.decimals,r,u,h),await this.createTokenPool({feePayer:o,mint:n,tokenProgramId:h})]}static async createTokenPool(t){const{mint:n,feePayer:r,tokenProgramId:o}=t,s=null!=o?o:i.TOKEN_PROGRAM_ID,a=this.deriveTokenPoolPda(n),m=_({mint:n,feePayer:r,tokenPoolPda:a,tokenProgram:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:e.SystemProgram.programId});return new e.TransactionInstruction({programId:this.programId,keys:m,data:u})}static async mintTo(n){const r=t.defaultStaticAccountsStruct(),{mint:o,feePayer:s,authority:a,merkleTree:u,toPubkey:m,amount:h,tokenProgramId:l}=n,d=null!=l?l:i.TOKEN_PROGRAM_ID,c=this.deriveTokenPoolPda(o),p=t.toArray(h).map((e=>t.bn(e))),g=t.toArray(m);if(p.length!==g.length)throw new Error("Amount and toPubkey arrays must have the same length");const f=O({mint:o,feePayer:s,authority:a,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:d,tokenPoolPda:c,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:r.registeredProgramPda,noopProgram:r.noopProgram,accountCompressionAuthority:r.accountCompressionAuthority,accountCompressionProgram:r.accountCompressionProgram,merkleTree:null!=u?u:t.defaultTestStateTreeAccounts().merkleTree,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,solPoolPda:null}),y=C({recipients:g,amounts:p,lamports:null});return new e.TransactionInstruction({programId:this.programId,keys:f,data:y})}static async approveAndMintTo(t){const{mint:e,feePayer:n,authorityTokenAccount:r,authority:o,merkleTree:s,toPubkey:a,tokenProgramId:u}=t,m=BigInt(t.amount.toString());return[i.createMintToInstruction(e,r,o,m,[],u),await this.compress({payer:n,owner:o,source:r,toAddress:a,mint:e,amount:t.amount,outputStateTree:s,tokenProgramId:u})]}static async transfer(i){const{payer:n,inputCompressedTokenAccounts:r,recentInputStateRootIndices:s,recentValidityProof:a,amount:u,outputStateTrees:m,toAddress:h}=i,l=L(r,h,u),{inputTokenDataWithContext:d,packedOutputTokenData:c,remainingAccountMetas:p}=o({inputCompressedTokenAccounts:r,outputStateTrees:m,rootIndices:s,tokenTransferOutputs:l}),{mint:g,currentOwner:f}=K(r),y=x({proof:a,mint:g,delegatedTransfer:null,inputTokenDataWithContext:d,outputCompressedAccounts:c,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:M,noopProgram:v,registeredProgramPda:w,accountCompressionProgram:k}=t.defaultStaticAccountsStruct(),b=D({feePayer:n,authority:f,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:w,noopProgram:v,accountCompressionAuthority:M,accountCompressionProgram:k,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:e.SystemProgram.programId});return b.push(...p),new e.TransactionInstruction({programId:this.programId,keys:b,data:y})}static async createTokenProgramLookupTable(n){const{authority:r,mints:o,recentSlot:s,payer:a,remainingAccounts:u}=n,[m,h]=e.AddressLookupTableProgram.createLookupTable({authority:r,payer:r,recentSlot:s});let l=[];return o&&(l=[...o,...o.map((t=>this.deriveTokenPoolPda(t)))]),{instructions:[m,e.AddressLookupTableProgram.extendLookupTable({payer:a,authority:r,lookupTable:h,addresses:[this.deriveCpiAuthorityPda,t.LightSystemProgram.programId,t.defaultStaticAccountsStruct().registeredProgramPda,t.defaultStaticAccountsStruct().noopProgram,t.defaultStaticAccountsStruct().accountCompressionAuthority,t.defaultStaticAccountsStruct().accountCompressionProgram,t.defaultTestStateTreeAccounts().merkleTree,t.defaultTestStateTreeAccounts().nullifierQueue,t.defaultTestStateTreeAccounts().addressTree,t.defaultTestStateTreeAccounts().addressQueue,this.programId,i.TOKEN_PROGRAM_ID,i.TOKEN_2022_PROGRAM_ID,r,...l,...null!=u?u:[]]})],address:h}}static async compress(n){const{payer:r,owner:s,source:a,toAddress:u,mint:m,outputStateTree:h,tokenProgramId:l}=n;if(Array.isArray(n.amount)!==Array.isArray(n.toAddress))throw new Error("Both amount and toAddress must be arrays or both must be single values");let d;if(Array.isArray(n.amount)&&Array.isArray(n.toAddress)){if(n.amount.length!==n.toAddress.length)throw new Error("Amount and toAddress arrays must have the same length");d=n.amount.map(((e,i)=>{const r=t.bn(e);return{owner:n.toAddress[i],amount:r,lamports:t.bn(0),tlv:null}}))}else d=[{owner:u,amount:t.bn(n.amount),lamports:t.bn(0),tlv:null}];const{inputTokenDataWithContext:c,packedOutputTokenData:p,remainingAccountMetas:g}=o({inputCompressedTokenAccounts:[],outputStateTrees:h,rootIndices:[],tokenTransferOutputs:d}),f=x({proof:null,mint:m,delegatedTransfer:null,inputTokenDataWithContext:c,outputCompressedAccounts:p,compressOrDecompressAmount:Array.isArray(n.amount)?n.amount.map((t=>new y(t))).reduce(((t,e)=>t.add(e)),new y(0)):new y(n.amount),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),M=null!=l?l:i.TOKEN_PROGRAM_ID,v=D(Object.assign(Object.assign({},t.defaultStaticAccountsStruct()),{feePayer:r,authority:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,tokenPoolPda:this.deriveTokenPoolPda(m),compressOrDecompressTokenAccount:a,tokenProgram:M}));return v.push(...g),new e.TransactionInstruction({programId:this.programId,keys:v,data:f})}static async decompress(n){const{payer:r,inputCompressedTokenAccounts:s,toAddress:a,outputStateTree:u,recentValidityProof:m,recentInputStateRootIndices:h,tokenProgramId:l}=n,d=t.bn(n.amount),c=R(s,d),{inputTokenDataWithContext:p,packedOutputTokenData:g,remainingAccountMetas:f}=o({inputCompressedTokenAccounts:s,outputStateTrees:u,rootIndices:h,tokenTransferOutputs:c}),{mint:y,currentOwner:M}=K(s),v=x({proof:m,mint:y,delegatedTransfer:null,inputTokenDataWithContext:p,outputCompressedAccounts:g,compressOrDecompressAmount:d,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),w=null!=l?l:i.TOKEN_PROGRAM_ID,{accountCompressionAuthority:k,noopProgram:b,registeredProgramPda:P,accountCompressionProgram:S}=t.defaultStaticAccountsStruct(),A=D({feePayer:r,authority:M,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:P,noopProgram:b,accountCompressionAuthority:k,accountCompressionProgram:S,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(y),compressOrDecompressTokenAccount:a,tokenProgram:w,systemProgram:e.SystemProgram.programId});return A.push(...f),new e.TransactionInstruction({programId:this.programId,keys:A,data:v})}static async mergeTokenAccounts(t){const{payer:e,owner:i,inputCompressedTokenAccounts:n,outputStateTree:r,recentValidityProof:o,recentInputStateRootIndices:s}=t;if(n.length>3)throw new Error("Cannot merge more than 3 token accounts at once");return[await this.transfer({payer:e,inputCompressedTokenAccounts:n,toAddress:i,amount:n.reduce(((t,e)=>t.add(e.parsed.amount)),new y(0)),outputStateTrees:r,recentInputStateRootIndices:s,recentValidityProof:o})]}static async compressSplTokenAccount(n){const{feePayer:r,authority:o,tokenAccount:s,mint:a,remainingAmount:u,outputStateTree:m,tokenProgramId:h}=n,l=null!=h?h:i.TOKEN_PROGRAM_ID,d=[{pubkey:m,isSigner:0,isWritable:1}],c=I({owner:o,remainingAmount:null!=u?u:null,cpiContext:null}),{accountCompressionAuthority:p,noopProgram:g,registeredProgramPda:f,accountCompressionProgram:y}=t.defaultStaticAccountsStruct(),M=D({feePayer:r,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:f,noopProgram:g,accountCompressionAuthority:p,accountCompressionProgram:y,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(a),compressOrDecompressTokenAccount:s,tokenProgram:l,systemProgram:e.SystemProgram.programId});return M.push(...d),new e.TransactionInstruction({programId:this.programId,keys:M,data:c})}static async get_mint_program_id(t,e){var i;return null===(i=await e.getAccountInfo(t))||void 0===i?void 0:i.owner}}function W(e,i){let n=t.bn(0),r=t.bn(0);const o=[];e.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const s of e){if(n.gte(t.bn(i)))break;n=n.add(s.parsed.amount),r=r.add(s.compressedAccount.lamports),o.push(s)}if(n.lt(t.bn(i)))throw new Error(`Not enough balance for transfer. Required: ${i.toString()}, available: ${n.toString()}`);return[o,n,r.lt(t.bn(0))?r:null]}N.programId=new e.PublicKey("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m"),exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=l,exports.CPI_AUTHORITY_SEED=a,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=u,exports.CompressedTokenInstructionDataTransferLayout=S,exports.CompressedTokenProgram=N,exports.CpiContextLayout=P,exports.DelegatedTransferLayout=b,exports.IDL={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:"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:"nullifierQueuePubkeyIndex",type:"u8"},{name:"leafIndex",type:"u32"},{name:"queueIndex",type:{option:{defined:"QueueIndex"}}}]}},{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"}]},exports.MINT_TO_DISCRIMINATOR=m,exports.POOL_SEED=s,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=1461600,exports.TRANSFER_DISCRIMINATOR=h,exports.approveAndMintTo=async function(n,r,o,s,a,u,m,h,l){l=l||await N.get_mint_program_id(o,n);const d=await i.getOrCreateAssociatedTokenAccount(n,r,o,a.publicKey,void 0,void 0,h,l);if(!m){const e=await n.getCachedActiveStateTreeInfo(),{tree:i}=t.pickRandomTreeAndQueue(e);m=i}const c=await N.approveAndMintTo({feePayer:r.publicKey,mint:o,authority:a.publicKey,authorityTokenAccount:d.address,amount:u,toPubkey:s,merkleTree:m,tokenProgramId:l}),{blockhash:p}=await n.getLatestBlockhash(),g=t.dedupeSigner(r,[a]),f=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),...c],r,p,g);return await t.sendAndConfirmTx(n,f,h)},exports.compress=async function(i,n,r,o,s,a,u,m,h,l){if(l=l||await N.get_mint_program_id(r,i),!m){const e=await i.getCachedActiveStateTreeInfo(),{tree:n}=t.pickRandomTreeAndQueue(e);m=n}const d=await N.compress({payer:n.publicKey,owner:s.publicKey,source:a,toAddress:u,amount:o,mint:r,outputStateTree:m,tokenProgramId:l}),c=await i.getLatestBlockhash(),p=t.dedupeSigner(n,[s]),g=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),d],n,c.blockhash,p);return await t.sendAndConfirmTx(i,g,h,c)},exports.compressSplTokenAccount=async function(i,n,r,o,s,a,u,m,h){h=h||await N.get_mint_program_id(r,i);const l=await N.compressSplTokenAccount({feePayer:n.publicKey,authority:o.publicKey,tokenAccount:s,mint:r,remainingAmount:u,outputStateTree:a,tokenProgramId:h}),d=await i.getLatestBlockhash(),c=t.dedupeSigner(n,[o]),p=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),l],n,d.blockhash,c);return await t.sendAndConfirmTx(i,p,m,d)},exports.compressSplTokenAccountInstructionDataLayout=T,exports.createDecompressOutputState=R,exports.createMint=async function(n,r,o,s,a=e.Keypair.generate(),u,m,h){const l=await n.getMinimumBalanceForRentExemption(i.MINT_SIZE),d=1==m?i.TOKEN_2022_PROGRAM_ID:m||i.TOKEN_PROGRAM_ID,c=await N.createMint({feePayer:r.publicKey,mint:a.publicKey,decimals:s,authority:o,freezeAuthority:h||null,rentExemptBalance:l,tokenProgramId:d}),{blockhash:p}=await n.getLatestBlockhash(),g=t.dedupeSigner(r,[a]),f=t.buildAndSignTx(c,r,p,g),y=await t.sendAndConfirmTx(n,f,u);return{mint:a.publicKey,transactionSignature:y}},exports.createTokenPool=async function(e,i,n,r,o){o=o||await N.get_mint_program_id(n,e);const s=await N.createTokenPool({feePayer:i.publicKey,mint:n,tokenProgramId:o}),{blockhash:a}=await e.getLatestBlockhash(),u=t.buildAndSignTx([s],i,a);return await t.sendAndConfirmTx(e,u,r)},exports.createTokenPoolAccountsLayout=_,exports.createTokenProgramLookupTable=async function(e,i,n,r,o){const s=await e.getSlot("finalized"),{instructions:a,address:u}=await N.createTokenProgramLookupTable({payer:i.publicKey,authority:n.publicKey,mints:r,remainingAccounts:o,recentSlot:s}),m=t.dedupeSigner(i,[n]),h=await e.getLatestBlockhash(),l=t.buildAndSignTx([a[0]],i,h.blockhash,m),d=await t.sendAndConfirmTx(e,l,{commitment:"finalized"},h),c=await e.getLatestBlockhash(),p=t.buildAndSignTx([a[1]],i,c.blockhash,m);return{txIds:[d,await t.sendAndConfirmTx(e,p,{commitment:"finalized"},c)],address:u}},exports.createTransferOutputState=L,exports.decodeCompressSplTokenAccountInstructionData=function(t){const e=T.decode(t.slice(l.length));return{owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext}},exports.decodeMintToInstructionData=function(t){const e=A.decode(t.slice(m.length));return{recipients:e.recipients,amounts:e.amounts,lamports:e.lamports}},exports.decodeTransferInstructionData=function(t){return S.decode(t.slice(h.length+4))},exports.decompress=async function(i,n,r,o,s,a,u,m,h){h=h||await N.get_mint_program_id(r,i),o=t.bn(o);const l=await i.getCompressedTokenAccountsByOwner(s.publicKey,{mint:r}),[d]=W(l.items,o),c=await i.getValidityProof(d.map((e=>t.bn(e.compressedAccount.hash)))),p=await N.decompress({payer:n.publicKey,inputCompressedTokenAccounts:d,toAddress:a,amount:o,outputStateTree:u,recentInputStateRootIndices:c.rootIndices,recentValidityProof:c.compressedProof,tokenProgramId:h}),{blockhash:g}=await i.getLatestBlockhash(),f=t.dedupeSigner(n,[s]),y=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),p],n,g,f);return await t.sendAndConfirmTx(i,y,m)},exports.encodeCompressSplTokenAccountInstructionData=I,exports.encodeMintToInstructionData=C,exports.encodeTransferInstructionData=x,exports.mergeTokenAccounts=async function(i,n,r,o,s,a){const u=await i.getCompressedTokenAccountsByOwner(o.publicKey,{mint:r});if(0===u.items.length)throw new Error(`No compressed token accounts found for mint ${r.toBase58()}`);if(u.items.length>=6)throw new Error(`Too many compressed token accounts used for mint ${r.toBase58()}`);const m=[e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6})];for(let e=0;e<u.items.slice(0,6).length;e+=3){const a=u.items.slice(e,e+3),h=await i.getValidityProof(a.map((e=>t.bn(e.compressedAccount.hash)))),l=await N.mergeTokenAccounts({payer:n.publicKey,owner:o.publicKey,mint:r,inputCompressedTokenAccounts:a,outputStateTree:s,recentValidityProof:h.compressedProof,recentInputStateRootIndices:h.rootIndices});m.push(...l)}const{blockhash:h}=await i.getLatestBlockhash(),l=t.dedupeSigner(n,[o]),d=t.buildAndSignTx(m,n,h,l);return await t.sendAndConfirmTx(i,d,a)},exports.mintTo=async function(i,n,r,o,s,a,u,m,h){h=h||await N.get_mint_program_id(r,i);const l=t.dedupeSigner(n,[s]);if(!u){const e=await i.getCachedActiveStateTreeInfo(),{tree:n}=t.pickRandomTreeAndQueue(e);u=n}const d=await N.mintTo({feePayer:n.publicKey,mint:r,authority:s.publicKey,amount:a,toPubkey:o,merkleTree:u,tokenProgramId:h}),{blockhash:c}=await i.getLatestBlockhash(),p=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),d],n,c,l);return await t.sendAndConfirmTx(i,p,m)},exports.mintToAccountsLayout=O,exports.mintToLayout=A,exports.packCompressedTokenAccounts=o,exports.parseTokenData=K,exports.selectMinCompressedTokenAccountsForTransfer=W,exports.sumUpTokenAmount=E,exports.transfer=async function(i,n,r,o,s,a,u,m){o=t.bn(o);const h=await i.getCompressedTokenAccountsByOwner(s.publicKey,{mint:r}),[l]=W(h.items,o),d=await i.getValidityProof(l.map((e=>t.bn(e.compressedAccount.hash)))),c=await N.transfer({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:a,amount:o,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,outputStateTrees:u}),{blockhash:p}=await i.getLatestBlockhash(),g=t.dedupeSigner(n,[s]),f=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),c],n,p,g);return await t.sendAndConfirmTx(i,f,m)},exports.transferAccountsLayout=D,exports.validateSameTokenOwner=B;
|
|
1
|
+
'use strict';
|
|
2
|
+
var t = require('@lightprotocol/stateless.js'),
|
|
3
|
+
e = require('@solana/web3.js'),
|
|
4
|
+
i = require('@solana/spl-token'),
|
|
5
|
+
n = require('@coral-xyz/borsh'),
|
|
6
|
+
r = require('buffer');
|
|
7
|
+
function o(e) {
|
|
8
|
+
const {
|
|
9
|
+
inputCompressedTokenAccounts: i,
|
|
10
|
+
outputStateTrees: n,
|
|
11
|
+
remainingAccounts: r = [],
|
|
12
|
+
rootIndices: o,
|
|
13
|
+
tokenTransferOutputs: s,
|
|
14
|
+
} = e,
|
|
15
|
+
a = r.slice();
|
|
16
|
+
let u = null;
|
|
17
|
+
i.length > 0 &&
|
|
18
|
+
i[0].parsed.delegate &&
|
|
19
|
+
(u = t.getIndexOrAdd(a, i[0].parsed.delegate));
|
|
20
|
+
const m = [];
|
|
21
|
+
i.forEach((e, i) => {
|
|
22
|
+
const n = t.getIndexOrAdd(a, e.compressedAccount.merkleTree),
|
|
23
|
+
r = t.getIndexOrAdd(a, e.compressedAccount.nullifierQueue);
|
|
24
|
+
m.push({
|
|
25
|
+
amount: e.parsed.amount,
|
|
26
|
+
delegateIndex: u,
|
|
27
|
+
merkleContext: {
|
|
28
|
+
merkleTreePubkeyIndex: n,
|
|
29
|
+
nullifierQueuePubkeyIndex: r,
|
|
30
|
+
leafIndex: e.compressedAccount.leafIndex,
|
|
31
|
+
queueIndex: null,
|
|
32
|
+
},
|
|
33
|
+
rootIndex: o[i],
|
|
34
|
+
lamports: e.compressedAccount.lamports.eq(t.bn(0))
|
|
35
|
+
? null
|
|
36
|
+
: e.compressedAccount.lamports,
|
|
37
|
+
tlv: null,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
const h = t.padOutputStateMerkleTrees(
|
|
41
|
+
n,
|
|
42
|
+
s.length,
|
|
43
|
+
i.map(t => t.compressedAccount),
|
|
44
|
+
),
|
|
45
|
+
l = [];
|
|
46
|
+
h.forEach((e, i) => {
|
|
47
|
+
var n;
|
|
48
|
+
const r = t.getIndexOrAdd(a, e);
|
|
49
|
+
l.push({
|
|
50
|
+
owner: s[i].owner,
|
|
51
|
+
amount: s[i].amount,
|
|
52
|
+
lamports: (
|
|
53
|
+
null === (n = s[i].lamports) || void 0 === n
|
|
54
|
+
? void 0
|
|
55
|
+
: n.eq(t.bn(0))
|
|
56
|
+
)
|
|
57
|
+
? null
|
|
58
|
+
: s[i].lamports,
|
|
59
|
+
merkleTreeIndex: r,
|
|
60
|
+
tlv: null,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const d = a.map(t => ({ pubkey: t, isWritable: 1, isSigner: 0 }));
|
|
64
|
+
return {
|
|
65
|
+
inputTokenDataWithContext: m,
|
|
66
|
+
remainingAccountMetas: d,
|
|
67
|
+
packedOutputTokenData: l,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const s = Buffer.from('pool'),
|
|
71
|
+
a = Buffer.from('cpi_authority'),
|
|
72
|
+
u = Buffer.from([23, 169, 27, 122, 147, 169, 209, 152]),
|
|
73
|
+
m = Buffer.from([241, 34, 48, 186, 37, 179, 123, 192]),
|
|
74
|
+
h = Buffer.from([163, 52, 200, 231, 140, 3, 69, 186]),
|
|
75
|
+
l = Buffer.from([112, 230, 105, 101, 145, 202, 157, 97]);
|
|
76
|
+
var d =
|
|
77
|
+
'undefined' != typeof globalThis
|
|
78
|
+
? globalThis
|
|
79
|
+
: 'undefined' != typeof window
|
|
80
|
+
? window
|
|
81
|
+
: 'undefined' != typeof global
|
|
82
|
+
? global
|
|
83
|
+
: 'undefined' != typeof self
|
|
84
|
+
? self
|
|
85
|
+
: {};
|
|
86
|
+
function c(t) {
|
|
87
|
+
return t &&
|
|
88
|
+
t.__esModule &&
|
|
89
|
+
Object.prototype.hasOwnProperty.call(t, 'default')
|
|
90
|
+
? t.default
|
|
91
|
+
: t;
|
|
92
|
+
}
|
|
93
|
+
function p(t) {
|
|
94
|
+
if (t.__esModule) return t;
|
|
95
|
+
var e = t.default;
|
|
96
|
+
if ('function' == typeof e) {
|
|
97
|
+
var i = function t() {
|
|
98
|
+
return this instanceof t
|
|
99
|
+
? Reflect.construct(e, arguments, this.constructor)
|
|
100
|
+
: e.apply(this, arguments);
|
|
101
|
+
};
|
|
102
|
+
i.prototype = e.prototype;
|
|
103
|
+
} else i = {};
|
|
104
|
+
return (
|
|
105
|
+
Object.defineProperty(i, '__esModule', { value: 1 }),
|
|
106
|
+
Object.keys(t).forEach(function (e) {
|
|
107
|
+
var n = Object.getOwnPropertyDescriptor(t, e);
|
|
108
|
+
Object.defineProperty(
|
|
109
|
+
i,
|
|
110
|
+
e,
|
|
111
|
+
n.get
|
|
112
|
+
? n
|
|
113
|
+
: {
|
|
114
|
+
enumerable: 1,
|
|
115
|
+
get: function () {
|
|
116
|
+
return t[e];
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
}),
|
|
121
|
+
i
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
var g = { exports: {} },
|
|
125
|
+
f = p(Object.freeze({ __proto__: null, default: {} }));
|
|
126
|
+
!(function (t, e) {
|
|
127
|
+
function i(t, e) {
|
|
128
|
+
if (!t) throw new Error(e || 'Assertion failed');
|
|
129
|
+
}
|
|
130
|
+
function n(t, e) {
|
|
131
|
+
t.super_ = e;
|
|
132
|
+
var i = function () {};
|
|
133
|
+
(i.prototype = e.prototype),
|
|
134
|
+
(t.prototype = new i()),
|
|
135
|
+
(t.prototype.constructor = t);
|
|
136
|
+
}
|
|
137
|
+
function r(t, e, i) {
|
|
138
|
+
if (r.isBN(t)) return t;
|
|
139
|
+
(this.negative = 0),
|
|
140
|
+
(this.words = null),
|
|
141
|
+
(this.length = 0),
|
|
142
|
+
(this.red = null),
|
|
143
|
+
null !== t &&
|
|
144
|
+
(('le' !== e && 'be' !== e) || ((i = e), (e = 10)),
|
|
145
|
+
this._init(t || 0, e || 10, i || 'be'));
|
|
146
|
+
}
|
|
147
|
+
var o;
|
|
148
|
+
'object' == typeof g ? (g.exports = r) : (e.BN = r),
|
|
149
|
+
(r.BN = r),
|
|
150
|
+
(r.wordSize = 26);
|
|
151
|
+
try {
|
|
152
|
+
o =
|
|
153
|
+
'undefined' != typeof window && void 0 !== window.Buffer
|
|
154
|
+
? window.Buffer
|
|
155
|
+
: f.Buffer;
|
|
156
|
+
} catch (t) {}
|
|
157
|
+
function s(t, e) {
|
|
158
|
+
var n = t.charCodeAt(e);
|
|
159
|
+
return n >= 48 && n <= 57
|
|
160
|
+
? n - 48
|
|
161
|
+
: n >= 65 && n <= 70
|
|
162
|
+
? n - 55
|
|
163
|
+
: n >= 97 && n <= 102
|
|
164
|
+
? n - 87
|
|
165
|
+
: void i(0, 'Invalid character in ' + t);
|
|
166
|
+
}
|
|
167
|
+
function a(t, e, i) {
|
|
168
|
+
var n = s(t, i);
|
|
169
|
+
return i - 1 >= e && (n |= s(t, i - 1) << 4), n;
|
|
170
|
+
}
|
|
171
|
+
function u(t, e, n, r) {
|
|
172
|
+
for (var o = 0, s = 0, a = Math.min(t.length, n), u = e; u < a; u++) {
|
|
173
|
+
var m = t.charCodeAt(u) - 48;
|
|
174
|
+
(o *= r),
|
|
175
|
+
(s = m >= 49 ? m - 49 + 10 : m >= 17 ? m - 17 + 10 : m),
|
|
176
|
+
i(m >= 0 && s < r, 'Invalid character'),
|
|
177
|
+
(o += s);
|
|
178
|
+
}
|
|
179
|
+
return o;
|
|
180
|
+
}
|
|
181
|
+
function m(t, e) {
|
|
182
|
+
(t.words = e.words),
|
|
183
|
+
(t.length = e.length),
|
|
184
|
+
(t.negative = e.negative),
|
|
185
|
+
(t.red = e.red);
|
|
186
|
+
}
|
|
187
|
+
if (
|
|
188
|
+
((r.isBN = function (t) {
|
|
189
|
+
return t instanceof r
|
|
190
|
+
? 1
|
|
191
|
+
: null !== t &&
|
|
192
|
+
'object' == typeof t &&
|
|
193
|
+
t.constructor.wordSize === r.wordSize &&
|
|
194
|
+
Array.isArray(t.words);
|
|
195
|
+
}),
|
|
196
|
+
(r.max = function (t, e) {
|
|
197
|
+
return t.cmp(e) > 0 ? t : e;
|
|
198
|
+
}),
|
|
199
|
+
(r.min = function (t, e) {
|
|
200
|
+
return t.cmp(e) < 0 ? t : e;
|
|
201
|
+
}),
|
|
202
|
+
(r.prototype._init = function (t, e, n) {
|
|
203
|
+
if ('number' == typeof t) return this._initNumber(t, e, n);
|
|
204
|
+
if ('object' == typeof t) return this._initArray(t, e, n);
|
|
205
|
+
'hex' === e && (e = 16), i(e === (0 | e) && e >= 2 && e <= 36);
|
|
206
|
+
var r = 0;
|
|
207
|
+
'-' === (t = t.toString().replace(/\s+/g, ''))[0] &&
|
|
208
|
+
(r++, (this.negative = 1)),
|
|
209
|
+
r < t.length &&
|
|
210
|
+
(16 === e
|
|
211
|
+
? this._parseHex(t, r, n)
|
|
212
|
+
: (this._parseBase(t, e, r),
|
|
213
|
+
'le' === n && this._initArray(this.toArray(), e, n)));
|
|
214
|
+
}),
|
|
215
|
+
(r.prototype._initNumber = function (t, e, n) {
|
|
216
|
+
t < 0 && ((this.negative = 1), (t = -t)),
|
|
217
|
+
t < 67108864
|
|
218
|
+
? ((this.words = [67108863 & t]), (this.length = 1))
|
|
219
|
+
: t < 4503599627370496
|
|
220
|
+
? ((this.words = [
|
|
221
|
+
67108863 & t,
|
|
222
|
+
(t / 67108864) & 67108863,
|
|
223
|
+
]),
|
|
224
|
+
(this.length = 2))
|
|
225
|
+
: (i(t < 9007199254740992),
|
|
226
|
+
(this.words = [
|
|
227
|
+
67108863 & t,
|
|
228
|
+
(t / 67108864) & 67108863,
|
|
229
|
+
1,
|
|
230
|
+
]),
|
|
231
|
+
(this.length = 3)),
|
|
232
|
+
'le' === n && this._initArray(this.toArray(), e, n);
|
|
233
|
+
}),
|
|
234
|
+
(r.prototype._initArray = function (t, e, n) {
|
|
235
|
+
if ((i('number' == typeof t.length), t.length <= 0))
|
|
236
|
+
return (this.words = [0]), (this.length = 1), this;
|
|
237
|
+
(this.length = Math.ceil(t.length / 3)),
|
|
238
|
+
(this.words = new Array(this.length));
|
|
239
|
+
for (var r = 0; r < this.length; r++) this.words[r] = 0;
|
|
240
|
+
var o,
|
|
241
|
+
s,
|
|
242
|
+
a = 0;
|
|
243
|
+
if ('be' === n)
|
|
244
|
+
for (r = t.length - 1, o = 0; r >= 0; r -= 3)
|
|
245
|
+
(s = t[r] | (t[r - 1] << 8) | (t[r - 2] << 16)),
|
|
246
|
+
(this.words[o] |= (s << a) & 67108863),
|
|
247
|
+
(this.words[o + 1] = (s >>> (26 - a)) & 67108863),
|
|
248
|
+
(a += 24) >= 26 && ((a -= 26), o++);
|
|
249
|
+
else if ('le' === n)
|
|
250
|
+
for (r = 0, o = 0; r < t.length; r += 3)
|
|
251
|
+
(s = t[r] | (t[r + 1] << 8) | (t[r + 2] << 16)),
|
|
252
|
+
(this.words[o] |= (s << a) & 67108863),
|
|
253
|
+
(this.words[o + 1] = (s >>> (26 - a)) & 67108863),
|
|
254
|
+
(a += 24) >= 26 && ((a -= 26), o++);
|
|
255
|
+
return this._strip();
|
|
256
|
+
}),
|
|
257
|
+
(r.prototype._parseHex = function (t, e, i) {
|
|
258
|
+
(this.length = Math.ceil((t.length - e) / 6)),
|
|
259
|
+
(this.words = new Array(this.length));
|
|
260
|
+
for (var n = 0; n < this.length; n++) this.words[n] = 0;
|
|
261
|
+
var r,
|
|
262
|
+
o = 0,
|
|
263
|
+
s = 0;
|
|
264
|
+
if ('be' === i)
|
|
265
|
+
for (n = t.length - 1; n >= e; n -= 2)
|
|
266
|
+
(r = a(t, e, n) << o),
|
|
267
|
+
(this.words[s] |= 67108863 & r),
|
|
268
|
+
o >= 18
|
|
269
|
+
? ((o -= 18), (s += 1), (this.words[s] |= r >>> 26))
|
|
270
|
+
: (o += 8);
|
|
271
|
+
else
|
|
272
|
+
for (
|
|
273
|
+
n = (t.length - e) % 2 == 0 ? e + 1 : e;
|
|
274
|
+
n < t.length;
|
|
275
|
+
n += 2
|
|
276
|
+
)
|
|
277
|
+
(r = a(t, e, n) << o),
|
|
278
|
+
(this.words[s] |= 67108863 & r),
|
|
279
|
+
o >= 18
|
|
280
|
+
? ((o -= 18), (s += 1), (this.words[s] |= r >>> 26))
|
|
281
|
+
: (o += 8);
|
|
282
|
+
this._strip();
|
|
283
|
+
}),
|
|
284
|
+
(r.prototype._parseBase = function (t, e, i) {
|
|
285
|
+
(this.words = [0]), (this.length = 1);
|
|
286
|
+
for (var n = 0, r = 1; r <= 67108863; r *= e) n++;
|
|
287
|
+
n--, (r = (r / e) | 0);
|
|
288
|
+
for (
|
|
289
|
+
var o = t.length - i,
|
|
290
|
+
s = o % n,
|
|
291
|
+
a = Math.min(o, o - s) + i,
|
|
292
|
+
m = 0,
|
|
293
|
+
h = i;
|
|
294
|
+
h < a;
|
|
295
|
+
h += n
|
|
296
|
+
)
|
|
297
|
+
(m = u(t, h, h + n, e)),
|
|
298
|
+
this.imuln(r),
|
|
299
|
+
this.words[0] + m < 67108864
|
|
300
|
+
? (this.words[0] += m)
|
|
301
|
+
: this._iaddn(m);
|
|
302
|
+
if (0 !== s) {
|
|
303
|
+
var l = 1;
|
|
304
|
+
for (m = u(t, h, t.length, e), h = 0; h < s; h++) l *= e;
|
|
305
|
+
this.imuln(l),
|
|
306
|
+
this.words[0] + m < 67108864
|
|
307
|
+
? (this.words[0] += m)
|
|
308
|
+
: this._iaddn(m);
|
|
309
|
+
}
|
|
310
|
+
this._strip();
|
|
311
|
+
}),
|
|
312
|
+
(r.prototype.copy = function (t) {
|
|
313
|
+
t.words = new Array(this.length);
|
|
314
|
+
for (var e = 0; e < this.length; e++) t.words[e] = this.words[e];
|
|
315
|
+
(t.length = this.length),
|
|
316
|
+
(t.negative = this.negative),
|
|
317
|
+
(t.red = this.red);
|
|
318
|
+
}),
|
|
319
|
+
(r.prototype._move = function (t) {
|
|
320
|
+
m(t, this);
|
|
321
|
+
}),
|
|
322
|
+
(r.prototype.clone = function () {
|
|
323
|
+
var t = new r(null);
|
|
324
|
+
return this.copy(t), t;
|
|
325
|
+
}),
|
|
326
|
+
(r.prototype._expand = function (t) {
|
|
327
|
+
for (; this.length < t; ) this.words[this.length++] = 0;
|
|
328
|
+
return this;
|
|
329
|
+
}),
|
|
330
|
+
(r.prototype._strip = function () {
|
|
331
|
+
for (; this.length > 1 && 0 === this.words[this.length - 1]; )
|
|
332
|
+
this.length--;
|
|
333
|
+
return this._normSign();
|
|
334
|
+
}),
|
|
335
|
+
(r.prototype._normSign = function () {
|
|
336
|
+
return (
|
|
337
|
+
1 === this.length && 0 === this.words[0] && (this.negative = 0),
|
|
338
|
+
this
|
|
339
|
+
);
|
|
340
|
+
}),
|
|
341
|
+
'undefined' != typeof Symbol && 'function' == typeof Symbol.for)
|
|
342
|
+
)
|
|
343
|
+
try {
|
|
344
|
+
r.prototype[Symbol.for('nodejs.util.inspect.custom')] = h;
|
|
345
|
+
} catch (t) {
|
|
346
|
+
r.prototype.inspect = h;
|
|
347
|
+
}
|
|
348
|
+
else r.prototype.inspect = h;
|
|
349
|
+
function h() {
|
|
350
|
+
return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
|
|
351
|
+
}
|
|
352
|
+
var l = [
|
|
353
|
+
'',
|
|
354
|
+
'0',
|
|
355
|
+
'00',
|
|
356
|
+
'000',
|
|
357
|
+
'0000',
|
|
358
|
+
'00000',
|
|
359
|
+
'000000',
|
|
360
|
+
'0000000',
|
|
361
|
+
'00000000',
|
|
362
|
+
'000000000',
|
|
363
|
+
'0000000000',
|
|
364
|
+
'00000000000',
|
|
365
|
+
'000000000000',
|
|
366
|
+
'0000000000000',
|
|
367
|
+
'00000000000000',
|
|
368
|
+
'000000000000000',
|
|
369
|
+
'0000000000000000',
|
|
370
|
+
'00000000000000000',
|
|
371
|
+
'000000000000000000',
|
|
372
|
+
'0000000000000000000',
|
|
373
|
+
'00000000000000000000',
|
|
374
|
+
'000000000000000000000',
|
|
375
|
+
'0000000000000000000000',
|
|
376
|
+
'00000000000000000000000',
|
|
377
|
+
'000000000000000000000000',
|
|
378
|
+
'0000000000000000000000000',
|
|
379
|
+
],
|
|
380
|
+
d = [
|
|
381
|
+
0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6,
|
|
382
|
+
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
|
383
|
+
],
|
|
384
|
+
c = [
|
|
385
|
+
0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607,
|
|
386
|
+
16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536,
|
|
387
|
+
11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101,
|
|
388
|
+
5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368,
|
|
389
|
+
20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875,
|
|
390
|
+
60466176,
|
|
391
|
+
];
|
|
392
|
+
function p(t, e, i) {
|
|
393
|
+
i.negative = e.negative ^ t.negative;
|
|
394
|
+
var n = (t.length + e.length) | 0;
|
|
395
|
+
(i.length = n), (n = (n - 1) | 0);
|
|
396
|
+
var r = 0 | t.words[0],
|
|
397
|
+
o = 0 | e.words[0],
|
|
398
|
+
s = r * o,
|
|
399
|
+
a = 67108863 & s,
|
|
400
|
+
u = (s / 67108864) | 0;
|
|
401
|
+
i.words[0] = a;
|
|
402
|
+
for (var m = 1; m < n; m++) {
|
|
403
|
+
for (
|
|
404
|
+
var h = u >>> 26,
|
|
405
|
+
l = 67108863 & u,
|
|
406
|
+
d = Math.min(m, e.length - 1),
|
|
407
|
+
c = Math.max(0, m - t.length + 1);
|
|
408
|
+
c <= d;
|
|
409
|
+
c++
|
|
410
|
+
) {
|
|
411
|
+
var p = (m - c) | 0;
|
|
412
|
+
(h +=
|
|
413
|
+
((s = (r = 0 | t.words[p]) * (o = 0 | e.words[c]) + l) /
|
|
414
|
+
67108864) |
|
|
415
|
+
0),
|
|
416
|
+
(l = 67108863 & s);
|
|
417
|
+
}
|
|
418
|
+
(i.words[m] = 0 | l), (u = 0 | h);
|
|
419
|
+
}
|
|
420
|
+
return 0 !== u ? (i.words[m] = 0 | u) : i.length--, i._strip();
|
|
421
|
+
}
|
|
422
|
+
(r.prototype.toString = function (t, e) {
|
|
423
|
+
var n;
|
|
424
|
+
if (((e = 0 | e || 1), 16 === (t = t || 10) || 'hex' === t)) {
|
|
425
|
+
n = '';
|
|
426
|
+
for (var r = 0, o = 0, s = 0; s < this.length; s++) {
|
|
427
|
+
var a = this.words[s],
|
|
428
|
+
u = (16777215 & ((a << r) | o)).toString(16);
|
|
429
|
+
(o = (a >>> (24 - r)) & 16777215),
|
|
430
|
+
(r += 2) >= 26 && ((r -= 26), s--),
|
|
431
|
+
(n =
|
|
432
|
+
0 !== o || s !== this.length - 1
|
|
433
|
+
? l[6 - u.length] + u + n
|
|
434
|
+
: u + n);
|
|
435
|
+
}
|
|
436
|
+
for (0 !== o && (n = o.toString(16) + n); n.length % e != 0; )
|
|
437
|
+
n = '0' + n;
|
|
438
|
+
return 0 !== this.negative && (n = '-' + n), n;
|
|
439
|
+
}
|
|
440
|
+
if (t === (0 | t) && t >= 2 && t <= 36) {
|
|
441
|
+
var m = d[t],
|
|
442
|
+
h = c[t];
|
|
443
|
+
n = '';
|
|
444
|
+
var p = this.clone();
|
|
445
|
+
for (p.negative = 0; !p.isZero(); ) {
|
|
446
|
+
var g = p.modrn(h).toString(t);
|
|
447
|
+
n = (p = p.idivn(h)).isZero() ? g + n : l[m - g.length] + g + n;
|
|
448
|
+
}
|
|
449
|
+
for (this.isZero() && (n = '0' + n); n.length % e != 0; )
|
|
450
|
+
n = '0' + n;
|
|
451
|
+
return 0 !== this.negative && (n = '-' + n), n;
|
|
452
|
+
}
|
|
453
|
+
i(0, 'Base should be between 2 and 36');
|
|
454
|
+
}),
|
|
455
|
+
(r.prototype.toNumber = function () {
|
|
456
|
+
var t = this.words[0];
|
|
457
|
+
return (
|
|
458
|
+
2 === this.length
|
|
459
|
+
? (t += 67108864 * this.words[1])
|
|
460
|
+
: 3 === this.length && 1 === this.words[2]
|
|
461
|
+
? (t += 4503599627370496 + 67108864 * this.words[1])
|
|
462
|
+
: this.length > 2 &&
|
|
463
|
+
i(0, 'Number can only safely store up to 53 bits'),
|
|
464
|
+
0 !== this.negative ? -t : t
|
|
465
|
+
);
|
|
466
|
+
}),
|
|
467
|
+
(r.prototype.toJSON = function () {
|
|
468
|
+
return this.toString(16, 2);
|
|
469
|
+
}),
|
|
470
|
+
o &&
|
|
471
|
+
(r.prototype.toBuffer = function (t, e) {
|
|
472
|
+
return this.toArrayLike(o, t, e);
|
|
473
|
+
}),
|
|
474
|
+
(r.prototype.toArray = function (t, e) {
|
|
475
|
+
return this.toArrayLike(Array, t, e);
|
|
476
|
+
}),
|
|
477
|
+
(r.prototype.toArrayLike = function (t, e, n) {
|
|
478
|
+
this._strip();
|
|
479
|
+
var r = this.byteLength(),
|
|
480
|
+
o = n || Math.max(1, r);
|
|
481
|
+
i(r <= o, 'byte array longer than desired length'),
|
|
482
|
+
i(o > 0, 'Requested array length <= 0');
|
|
483
|
+
var s = (function (t, e) {
|
|
484
|
+
return t.allocUnsafe ? t.allocUnsafe(e) : new t(e);
|
|
485
|
+
})(t, o);
|
|
486
|
+
return this['_toArrayLike' + ('le' === e ? 'LE' : 'BE')](s, r), s;
|
|
487
|
+
}),
|
|
488
|
+
(r.prototype._toArrayLikeLE = function (t) {
|
|
489
|
+
for (var e = 0, i = 0, n = 0, r = 0; n < this.length; n++) {
|
|
490
|
+
var o = (this.words[n] << r) | i;
|
|
491
|
+
(t[e++] = 255 & o),
|
|
492
|
+
e < t.length && (t[e++] = (o >> 8) & 255),
|
|
493
|
+
e < t.length && (t[e++] = (o >> 16) & 255),
|
|
494
|
+
6 === r
|
|
495
|
+
? (e < t.length && (t[e++] = (o >> 24) & 255),
|
|
496
|
+
(i = 0),
|
|
497
|
+
(r = 0))
|
|
498
|
+
: ((i = o >>> 24), (r += 2));
|
|
499
|
+
}
|
|
500
|
+
if (e < t.length) for (t[e++] = i; e < t.length; ) t[e++] = 0;
|
|
501
|
+
}),
|
|
502
|
+
(r.prototype._toArrayLikeBE = function (t) {
|
|
503
|
+
for (
|
|
504
|
+
var e = t.length - 1, i = 0, n = 0, r = 0;
|
|
505
|
+
n < this.length;
|
|
506
|
+
n++
|
|
507
|
+
) {
|
|
508
|
+
var o = (this.words[n] << r) | i;
|
|
509
|
+
(t[e--] = 255 & o),
|
|
510
|
+
e >= 0 && (t[e--] = (o >> 8) & 255),
|
|
511
|
+
e >= 0 && (t[e--] = (o >> 16) & 255),
|
|
512
|
+
6 === r
|
|
513
|
+
? (e >= 0 && (t[e--] = (o >> 24) & 255),
|
|
514
|
+
(i = 0),
|
|
515
|
+
(r = 0))
|
|
516
|
+
: ((i = o >>> 24), (r += 2));
|
|
517
|
+
}
|
|
518
|
+
if (e >= 0) for (t[e--] = i; e >= 0; ) t[e--] = 0;
|
|
519
|
+
}),
|
|
520
|
+
Math.clz32
|
|
521
|
+
? (r.prototype._countBits = function (t) {
|
|
522
|
+
return 32 - Math.clz32(t);
|
|
523
|
+
})
|
|
524
|
+
: (r.prototype._countBits = function (t) {
|
|
525
|
+
var e = t,
|
|
526
|
+
i = 0;
|
|
527
|
+
return (
|
|
528
|
+
e >= 4096 && ((i += 13), (e >>>= 13)),
|
|
529
|
+
e >= 64 && ((i += 7), (e >>>= 7)),
|
|
530
|
+
e >= 8 && ((i += 4), (e >>>= 4)),
|
|
531
|
+
e >= 2 && ((i += 2), (e >>>= 2)),
|
|
532
|
+
i + e
|
|
533
|
+
);
|
|
534
|
+
}),
|
|
535
|
+
(r.prototype._zeroBits = function (t) {
|
|
536
|
+
if (0 === t) return 26;
|
|
537
|
+
var e = t,
|
|
538
|
+
i = 0;
|
|
539
|
+
return (
|
|
540
|
+
0 == (8191 & e) && ((i += 13), (e >>>= 13)),
|
|
541
|
+
0 == (127 & e) && ((i += 7), (e >>>= 7)),
|
|
542
|
+
0 == (15 & e) && ((i += 4), (e >>>= 4)),
|
|
543
|
+
0 == (3 & e) && ((i += 2), (e >>>= 2)),
|
|
544
|
+
0 == (1 & e) && i++,
|
|
545
|
+
i
|
|
546
|
+
);
|
|
547
|
+
}),
|
|
548
|
+
(r.prototype.bitLength = function () {
|
|
549
|
+
var t = this.words[this.length - 1],
|
|
550
|
+
e = this._countBits(t);
|
|
551
|
+
return 26 * (this.length - 1) + e;
|
|
552
|
+
}),
|
|
553
|
+
(r.prototype.zeroBits = function () {
|
|
554
|
+
if (this.isZero()) return 0;
|
|
555
|
+
for (var t = 0, e = 0; e < this.length; e++) {
|
|
556
|
+
var i = this._zeroBits(this.words[e]);
|
|
557
|
+
if (((t += i), 26 !== i)) break;
|
|
558
|
+
}
|
|
559
|
+
return t;
|
|
560
|
+
}),
|
|
561
|
+
(r.prototype.byteLength = function () {
|
|
562
|
+
return Math.ceil(this.bitLength() / 8);
|
|
563
|
+
}),
|
|
564
|
+
(r.prototype.toTwos = function (t) {
|
|
565
|
+
return 0 !== this.negative
|
|
566
|
+
? this.abs().inotn(t).iaddn(1)
|
|
567
|
+
: this.clone();
|
|
568
|
+
}),
|
|
569
|
+
(r.prototype.fromTwos = function (t) {
|
|
570
|
+
return this.testn(t - 1)
|
|
571
|
+
? this.notn(t).iaddn(1).ineg()
|
|
572
|
+
: this.clone();
|
|
573
|
+
}),
|
|
574
|
+
(r.prototype.isNeg = function () {
|
|
575
|
+
return 0 !== this.negative;
|
|
576
|
+
}),
|
|
577
|
+
(r.prototype.neg = function () {
|
|
578
|
+
return this.clone().ineg();
|
|
579
|
+
}),
|
|
580
|
+
(r.prototype.ineg = function () {
|
|
581
|
+
return this.isZero() || (this.negative ^= 1), this;
|
|
582
|
+
}),
|
|
583
|
+
(r.prototype.iuor = function (t) {
|
|
584
|
+
for (; this.length < t.length; ) this.words[this.length++] = 0;
|
|
585
|
+
for (var e = 0; e < t.length; e++)
|
|
586
|
+
this.words[e] = this.words[e] | t.words[e];
|
|
587
|
+
return this._strip();
|
|
588
|
+
}),
|
|
589
|
+
(r.prototype.ior = function (t) {
|
|
590
|
+
return i(0 == (this.negative | t.negative)), this.iuor(t);
|
|
591
|
+
}),
|
|
592
|
+
(r.prototype.or = function (t) {
|
|
593
|
+
return this.length > t.length
|
|
594
|
+
? this.clone().ior(t)
|
|
595
|
+
: t.clone().ior(this);
|
|
596
|
+
}),
|
|
597
|
+
(r.prototype.uor = function (t) {
|
|
598
|
+
return this.length > t.length
|
|
599
|
+
? this.clone().iuor(t)
|
|
600
|
+
: t.clone().iuor(this);
|
|
601
|
+
}),
|
|
602
|
+
(r.prototype.iuand = function (t) {
|
|
603
|
+
var e;
|
|
604
|
+
e = this.length > t.length ? t : this;
|
|
605
|
+
for (var i = 0; i < e.length; i++)
|
|
606
|
+
this.words[i] = this.words[i] & t.words[i];
|
|
607
|
+
return (this.length = e.length), this._strip();
|
|
608
|
+
}),
|
|
609
|
+
(r.prototype.iand = function (t) {
|
|
610
|
+
return i(0 == (this.negative | t.negative)), this.iuand(t);
|
|
611
|
+
}),
|
|
612
|
+
(r.prototype.and = function (t) {
|
|
613
|
+
return this.length > t.length
|
|
614
|
+
? this.clone().iand(t)
|
|
615
|
+
: t.clone().iand(this);
|
|
616
|
+
}),
|
|
617
|
+
(r.prototype.uand = function (t) {
|
|
618
|
+
return this.length > t.length
|
|
619
|
+
? this.clone().iuand(t)
|
|
620
|
+
: t.clone().iuand(this);
|
|
621
|
+
}),
|
|
622
|
+
(r.prototype.iuxor = function (t) {
|
|
623
|
+
var e, i;
|
|
624
|
+
this.length > t.length
|
|
625
|
+
? ((e = this), (i = t))
|
|
626
|
+
: ((e = t), (i = this));
|
|
627
|
+
for (var n = 0; n < i.length; n++)
|
|
628
|
+
this.words[n] = e.words[n] ^ i.words[n];
|
|
629
|
+
if (this !== e)
|
|
630
|
+
for (; n < e.length; n++) this.words[n] = e.words[n];
|
|
631
|
+
return (this.length = e.length), this._strip();
|
|
632
|
+
}),
|
|
633
|
+
(r.prototype.ixor = function (t) {
|
|
634
|
+
return i(0 == (this.negative | t.negative)), this.iuxor(t);
|
|
635
|
+
}),
|
|
636
|
+
(r.prototype.xor = function (t) {
|
|
637
|
+
return this.length > t.length
|
|
638
|
+
? this.clone().ixor(t)
|
|
639
|
+
: t.clone().ixor(this);
|
|
640
|
+
}),
|
|
641
|
+
(r.prototype.uxor = function (t) {
|
|
642
|
+
return this.length > t.length
|
|
643
|
+
? this.clone().iuxor(t)
|
|
644
|
+
: t.clone().iuxor(this);
|
|
645
|
+
}),
|
|
646
|
+
(r.prototype.inotn = function (t) {
|
|
647
|
+
i('number' == typeof t && t >= 0);
|
|
648
|
+
var e = 0 | Math.ceil(t / 26),
|
|
649
|
+
n = t % 26;
|
|
650
|
+
this._expand(e), n > 0 && e--;
|
|
651
|
+
for (var r = 0; r < e; r++)
|
|
652
|
+
this.words[r] = 67108863 & ~this.words[r];
|
|
653
|
+
return (
|
|
654
|
+
n > 0 &&
|
|
655
|
+
(this.words[r] = ~this.words[r] & (67108863 >> (26 - n))),
|
|
656
|
+
this._strip()
|
|
657
|
+
);
|
|
658
|
+
}),
|
|
659
|
+
(r.prototype.notn = function (t) {
|
|
660
|
+
return this.clone().inotn(t);
|
|
661
|
+
}),
|
|
662
|
+
(r.prototype.setn = function (t, e) {
|
|
663
|
+
i('number' == typeof t && t >= 0);
|
|
664
|
+
var n = (t / 26) | 0,
|
|
665
|
+
r = t % 26;
|
|
666
|
+
return (
|
|
667
|
+
this._expand(n + 1),
|
|
668
|
+
(this.words[n] = e
|
|
669
|
+
? this.words[n] | (1 << r)
|
|
670
|
+
: this.words[n] & ~(1 << r)),
|
|
671
|
+
this._strip()
|
|
672
|
+
);
|
|
673
|
+
}),
|
|
674
|
+
(r.prototype.iadd = function (t) {
|
|
675
|
+
var e, i, n;
|
|
676
|
+
if (0 !== this.negative && 0 === t.negative)
|
|
677
|
+
return (
|
|
678
|
+
(this.negative = 0),
|
|
679
|
+
(e = this.isub(t)),
|
|
680
|
+
(this.negative ^= 1),
|
|
681
|
+
this._normSign()
|
|
682
|
+
);
|
|
683
|
+
if (0 === this.negative && 0 !== t.negative)
|
|
684
|
+
return (
|
|
685
|
+
(t.negative = 0),
|
|
686
|
+
(e = this.isub(t)),
|
|
687
|
+
(t.negative = 1),
|
|
688
|
+
e._normSign()
|
|
689
|
+
);
|
|
690
|
+
this.length > t.length
|
|
691
|
+
? ((i = this), (n = t))
|
|
692
|
+
: ((i = t), (n = this));
|
|
693
|
+
for (var r = 0, o = 0; o < n.length; o++)
|
|
694
|
+
(e = (0 | i.words[o]) + (0 | n.words[o]) + r),
|
|
695
|
+
(this.words[o] = 67108863 & e),
|
|
696
|
+
(r = e >>> 26);
|
|
697
|
+
for (; 0 !== r && o < i.length; o++)
|
|
698
|
+
(e = (0 | i.words[o]) + r),
|
|
699
|
+
(this.words[o] = 67108863 & e),
|
|
700
|
+
(r = e >>> 26);
|
|
701
|
+
if (((this.length = i.length), 0 !== r))
|
|
702
|
+
(this.words[this.length] = r), this.length++;
|
|
703
|
+
else if (i !== this)
|
|
704
|
+
for (; o < i.length; o++) this.words[o] = i.words[o];
|
|
705
|
+
return this;
|
|
706
|
+
}),
|
|
707
|
+
(r.prototype.add = function (t) {
|
|
708
|
+
var e;
|
|
709
|
+
return 0 !== t.negative && 0 === this.negative
|
|
710
|
+
? ((t.negative = 0), (e = this.sub(t)), (t.negative ^= 1), e)
|
|
711
|
+
: 0 === t.negative && 0 !== this.negative
|
|
712
|
+
? ((this.negative = 0),
|
|
713
|
+
(e = t.sub(this)),
|
|
714
|
+
(this.negative = 1),
|
|
715
|
+
e)
|
|
716
|
+
: this.length > t.length
|
|
717
|
+
? this.clone().iadd(t)
|
|
718
|
+
: t.clone().iadd(this);
|
|
719
|
+
}),
|
|
720
|
+
(r.prototype.isub = function (t) {
|
|
721
|
+
if (0 !== t.negative) {
|
|
722
|
+
t.negative = 0;
|
|
723
|
+
var e = this.iadd(t);
|
|
724
|
+
return (t.negative = 1), e._normSign();
|
|
725
|
+
}
|
|
726
|
+
if (0 !== this.negative)
|
|
727
|
+
return (
|
|
728
|
+
(this.negative = 0),
|
|
729
|
+
this.iadd(t),
|
|
730
|
+
(this.negative = 1),
|
|
731
|
+
this._normSign()
|
|
732
|
+
);
|
|
733
|
+
var i,
|
|
734
|
+
n,
|
|
735
|
+
r = this.cmp(t);
|
|
736
|
+
if (0 === r)
|
|
737
|
+
return (
|
|
738
|
+
(this.negative = 0),
|
|
739
|
+
(this.length = 1),
|
|
740
|
+
(this.words[0] = 0),
|
|
741
|
+
this
|
|
742
|
+
);
|
|
743
|
+
r > 0 ? ((i = this), (n = t)) : ((i = t), (n = this));
|
|
744
|
+
for (var o = 0, s = 0; s < n.length; s++)
|
|
745
|
+
(o = (e = (0 | i.words[s]) - (0 | n.words[s]) + o) >> 26),
|
|
746
|
+
(this.words[s] = 67108863 & e);
|
|
747
|
+
for (; 0 !== o && s < i.length; s++)
|
|
748
|
+
(o = (e = (0 | i.words[s]) + o) >> 26),
|
|
749
|
+
(this.words[s] = 67108863 & e);
|
|
750
|
+
if (0 === o && s < i.length && i !== this)
|
|
751
|
+
for (; s < i.length; s++) this.words[s] = i.words[s];
|
|
752
|
+
return (
|
|
753
|
+
(this.length = Math.max(this.length, s)),
|
|
754
|
+
i !== this && (this.negative = 1),
|
|
755
|
+
this._strip()
|
|
756
|
+
);
|
|
757
|
+
}),
|
|
758
|
+
(r.prototype.sub = function (t) {
|
|
759
|
+
return this.clone().isub(t);
|
|
760
|
+
});
|
|
761
|
+
var y = function (t, e, i) {
|
|
762
|
+
var n,
|
|
763
|
+
r,
|
|
764
|
+
o,
|
|
765
|
+
s = t.words,
|
|
766
|
+
a = e.words,
|
|
767
|
+
u = i.words,
|
|
768
|
+
m = 0,
|
|
769
|
+
h = 0 | s[0],
|
|
770
|
+
l = 8191 & h,
|
|
771
|
+
d = h >>> 13,
|
|
772
|
+
c = 0 | s[1],
|
|
773
|
+
p = 8191 & c,
|
|
774
|
+
g = c >>> 13,
|
|
775
|
+
f = 0 | s[2],
|
|
776
|
+
y = 8191 & f,
|
|
777
|
+
M = f >>> 13,
|
|
778
|
+
v = 0 | s[3],
|
|
779
|
+
w = 8191 & v,
|
|
780
|
+
k = v >>> 13,
|
|
781
|
+
b = 0 | s[4],
|
|
782
|
+
P = 8191 & b,
|
|
783
|
+
S = b >>> 13,
|
|
784
|
+
A = 0 | s[5],
|
|
785
|
+
T = 8191 & A,
|
|
786
|
+
C = A >>> 13,
|
|
787
|
+
I = 0 | s[6],
|
|
788
|
+
x = 8191 & I,
|
|
789
|
+
_ = I >>> 13,
|
|
790
|
+
O = 0 | s[7],
|
|
791
|
+
D = 8191 & O,
|
|
792
|
+
E = O >>> 13,
|
|
793
|
+
B = 0 | s[8],
|
|
794
|
+
K = 8191 & B,
|
|
795
|
+
L = B >>> 13,
|
|
796
|
+
R = 0 | s[9],
|
|
797
|
+
N = 8191 & R,
|
|
798
|
+
W = R >>> 13,
|
|
799
|
+
q = 0 | a[0],
|
|
800
|
+
F = 8191 & q,
|
|
801
|
+
U = q >>> 13,
|
|
802
|
+
z = 0 | a[1],
|
|
803
|
+
Z = 8191 & z,
|
|
804
|
+
H = z >>> 13,
|
|
805
|
+
j = 0 | a[2],
|
|
806
|
+
Q = 8191 & j,
|
|
807
|
+
V = j >>> 13,
|
|
808
|
+
G = 0 | a[3],
|
|
809
|
+
$ = 8191 & G,
|
|
810
|
+
X = G >>> 13,
|
|
811
|
+
Y = 0 | a[4],
|
|
812
|
+
J = 8191 & Y,
|
|
813
|
+
tt = Y >>> 13,
|
|
814
|
+
et = 0 | a[5],
|
|
815
|
+
it = 8191 & et,
|
|
816
|
+
nt = et >>> 13,
|
|
817
|
+
rt = 0 | a[6],
|
|
818
|
+
ot = 8191 & rt,
|
|
819
|
+
st = rt >>> 13,
|
|
820
|
+
at = 0 | a[7],
|
|
821
|
+
ut = 8191 & at,
|
|
822
|
+
mt = at >>> 13,
|
|
823
|
+
ht = 0 | a[8],
|
|
824
|
+
lt = 8191 & ht,
|
|
825
|
+
dt = ht >>> 13,
|
|
826
|
+
ct = 0 | a[9],
|
|
827
|
+
pt = 8191 & ct,
|
|
828
|
+
gt = ct >>> 13;
|
|
829
|
+
(i.negative = t.negative ^ e.negative), (i.length = 19);
|
|
830
|
+
var ft =
|
|
831
|
+
(((m + (n = Math.imul(l, F))) | 0) +
|
|
832
|
+
((8191 & (r = ((r = Math.imul(l, U)) + Math.imul(d, F)) | 0)) <<
|
|
833
|
+
13)) |
|
|
834
|
+
0;
|
|
835
|
+
(m = ((((o = Math.imul(d, U)) + (r >>> 13)) | 0) + (ft >>> 26)) | 0),
|
|
836
|
+
(ft &= 67108863),
|
|
837
|
+
(n = Math.imul(p, F)),
|
|
838
|
+
(r = ((r = Math.imul(p, U)) + Math.imul(g, F)) | 0),
|
|
839
|
+
(o = Math.imul(g, U));
|
|
840
|
+
var yt =
|
|
841
|
+
(((m + (n = (n + Math.imul(l, Z)) | 0)) | 0) +
|
|
842
|
+
((8191 &
|
|
843
|
+
(r =
|
|
844
|
+
((r = (r + Math.imul(l, H)) | 0) + Math.imul(d, Z)) |
|
|
845
|
+
0)) <<
|
|
846
|
+
13)) |
|
|
847
|
+
0;
|
|
848
|
+
(m =
|
|
849
|
+
((((o = (o + Math.imul(d, H)) | 0) + (r >>> 13)) | 0) +
|
|
850
|
+
(yt >>> 26)) |
|
|
851
|
+
0),
|
|
852
|
+
(yt &= 67108863),
|
|
853
|
+
(n = Math.imul(y, F)),
|
|
854
|
+
(r = ((r = Math.imul(y, U)) + Math.imul(M, F)) | 0),
|
|
855
|
+
(o = Math.imul(M, U)),
|
|
856
|
+
(n = (n + Math.imul(p, Z)) | 0),
|
|
857
|
+
(r = ((r = (r + Math.imul(p, H)) | 0) + Math.imul(g, Z)) | 0),
|
|
858
|
+
(o = (o + Math.imul(g, H)) | 0);
|
|
859
|
+
var Mt =
|
|
860
|
+
(((m + (n = (n + Math.imul(l, Q)) | 0)) | 0) +
|
|
861
|
+
((8191 &
|
|
862
|
+
(r =
|
|
863
|
+
((r = (r + Math.imul(l, V)) | 0) + Math.imul(d, Q)) |
|
|
864
|
+
0)) <<
|
|
865
|
+
13)) |
|
|
866
|
+
0;
|
|
867
|
+
(m =
|
|
868
|
+
((((o = (o + Math.imul(d, V)) | 0) + (r >>> 13)) | 0) +
|
|
869
|
+
(Mt >>> 26)) |
|
|
870
|
+
0),
|
|
871
|
+
(Mt &= 67108863),
|
|
872
|
+
(n = Math.imul(w, F)),
|
|
873
|
+
(r = ((r = Math.imul(w, U)) + Math.imul(k, F)) | 0),
|
|
874
|
+
(o = Math.imul(k, U)),
|
|
875
|
+
(n = (n + Math.imul(y, Z)) | 0),
|
|
876
|
+
(r = ((r = (r + Math.imul(y, H)) | 0) + Math.imul(M, Z)) | 0),
|
|
877
|
+
(o = (o + Math.imul(M, H)) | 0),
|
|
878
|
+
(n = (n + Math.imul(p, Q)) | 0),
|
|
879
|
+
(r = ((r = (r + Math.imul(p, V)) | 0) + Math.imul(g, Q)) | 0),
|
|
880
|
+
(o = (o + Math.imul(g, V)) | 0);
|
|
881
|
+
var vt =
|
|
882
|
+
(((m + (n = (n + Math.imul(l, $)) | 0)) | 0) +
|
|
883
|
+
((8191 &
|
|
884
|
+
(r =
|
|
885
|
+
((r = (r + Math.imul(l, X)) | 0) + Math.imul(d, $)) |
|
|
886
|
+
0)) <<
|
|
887
|
+
13)) |
|
|
888
|
+
0;
|
|
889
|
+
(m =
|
|
890
|
+
((((o = (o + Math.imul(d, X)) | 0) + (r >>> 13)) | 0) +
|
|
891
|
+
(vt >>> 26)) |
|
|
892
|
+
0),
|
|
893
|
+
(vt &= 67108863),
|
|
894
|
+
(n = Math.imul(P, F)),
|
|
895
|
+
(r = ((r = Math.imul(P, U)) + Math.imul(S, F)) | 0),
|
|
896
|
+
(o = Math.imul(S, U)),
|
|
897
|
+
(n = (n + Math.imul(w, Z)) | 0),
|
|
898
|
+
(r = ((r = (r + Math.imul(w, H)) | 0) + Math.imul(k, Z)) | 0),
|
|
899
|
+
(o = (o + Math.imul(k, H)) | 0),
|
|
900
|
+
(n = (n + Math.imul(y, Q)) | 0),
|
|
901
|
+
(r = ((r = (r + Math.imul(y, V)) | 0) + Math.imul(M, Q)) | 0),
|
|
902
|
+
(o = (o + Math.imul(M, V)) | 0),
|
|
903
|
+
(n = (n + Math.imul(p, $)) | 0),
|
|
904
|
+
(r = ((r = (r + Math.imul(p, X)) | 0) + Math.imul(g, $)) | 0),
|
|
905
|
+
(o = (o + Math.imul(g, X)) | 0);
|
|
906
|
+
var wt =
|
|
907
|
+
(((m + (n = (n + Math.imul(l, J)) | 0)) | 0) +
|
|
908
|
+
((8191 &
|
|
909
|
+
(r =
|
|
910
|
+
((r = (r + Math.imul(l, tt)) | 0) + Math.imul(d, J)) |
|
|
911
|
+
0)) <<
|
|
912
|
+
13)) |
|
|
913
|
+
0;
|
|
914
|
+
(m =
|
|
915
|
+
((((o = (o + Math.imul(d, tt)) | 0) + (r >>> 13)) | 0) +
|
|
916
|
+
(wt >>> 26)) |
|
|
917
|
+
0),
|
|
918
|
+
(wt &= 67108863),
|
|
919
|
+
(n = Math.imul(T, F)),
|
|
920
|
+
(r = ((r = Math.imul(T, U)) + Math.imul(C, F)) | 0),
|
|
921
|
+
(o = Math.imul(C, U)),
|
|
922
|
+
(n = (n + Math.imul(P, Z)) | 0),
|
|
923
|
+
(r = ((r = (r + Math.imul(P, H)) | 0) + Math.imul(S, Z)) | 0),
|
|
924
|
+
(o = (o + Math.imul(S, H)) | 0),
|
|
925
|
+
(n = (n + Math.imul(w, Q)) | 0),
|
|
926
|
+
(r = ((r = (r + Math.imul(w, V)) | 0) + Math.imul(k, Q)) | 0),
|
|
927
|
+
(o = (o + Math.imul(k, V)) | 0),
|
|
928
|
+
(n = (n + Math.imul(y, $)) | 0),
|
|
929
|
+
(r = ((r = (r + Math.imul(y, X)) | 0) + Math.imul(M, $)) | 0),
|
|
930
|
+
(o = (o + Math.imul(M, X)) | 0),
|
|
931
|
+
(n = (n + Math.imul(p, J)) | 0),
|
|
932
|
+
(r = ((r = (r + Math.imul(p, tt)) | 0) + Math.imul(g, J)) | 0),
|
|
933
|
+
(o = (o + Math.imul(g, tt)) | 0);
|
|
934
|
+
var kt =
|
|
935
|
+
(((m + (n = (n + Math.imul(l, it)) | 0)) | 0) +
|
|
936
|
+
((8191 &
|
|
937
|
+
(r =
|
|
938
|
+
((r = (r + Math.imul(l, nt)) | 0) + Math.imul(d, it)) |
|
|
939
|
+
0)) <<
|
|
940
|
+
13)) |
|
|
941
|
+
0;
|
|
942
|
+
(m =
|
|
943
|
+
((((o = (o + Math.imul(d, nt)) | 0) + (r >>> 13)) | 0) +
|
|
944
|
+
(kt >>> 26)) |
|
|
945
|
+
0),
|
|
946
|
+
(kt &= 67108863),
|
|
947
|
+
(n = Math.imul(x, F)),
|
|
948
|
+
(r = ((r = Math.imul(x, U)) + Math.imul(_, F)) | 0),
|
|
949
|
+
(o = Math.imul(_, U)),
|
|
950
|
+
(n = (n + Math.imul(T, Z)) | 0),
|
|
951
|
+
(r = ((r = (r + Math.imul(T, H)) | 0) + Math.imul(C, Z)) | 0),
|
|
952
|
+
(o = (o + Math.imul(C, H)) | 0),
|
|
953
|
+
(n = (n + Math.imul(P, Q)) | 0),
|
|
954
|
+
(r = ((r = (r + Math.imul(P, V)) | 0) + Math.imul(S, Q)) | 0),
|
|
955
|
+
(o = (o + Math.imul(S, V)) | 0),
|
|
956
|
+
(n = (n + Math.imul(w, $)) | 0),
|
|
957
|
+
(r = ((r = (r + Math.imul(w, X)) | 0) + Math.imul(k, $)) | 0),
|
|
958
|
+
(o = (o + Math.imul(k, X)) | 0),
|
|
959
|
+
(n = (n + Math.imul(y, J)) | 0),
|
|
960
|
+
(r = ((r = (r + Math.imul(y, tt)) | 0) + Math.imul(M, J)) | 0),
|
|
961
|
+
(o = (o + Math.imul(M, tt)) | 0),
|
|
962
|
+
(n = (n + Math.imul(p, it)) | 0),
|
|
963
|
+
(r = ((r = (r + Math.imul(p, nt)) | 0) + Math.imul(g, it)) | 0),
|
|
964
|
+
(o = (o + Math.imul(g, nt)) | 0);
|
|
965
|
+
var bt =
|
|
966
|
+
(((m + (n = (n + Math.imul(l, ot)) | 0)) | 0) +
|
|
967
|
+
((8191 &
|
|
968
|
+
(r =
|
|
969
|
+
((r = (r + Math.imul(l, st)) | 0) + Math.imul(d, ot)) |
|
|
970
|
+
0)) <<
|
|
971
|
+
13)) |
|
|
972
|
+
0;
|
|
973
|
+
(m =
|
|
974
|
+
((((o = (o + Math.imul(d, st)) | 0) + (r >>> 13)) | 0) +
|
|
975
|
+
(bt >>> 26)) |
|
|
976
|
+
0),
|
|
977
|
+
(bt &= 67108863),
|
|
978
|
+
(n = Math.imul(D, F)),
|
|
979
|
+
(r = ((r = Math.imul(D, U)) + Math.imul(E, F)) | 0),
|
|
980
|
+
(o = Math.imul(E, U)),
|
|
981
|
+
(n = (n + Math.imul(x, Z)) | 0),
|
|
982
|
+
(r = ((r = (r + Math.imul(x, H)) | 0) + Math.imul(_, Z)) | 0),
|
|
983
|
+
(o = (o + Math.imul(_, H)) | 0),
|
|
984
|
+
(n = (n + Math.imul(T, Q)) | 0),
|
|
985
|
+
(r = ((r = (r + Math.imul(T, V)) | 0) + Math.imul(C, Q)) | 0),
|
|
986
|
+
(o = (o + Math.imul(C, V)) | 0),
|
|
987
|
+
(n = (n + Math.imul(P, $)) | 0),
|
|
988
|
+
(r = ((r = (r + Math.imul(P, X)) | 0) + Math.imul(S, $)) | 0),
|
|
989
|
+
(o = (o + Math.imul(S, X)) | 0),
|
|
990
|
+
(n = (n + Math.imul(w, J)) | 0),
|
|
991
|
+
(r = ((r = (r + Math.imul(w, tt)) | 0) + Math.imul(k, J)) | 0),
|
|
992
|
+
(o = (o + Math.imul(k, tt)) | 0),
|
|
993
|
+
(n = (n + Math.imul(y, it)) | 0),
|
|
994
|
+
(r = ((r = (r + Math.imul(y, nt)) | 0) + Math.imul(M, it)) | 0),
|
|
995
|
+
(o = (o + Math.imul(M, nt)) | 0),
|
|
996
|
+
(n = (n + Math.imul(p, ot)) | 0),
|
|
997
|
+
(r = ((r = (r + Math.imul(p, st)) | 0) + Math.imul(g, ot)) | 0),
|
|
998
|
+
(o = (o + Math.imul(g, st)) | 0);
|
|
999
|
+
var Pt =
|
|
1000
|
+
(((m + (n = (n + Math.imul(l, ut)) | 0)) | 0) +
|
|
1001
|
+
((8191 &
|
|
1002
|
+
(r =
|
|
1003
|
+
((r = (r + Math.imul(l, mt)) | 0) + Math.imul(d, ut)) |
|
|
1004
|
+
0)) <<
|
|
1005
|
+
13)) |
|
|
1006
|
+
0;
|
|
1007
|
+
(m =
|
|
1008
|
+
((((o = (o + Math.imul(d, mt)) | 0) + (r >>> 13)) | 0) +
|
|
1009
|
+
(Pt >>> 26)) |
|
|
1010
|
+
0),
|
|
1011
|
+
(Pt &= 67108863),
|
|
1012
|
+
(n = Math.imul(K, F)),
|
|
1013
|
+
(r = ((r = Math.imul(K, U)) + Math.imul(L, F)) | 0),
|
|
1014
|
+
(o = Math.imul(L, U)),
|
|
1015
|
+
(n = (n + Math.imul(D, Z)) | 0),
|
|
1016
|
+
(r = ((r = (r + Math.imul(D, H)) | 0) + Math.imul(E, Z)) | 0),
|
|
1017
|
+
(o = (o + Math.imul(E, H)) | 0),
|
|
1018
|
+
(n = (n + Math.imul(x, Q)) | 0),
|
|
1019
|
+
(r = ((r = (r + Math.imul(x, V)) | 0) + Math.imul(_, Q)) | 0),
|
|
1020
|
+
(o = (o + Math.imul(_, V)) | 0),
|
|
1021
|
+
(n = (n + Math.imul(T, $)) | 0),
|
|
1022
|
+
(r = ((r = (r + Math.imul(T, X)) | 0) + Math.imul(C, $)) | 0),
|
|
1023
|
+
(o = (o + Math.imul(C, X)) | 0),
|
|
1024
|
+
(n = (n + Math.imul(P, J)) | 0),
|
|
1025
|
+
(r = ((r = (r + Math.imul(P, tt)) | 0) + Math.imul(S, J)) | 0),
|
|
1026
|
+
(o = (o + Math.imul(S, tt)) | 0),
|
|
1027
|
+
(n = (n + Math.imul(w, it)) | 0),
|
|
1028
|
+
(r = ((r = (r + Math.imul(w, nt)) | 0) + Math.imul(k, it)) | 0),
|
|
1029
|
+
(o = (o + Math.imul(k, nt)) | 0),
|
|
1030
|
+
(n = (n + Math.imul(y, ot)) | 0),
|
|
1031
|
+
(r = ((r = (r + Math.imul(y, st)) | 0) + Math.imul(M, ot)) | 0),
|
|
1032
|
+
(o = (o + Math.imul(M, st)) | 0),
|
|
1033
|
+
(n = (n + Math.imul(p, ut)) | 0),
|
|
1034
|
+
(r = ((r = (r + Math.imul(p, mt)) | 0) + Math.imul(g, ut)) | 0),
|
|
1035
|
+
(o = (o + Math.imul(g, mt)) | 0);
|
|
1036
|
+
var St =
|
|
1037
|
+
(((m + (n = (n + Math.imul(l, lt)) | 0)) | 0) +
|
|
1038
|
+
((8191 &
|
|
1039
|
+
(r =
|
|
1040
|
+
((r = (r + Math.imul(l, dt)) | 0) + Math.imul(d, lt)) |
|
|
1041
|
+
0)) <<
|
|
1042
|
+
13)) |
|
|
1043
|
+
0;
|
|
1044
|
+
(m =
|
|
1045
|
+
((((o = (o + Math.imul(d, dt)) | 0) + (r >>> 13)) | 0) +
|
|
1046
|
+
(St >>> 26)) |
|
|
1047
|
+
0),
|
|
1048
|
+
(St &= 67108863),
|
|
1049
|
+
(n = Math.imul(N, F)),
|
|
1050
|
+
(r = ((r = Math.imul(N, U)) + Math.imul(W, F)) | 0),
|
|
1051
|
+
(o = Math.imul(W, U)),
|
|
1052
|
+
(n = (n + Math.imul(K, Z)) | 0),
|
|
1053
|
+
(r = ((r = (r + Math.imul(K, H)) | 0) + Math.imul(L, Z)) | 0),
|
|
1054
|
+
(o = (o + Math.imul(L, H)) | 0),
|
|
1055
|
+
(n = (n + Math.imul(D, Q)) | 0),
|
|
1056
|
+
(r = ((r = (r + Math.imul(D, V)) | 0) + Math.imul(E, Q)) | 0),
|
|
1057
|
+
(o = (o + Math.imul(E, V)) | 0),
|
|
1058
|
+
(n = (n + Math.imul(x, $)) | 0),
|
|
1059
|
+
(r = ((r = (r + Math.imul(x, X)) | 0) + Math.imul(_, $)) | 0),
|
|
1060
|
+
(o = (o + Math.imul(_, X)) | 0),
|
|
1061
|
+
(n = (n + Math.imul(T, J)) | 0),
|
|
1062
|
+
(r = ((r = (r + Math.imul(T, tt)) | 0) + Math.imul(C, J)) | 0),
|
|
1063
|
+
(o = (o + Math.imul(C, tt)) | 0),
|
|
1064
|
+
(n = (n + Math.imul(P, it)) | 0),
|
|
1065
|
+
(r = ((r = (r + Math.imul(P, nt)) | 0) + Math.imul(S, it)) | 0),
|
|
1066
|
+
(o = (o + Math.imul(S, nt)) | 0),
|
|
1067
|
+
(n = (n + Math.imul(w, ot)) | 0),
|
|
1068
|
+
(r = ((r = (r + Math.imul(w, st)) | 0) + Math.imul(k, ot)) | 0),
|
|
1069
|
+
(o = (o + Math.imul(k, st)) | 0),
|
|
1070
|
+
(n = (n + Math.imul(y, ut)) | 0),
|
|
1071
|
+
(r = ((r = (r + Math.imul(y, mt)) | 0) + Math.imul(M, ut)) | 0),
|
|
1072
|
+
(o = (o + Math.imul(M, mt)) | 0),
|
|
1073
|
+
(n = (n + Math.imul(p, lt)) | 0),
|
|
1074
|
+
(r = ((r = (r + Math.imul(p, dt)) | 0) + Math.imul(g, lt)) | 0),
|
|
1075
|
+
(o = (o + Math.imul(g, dt)) | 0);
|
|
1076
|
+
var At =
|
|
1077
|
+
(((m + (n = (n + Math.imul(l, pt)) | 0)) | 0) +
|
|
1078
|
+
((8191 &
|
|
1079
|
+
(r =
|
|
1080
|
+
((r = (r + Math.imul(l, gt)) | 0) + Math.imul(d, pt)) |
|
|
1081
|
+
0)) <<
|
|
1082
|
+
13)) |
|
|
1083
|
+
0;
|
|
1084
|
+
(m =
|
|
1085
|
+
((((o = (o + Math.imul(d, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1086
|
+
(At >>> 26)) |
|
|
1087
|
+
0),
|
|
1088
|
+
(At &= 67108863),
|
|
1089
|
+
(n = Math.imul(N, Z)),
|
|
1090
|
+
(r = ((r = Math.imul(N, H)) + Math.imul(W, Z)) | 0),
|
|
1091
|
+
(o = Math.imul(W, H)),
|
|
1092
|
+
(n = (n + Math.imul(K, Q)) | 0),
|
|
1093
|
+
(r = ((r = (r + Math.imul(K, V)) | 0) + Math.imul(L, Q)) | 0),
|
|
1094
|
+
(o = (o + Math.imul(L, V)) | 0),
|
|
1095
|
+
(n = (n + Math.imul(D, $)) | 0),
|
|
1096
|
+
(r = ((r = (r + Math.imul(D, X)) | 0) + Math.imul(E, $)) | 0),
|
|
1097
|
+
(o = (o + Math.imul(E, X)) | 0),
|
|
1098
|
+
(n = (n + Math.imul(x, J)) | 0),
|
|
1099
|
+
(r = ((r = (r + Math.imul(x, tt)) | 0) + Math.imul(_, J)) | 0),
|
|
1100
|
+
(o = (o + Math.imul(_, tt)) | 0),
|
|
1101
|
+
(n = (n + Math.imul(T, it)) | 0),
|
|
1102
|
+
(r = ((r = (r + Math.imul(T, nt)) | 0) + Math.imul(C, it)) | 0),
|
|
1103
|
+
(o = (o + Math.imul(C, nt)) | 0),
|
|
1104
|
+
(n = (n + Math.imul(P, ot)) | 0),
|
|
1105
|
+
(r = ((r = (r + Math.imul(P, st)) | 0) + Math.imul(S, ot)) | 0),
|
|
1106
|
+
(o = (o + Math.imul(S, st)) | 0),
|
|
1107
|
+
(n = (n + Math.imul(w, ut)) | 0),
|
|
1108
|
+
(r = ((r = (r + Math.imul(w, mt)) | 0) + Math.imul(k, ut)) | 0),
|
|
1109
|
+
(o = (o + Math.imul(k, mt)) | 0),
|
|
1110
|
+
(n = (n + Math.imul(y, lt)) | 0),
|
|
1111
|
+
(r = ((r = (r + Math.imul(y, dt)) | 0) + Math.imul(M, lt)) | 0),
|
|
1112
|
+
(o = (o + Math.imul(M, dt)) | 0);
|
|
1113
|
+
var Tt =
|
|
1114
|
+
(((m + (n = (n + Math.imul(p, pt)) | 0)) | 0) +
|
|
1115
|
+
((8191 &
|
|
1116
|
+
(r =
|
|
1117
|
+
((r = (r + Math.imul(p, gt)) | 0) + Math.imul(g, pt)) |
|
|
1118
|
+
0)) <<
|
|
1119
|
+
13)) |
|
|
1120
|
+
0;
|
|
1121
|
+
(m =
|
|
1122
|
+
((((o = (o + Math.imul(g, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1123
|
+
(Tt >>> 26)) |
|
|
1124
|
+
0),
|
|
1125
|
+
(Tt &= 67108863),
|
|
1126
|
+
(n = Math.imul(N, Q)),
|
|
1127
|
+
(r = ((r = Math.imul(N, V)) + Math.imul(W, Q)) | 0),
|
|
1128
|
+
(o = Math.imul(W, V)),
|
|
1129
|
+
(n = (n + Math.imul(K, $)) | 0),
|
|
1130
|
+
(r = ((r = (r + Math.imul(K, X)) | 0) + Math.imul(L, $)) | 0),
|
|
1131
|
+
(o = (o + Math.imul(L, X)) | 0),
|
|
1132
|
+
(n = (n + Math.imul(D, J)) | 0),
|
|
1133
|
+
(r = ((r = (r + Math.imul(D, tt)) | 0) + Math.imul(E, J)) | 0),
|
|
1134
|
+
(o = (o + Math.imul(E, tt)) | 0),
|
|
1135
|
+
(n = (n + Math.imul(x, it)) | 0),
|
|
1136
|
+
(r = ((r = (r + Math.imul(x, nt)) | 0) + Math.imul(_, it)) | 0),
|
|
1137
|
+
(o = (o + Math.imul(_, nt)) | 0),
|
|
1138
|
+
(n = (n + Math.imul(T, ot)) | 0),
|
|
1139
|
+
(r = ((r = (r + Math.imul(T, st)) | 0) + Math.imul(C, ot)) | 0),
|
|
1140
|
+
(o = (o + Math.imul(C, st)) | 0),
|
|
1141
|
+
(n = (n + Math.imul(P, ut)) | 0),
|
|
1142
|
+
(r = ((r = (r + Math.imul(P, mt)) | 0) + Math.imul(S, ut)) | 0),
|
|
1143
|
+
(o = (o + Math.imul(S, mt)) | 0),
|
|
1144
|
+
(n = (n + Math.imul(w, lt)) | 0),
|
|
1145
|
+
(r = ((r = (r + Math.imul(w, dt)) | 0) + Math.imul(k, lt)) | 0),
|
|
1146
|
+
(o = (o + Math.imul(k, dt)) | 0);
|
|
1147
|
+
var Ct =
|
|
1148
|
+
(((m + (n = (n + Math.imul(y, pt)) | 0)) | 0) +
|
|
1149
|
+
((8191 &
|
|
1150
|
+
(r =
|
|
1151
|
+
((r = (r + Math.imul(y, gt)) | 0) + Math.imul(M, pt)) |
|
|
1152
|
+
0)) <<
|
|
1153
|
+
13)) |
|
|
1154
|
+
0;
|
|
1155
|
+
(m =
|
|
1156
|
+
((((o = (o + Math.imul(M, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1157
|
+
(Ct >>> 26)) |
|
|
1158
|
+
0),
|
|
1159
|
+
(Ct &= 67108863),
|
|
1160
|
+
(n = Math.imul(N, $)),
|
|
1161
|
+
(r = ((r = Math.imul(N, X)) + Math.imul(W, $)) | 0),
|
|
1162
|
+
(o = Math.imul(W, X)),
|
|
1163
|
+
(n = (n + Math.imul(K, J)) | 0),
|
|
1164
|
+
(r = ((r = (r + Math.imul(K, tt)) | 0) + Math.imul(L, J)) | 0),
|
|
1165
|
+
(o = (o + Math.imul(L, tt)) | 0),
|
|
1166
|
+
(n = (n + Math.imul(D, it)) | 0),
|
|
1167
|
+
(r = ((r = (r + Math.imul(D, nt)) | 0) + Math.imul(E, it)) | 0),
|
|
1168
|
+
(o = (o + Math.imul(E, nt)) | 0),
|
|
1169
|
+
(n = (n + Math.imul(x, ot)) | 0),
|
|
1170
|
+
(r = ((r = (r + Math.imul(x, st)) | 0) + Math.imul(_, ot)) | 0),
|
|
1171
|
+
(o = (o + Math.imul(_, st)) | 0),
|
|
1172
|
+
(n = (n + Math.imul(T, ut)) | 0),
|
|
1173
|
+
(r = ((r = (r + Math.imul(T, mt)) | 0) + Math.imul(C, ut)) | 0),
|
|
1174
|
+
(o = (o + Math.imul(C, mt)) | 0),
|
|
1175
|
+
(n = (n + Math.imul(P, lt)) | 0),
|
|
1176
|
+
(r = ((r = (r + Math.imul(P, dt)) | 0) + Math.imul(S, lt)) | 0),
|
|
1177
|
+
(o = (o + Math.imul(S, dt)) | 0);
|
|
1178
|
+
var It =
|
|
1179
|
+
(((m + (n = (n + Math.imul(w, pt)) | 0)) | 0) +
|
|
1180
|
+
((8191 &
|
|
1181
|
+
(r =
|
|
1182
|
+
((r = (r + Math.imul(w, gt)) | 0) + Math.imul(k, pt)) |
|
|
1183
|
+
0)) <<
|
|
1184
|
+
13)) |
|
|
1185
|
+
0;
|
|
1186
|
+
(m =
|
|
1187
|
+
((((o = (o + Math.imul(k, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1188
|
+
(It >>> 26)) |
|
|
1189
|
+
0),
|
|
1190
|
+
(It &= 67108863),
|
|
1191
|
+
(n = Math.imul(N, J)),
|
|
1192
|
+
(r = ((r = Math.imul(N, tt)) + Math.imul(W, J)) | 0),
|
|
1193
|
+
(o = Math.imul(W, tt)),
|
|
1194
|
+
(n = (n + Math.imul(K, it)) | 0),
|
|
1195
|
+
(r = ((r = (r + Math.imul(K, nt)) | 0) + Math.imul(L, it)) | 0),
|
|
1196
|
+
(o = (o + Math.imul(L, nt)) | 0),
|
|
1197
|
+
(n = (n + Math.imul(D, ot)) | 0),
|
|
1198
|
+
(r = ((r = (r + Math.imul(D, st)) | 0) + Math.imul(E, ot)) | 0),
|
|
1199
|
+
(o = (o + Math.imul(E, st)) | 0),
|
|
1200
|
+
(n = (n + Math.imul(x, ut)) | 0),
|
|
1201
|
+
(r = ((r = (r + Math.imul(x, mt)) | 0) + Math.imul(_, ut)) | 0),
|
|
1202
|
+
(o = (o + Math.imul(_, mt)) | 0),
|
|
1203
|
+
(n = (n + Math.imul(T, lt)) | 0),
|
|
1204
|
+
(r = ((r = (r + Math.imul(T, dt)) | 0) + Math.imul(C, lt)) | 0),
|
|
1205
|
+
(o = (o + Math.imul(C, dt)) | 0);
|
|
1206
|
+
var xt =
|
|
1207
|
+
(((m + (n = (n + Math.imul(P, pt)) | 0)) | 0) +
|
|
1208
|
+
((8191 &
|
|
1209
|
+
(r =
|
|
1210
|
+
((r = (r + Math.imul(P, gt)) | 0) + Math.imul(S, pt)) |
|
|
1211
|
+
0)) <<
|
|
1212
|
+
13)) |
|
|
1213
|
+
0;
|
|
1214
|
+
(m =
|
|
1215
|
+
((((o = (o + Math.imul(S, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1216
|
+
(xt >>> 26)) |
|
|
1217
|
+
0),
|
|
1218
|
+
(xt &= 67108863),
|
|
1219
|
+
(n = Math.imul(N, it)),
|
|
1220
|
+
(r = ((r = Math.imul(N, nt)) + Math.imul(W, it)) | 0),
|
|
1221
|
+
(o = Math.imul(W, nt)),
|
|
1222
|
+
(n = (n + Math.imul(K, ot)) | 0),
|
|
1223
|
+
(r = ((r = (r + Math.imul(K, st)) | 0) + Math.imul(L, ot)) | 0),
|
|
1224
|
+
(o = (o + Math.imul(L, st)) | 0),
|
|
1225
|
+
(n = (n + Math.imul(D, ut)) | 0),
|
|
1226
|
+
(r = ((r = (r + Math.imul(D, mt)) | 0) + Math.imul(E, ut)) | 0),
|
|
1227
|
+
(o = (o + Math.imul(E, mt)) | 0),
|
|
1228
|
+
(n = (n + Math.imul(x, lt)) | 0),
|
|
1229
|
+
(r = ((r = (r + Math.imul(x, dt)) | 0) + Math.imul(_, lt)) | 0),
|
|
1230
|
+
(o = (o + Math.imul(_, dt)) | 0);
|
|
1231
|
+
var _t =
|
|
1232
|
+
(((m + (n = (n + Math.imul(T, pt)) | 0)) | 0) +
|
|
1233
|
+
((8191 &
|
|
1234
|
+
(r =
|
|
1235
|
+
((r = (r + Math.imul(T, gt)) | 0) + Math.imul(C, pt)) |
|
|
1236
|
+
0)) <<
|
|
1237
|
+
13)) |
|
|
1238
|
+
0;
|
|
1239
|
+
(m =
|
|
1240
|
+
((((o = (o + Math.imul(C, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1241
|
+
(_t >>> 26)) |
|
|
1242
|
+
0),
|
|
1243
|
+
(_t &= 67108863),
|
|
1244
|
+
(n = Math.imul(N, ot)),
|
|
1245
|
+
(r = ((r = Math.imul(N, st)) + Math.imul(W, ot)) | 0),
|
|
1246
|
+
(o = Math.imul(W, st)),
|
|
1247
|
+
(n = (n + Math.imul(K, ut)) | 0),
|
|
1248
|
+
(r = ((r = (r + Math.imul(K, mt)) | 0) + Math.imul(L, ut)) | 0),
|
|
1249
|
+
(o = (o + Math.imul(L, mt)) | 0),
|
|
1250
|
+
(n = (n + Math.imul(D, lt)) | 0),
|
|
1251
|
+
(r = ((r = (r + Math.imul(D, dt)) | 0) + Math.imul(E, lt)) | 0),
|
|
1252
|
+
(o = (o + Math.imul(E, dt)) | 0);
|
|
1253
|
+
var Ot =
|
|
1254
|
+
(((m + (n = (n + Math.imul(x, pt)) | 0)) | 0) +
|
|
1255
|
+
((8191 &
|
|
1256
|
+
(r =
|
|
1257
|
+
((r = (r + Math.imul(x, gt)) | 0) + Math.imul(_, pt)) |
|
|
1258
|
+
0)) <<
|
|
1259
|
+
13)) |
|
|
1260
|
+
0;
|
|
1261
|
+
(m =
|
|
1262
|
+
((((o = (o + Math.imul(_, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1263
|
+
(Ot >>> 26)) |
|
|
1264
|
+
0),
|
|
1265
|
+
(Ot &= 67108863),
|
|
1266
|
+
(n = Math.imul(N, ut)),
|
|
1267
|
+
(r = ((r = Math.imul(N, mt)) + Math.imul(W, ut)) | 0),
|
|
1268
|
+
(o = Math.imul(W, mt)),
|
|
1269
|
+
(n = (n + Math.imul(K, lt)) | 0),
|
|
1270
|
+
(r = ((r = (r + Math.imul(K, dt)) | 0) + Math.imul(L, lt)) | 0),
|
|
1271
|
+
(o = (o + Math.imul(L, dt)) | 0);
|
|
1272
|
+
var Dt =
|
|
1273
|
+
(((m + (n = (n + Math.imul(D, pt)) | 0)) | 0) +
|
|
1274
|
+
((8191 &
|
|
1275
|
+
(r =
|
|
1276
|
+
((r = (r + Math.imul(D, gt)) | 0) + Math.imul(E, pt)) |
|
|
1277
|
+
0)) <<
|
|
1278
|
+
13)) |
|
|
1279
|
+
0;
|
|
1280
|
+
(m =
|
|
1281
|
+
((((o = (o + Math.imul(E, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1282
|
+
(Dt >>> 26)) |
|
|
1283
|
+
0),
|
|
1284
|
+
(Dt &= 67108863),
|
|
1285
|
+
(n = Math.imul(N, lt)),
|
|
1286
|
+
(r = ((r = Math.imul(N, dt)) + Math.imul(W, lt)) | 0),
|
|
1287
|
+
(o = Math.imul(W, dt));
|
|
1288
|
+
var Et =
|
|
1289
|
+
(((m + (n = (n + Math.imul(K, pt)) | 0)) | 0) +
|
|
1290
|
+
((8191 &
|
|
1291
|
+
(r =
|
|
1292
|
+
((r = (r + Math.imul(K, gt)) | 0) + Math.imul(L, pt)) |
|
|
1293
|
+
0)) <<
|
|
1294
|
+
13)) |
|
|
1295
|
+
0;
|
|
1296
|
+
(m =
|
|
1297
|
+
((((o = (o + Math.imul(L, gt)) | 0) + (r >>> 13)) | 0) +
|
|
1298
|
+
(Et >>> 26)) |
|
|
1299
|
+
0),
|
|
1300
|
+
(Et &= 67108863);
|
|
1301
|
+
var Bt =
|
|
1302
|
+
(((m + (n = Math.imul(N, pt))) | 0) +
|
|
1303
|
+
((8191 &
|
|
1304
|
+
(r = ((r = Math.imul(N, gt)) + Math.imul(W, pt)) | 0)) <<
|
|
1305
|
+
13)) |
|
|
1306
|
+
0;
|
|
1307
|
+
return (
|
|
1308
|
+
(m =
|
|
1309
|
+
((((o = Math.imul(W, gt)) + (r >>> 13)) | 0) + (Bt >>> 26)) |
|
|
1310
|
+
0),
|
|
1311
|
+
(Bt &= 67108863),
|
|
1312
|
+
(u[0] = ft),
|
|
1313
|
+
(u[1] = yt),
|
|
1314
|
+
(u[2] = Mt),
|
|
1315
|
+
(u[3] = vt),
|
|
1316
|
+
(u[4] = wt),
|
|
1317
|
+
(u[5] = kt),
|
|
1318
|
+
(u[6] = bt),
|
|
1319
|
+
(u[7] = Pt),
|
|
1320
|
+
(u[8] = St),
|
|
1321
|
+
(u[9] = At),
|
|
1322
|
+
(u[10] = Tt),
|
|
1323
|
+
(u[11] = Ct),
|
|
1324
|
+
(u[12] = It),
|
|
1325
|
+
(u[13] = xt),
|
|
1326
|
+
(u[14] = _t),
|
|
1327
|
+
(u[15] = Ot),
|
|
1328
|
+
(u[16] = Dt),
|
|
1329
|
+
(u[17] = Et),
|
|
1330
|
+
(u[18] = Bt),
|
|
1331
|
+
0 !== m && ((u[19] = m), i.length++),
|
|
1332
|
+
i
|
|
1333
|
+
);
|
|
1334
|
+
};
|
|
1335
|
+
function M(t, e, i) {
|
|
1336
|
+
(i.negative = e.negative ^ t.negative),
|
|
1337
|
+
(i.length = t.length + e.length);
|
|
1338
|
+
for (var n = 0, r = 0, o = 0; o < i.length - 1; o++) {
|
|
1339
|
+
var s = r;
|
|
1340
|
+
r = 0;
|
|
1341
|
+
for (
|
|
1342
|
+
var a = 67108863 & n,
|
|
1343
|
+
u = Math.min(o, e.length - 1),
|
|
1344
|
+
m = Math.max(0, o - t.length + 1);
|
|
1345
|
+
m <= u;
|
|
1346
|
+
m++
|
|
1347
|
+
) {
|
|
1348
|
+
var h = o - m,
|
|
1349
|
+
l = (0 | t.words[h]) * (0 | e.words[m]),
|
|
1350
|
+
d = 67108863 & l;
|
|
1351
|
+
(a = 67108863 & (d = (d + a) | 0)),
|
|
1352
|
+
(r +=
|
|
1353
|
+
(s =
|
|
1354
|
+
((s = (s + ((l / 67108864) | 0)) | 0) +
|
|
1355
|
+
(d >>> 26)) |
|
|
1356
|
+
0) >>> 26),
|
|
1357
|
+
(s &= 67108863);
|
|
1358
|
+
}
|
|
1359
|
+
(i.words[o] = a), (n = s), (s = r);
|
|
1360
|
+
}
|
|
1361
|
+
return 0 !== n ? (i.words[o] = n) : i.length--, i._strip();
|
|
1362
|
+
}
|
|
1363
|
+
function v(t, e, i) {
|
|
1364
|
+
return M(t, e, i);
|
|
1365
|
+
}
|
|
1366
|
+
Math.imul || (y = p),
|
|
1367
|
+
(r.prototype.mulTo = function (t, e) {
|
|
1368
|
+
var i = this.length + t.length;
|
|
1369
|
+
return 10 === this.length && 10 === t.length
|
|
1370
|
+
? y(this, t, e)
|
|
1371
|
+
: i < 63
|
|
1372
|
+
? p(this, t, e)
|
|
1373
|
+
: i < 1024
|
|
1374
|
+
? M(this, t, e)
|
|
1375
|
+
: v(this, t, e);
|
|
1376
|
+
}),
|
|
1377
|
+
(r.prototype.mul = function (t) {
|
|
1378
|
+
var e = new r(null);
|
|
1379
|
+
return (
|
|
1380
|
+
(e.words = new Array(this.length + t.length)), this.mulTo(t, e)
|
|
1381
|
+
);
|
|
1382
|
+
}),
|
|
1383
|
+
(r.prototype.mulf = function (t) {
|
|
1384
|
+
var e = new r(null);
|
|
1385
|
+
return (e.words = new Array(this.length + t.length)), v(this, t, e);
|
|
1386
|
+
}),
|
|
1387
|
+
(r.prototype.imul = function (t) {
|
|
1388
|
+
return this.clone().mulTo(t, this);
|
|
1389
|
+
}),
|
|
1390
|
+
(r.prototype.imuln = function (t) {
|
|
1391
|
+
var e = t < 0;
|
|
1392
|
+
e && (t = -t), i('number' == typeof t), i(t < 67108864);
|
|
1393
|
+
for (var n = 0, r = 0; r < this.length; r++) {
|
|
1394
|
+
var o = (0 | this.words[r]) * t,
|
|
1395
|
+
s = (67108863 & o) + (67108863 & n);
|
|
1396
|
+
(n >>= 26),
|
|
1397
|
+
(n += (o / 67108864) | 0),
|
|
1398
|
+
(n += s >>> 26),
|
|
1399
|
+
(this.words[r] = 67108863 & s);
|
|
1400
|
+
}
|
|
1401
|
+
return (
|
|
1402
|
+
0 !== n && ((this.words[r] = n), this.length++),
|
|
1403
|
+
e ? this.ineg() : this
|
|
1404
|
+
);
|
|
1405
|
+
}),
|
|
1406
|
+
(r.prototype.muln = function (t) {
|
|
1407
|
+
return this.clone().imuln(t);
|
|
1408
|
+
}),
|
|
1409
|
+
(r.prototype.sqr = function () {
|
|
1410
|
+
return this.mul(this);
|
|
1411
|
+
}),
|
|
1412
|
+
(r.prototype.isqr = function () {
|
|
1413
|
+
return this.imul(this.clone());
|
|
1414
|
+
}),
|
|
1415
|
+
(r.prototype.pow = function (t) {
|
|
1416
|
+
var e = (function (t) {
|
|
1417
|
+
for (
|
|
1418
|
+
var e = new Array(t.bitLength()), i = 0;
|
|
1419
|
+
i < e.length;
|
|
1420
|
+
i++
|
|
1421
|
+
) {
|
|
1422
|
+
var n = (i / 26) | 0,
|
|
1423
|
+
r = i % 26;
|
|
1424
|
+
e[i] = (t.words[n] >>> r) & 1;
|
|
1425
|
+
}
|
|
1426
|
+
return e;
|
|
1427
|
+
})(t);
|
|
1428
|
+
if (0 === e.length) return new r(1);
|
|
1429
|
+
for (
|
|
1430
|
+
var i = this, n = 0;
|
|
1431
|
+
n < e.length && 0 === e[n];
|
|
1432
|
+
n++, i = i.sqr()
|
|
1433
|
+
);
|
|
1434
|
+
if (++n < e.length)
|
|
1435
|
+
for (var o = i.sqr(); n < e.length; n++, o = o.sqr())
|
|
1436
|
+
0 !== e[n] && (i = i.mul(o));
|
|
1437
|
+
return i;
|
|
1438
|
+
}),
|
|
1439
|
+
(r.prototype.iushln = function (t) {
|
|
1440
|
+
i('number' == typeof t && t >= 0);
|
|
1441
|
+
var e,
|
|
1442
|
+
n = t % 26,
|
|
1443
|
+
r = (t - n) / 26,
|
|
1444
|
+
o = (67108863 >>> (26 - n)) << (26 - n);
|
|
1445
|
+
if (0 !== n) {
|
|
1446
|
+
var s = 0;
|
|
1447
|
+
for (e = 0; e < this.length; e++) {
|
|
1448
|
+
var a = this.words[e] & o,
|
|
1449
|
+
u = ((0 | this.words[e]) - a) << n;
|
|
1450
|
+
(this.words[e] = u | s), (s = a >>> (26 - n));
|
|
1451
|
+
}
|
|
1452
|
+
s && ((this.words[e] = s), this.length++);
|
|
1453
|
+
}
|
|
1454
|
+
if (0 !== r) {
|
|
1455
|
+
for (e = this.length - 1; e >= 0; e--)
|
|
1456
|
+
this.words[e + r] = this.words[e];
|
|
1457
|
+
for (e = 0; e < r; e++) this.words[e] = 0;
|
|
1458
|
+
this.length += r;
|
|
1459
|
+
}
|
|
1460
|
+
return this._strip();
|
|
1461
|
+
}),
|
|
1462
|
+
(r.prototype.ishln = function (t) {
|
|
1463
|
+
return i(0 === this.negative), this.iushln(t);
|
|
1464
|
+
}),
|
|
1465
|
+
(r.prototype.iushrn = function (t, e, n) {
|
|
1466
|
+
var r;
|
|
1467
|
+
i('number' == typeof t && t >= 0),
|
|
1468
|
+
(r = e ? (e - (e % 26)) / 26 : 0);
|
|
1469
|
+
var o = t % 26,
|
|
1470
|
+
s = Math.min((t - o) / 26, this.length),
|
|
1471
|
+
a = 67108863 ^ ((67108863 >>> o) << o),
|
|
1472
|
+
u = n;
|
|
1473
|
+
if (((r -= s), (r = Math.max(0, r)), u)) {
|
|
1474
|
+
for (var m = 0; m < s; m++) u.words[m] = this.words[m];
|
|
1475
|
+
u.length = s;
|
|
1476
|
+
}
|
|
1477
|
+
if (0 === s);
|
|
1478
|
+
else if (this.length > s)
|
|
1479
|
+
for (this.length -= s, m = 0; m < this.length; m++)
|
|
1480
|
+
this.words[m] = this.words[m + s];
|
|
1481
|
+
else (this.words[0] = 0), (this.length = 1);
|
|
1482
|
+
var h = 0;
|
|
1483
|
+
for (m = this.length - 1; m >= 0 && (0 !== h || m >= r); m--) {
|
|
1484
|
+
var l = 0 | this.words[m];
|
|
1485
|
+
(this.words[m] = (h << (26 - o)) | (l >>> o)), (h = l & a);
|
|
1486
|
+
}
|
|
1487
|
+
return (
|
|
1488
|
+
u && 0 !== h && (u.words[u.length++] = h),
|
|
1489
|
+
0 === this.length && ((this.words[0] = 0), (this.length = 1)),
|
|
1490
|
+
this._strip()
|
|
1491
|
+
);
|
|
1492
|
+
}),
|
|
1493
|
+
(r.prototype.ishrn = function (t, e, n) {
|
|
1494
|
+
return i(0 === this.negative), this.iushrn(t, e, n);
|
|
1495
|
+
}),
|
|
1496
|
+
(r.prototype.shln = function (t) {
|
|
1497
|
+
return this.clone().ishln(t);
|
|
1498
|
+
}),
|
|
1499
|
+
(r.prototype.ushln = function (t) {
|
|
1500
|
+
return this.clone().iushln(t);
|
|
1501
|
+
}),
|
|
1502
|
+
(r.prototype.shrn = function (t) {
|
|
1503
|
+
return this.clone().ishrn(t);
|
|
1504
|
+
}),
|
|
1505
|
+
(r.prototype.ushrn = function (t) {
|
|
1506
|
+
return this.clone().iushrn(t);
|
|
1507
|
+
}),
|
|
1508
|
+
(r.prototype.testn = function (t) {
|
|
1509
|
+
i('number' == typeof t && t >= 0);
|
|
1510
|
+
var e = t % 26,
|
|
1511
|
+
n = (t - e) / 26,
|
|
1512
|
+
r = 1 << e;
|
|
1513
|
+
return this.length <= n ? 0 : !!(this.words[n] & r);
|
|
1514
|
+
}),
|
|
1515
|
+
(r.prototype.imaskn = function (t) {
|
|
1516
|
+
i('number' == typeof t && t >= 0);
|
|
1517
|
+
var e = t % 26,
|
|
1518
|
+
n = (t - e) / 26;
|
|
1519
|
+
if (
|
|
1520
|
+
(i(
|
|
1521
|
+
0 === this.negative,
|
|
1522
|
+
'imaskn works only with positive numbers',
|
|
1523
|
+
),
|
|
1524
|
+
this.length <= n)
|
|
1525
|
+
)
|
|
1526
|
+
return this;
|
|
1527
|
+
if (
|
|
1528
|
+
(0 !== e && n++,
|
|
1529
|
+
(this.length = Math.min(n, this.length)),
|
|
1530
|
+
0 !== e)
|
|
1531
|
+
) {
|
|
1532
|
+
var r = 67108863 ^ ((67108863 >>> e) << e);
|
|
1533
|
+
this.words[this.length - 1] &= r;
|
|
1534
|
+
}
|
|
1535
|
+
return this._strip();
|
|
1536
|
+
}),
|
|
1537
|
+
(r.prototype.maskn = function (t) {
|
|
1538
|
+
return this.clone().imaskn(t);
|
|
1539
|
+
}),
|
|
1540
|
+
(r.prototype.iaddn = function (t) {
|
|
1541
|
+
return (
|
|
1542
|
+
i('number' == typeof t),
|
|
1543
|
+
i(t < 67108864),
|
|
1544
|
+
t < 0
|
|
1545
|
+
? this.isubn(-t)
|
|
1546
|
+
: 0 !== this.negative
|
|
1547
|
+
? 1 === this.length && (0 | this.words[0]) <= t
|
|
1548
|
+
? ((this.words[0] = t - (0 | this.words[0])),
|
|
1549
|
+
(this.negative = 0),
|
|
1550
|
+
this)
|
|
1551
|
+
: ((this.negative = 0),
|
|
1552
|
+
this.isubn(t),
|
|
1553
|
+
(this.negative = 1),
|
|
1554
|
+
this)
|
|
1555
|
+
: this._iaddn(t)
|
|
1556
|
+
);
|
|
1557
|
+
}),
|
|
1558
|
+
(r.prototype._iaddn = function (t) {
|
|
1559
|
+
this.words[0] += t;
|
|
1560
|
+
for (var e = 0; e < this.length && this.words[e] >= 67108864; e++)
|
|
1561
|
+
(this.words[e] -= 67108864),
|
|
1562
|
+
e === this.length - 1
|
|
1563
|
+
? (this.words[e + 1] = 1)
|
|
1564
|
+
: this.words[e + 1]++;
|
|
1565
|
+
return (this.length = Math.max(this.length, e + 1)), this;
|
|
1566
|
+
}),
|
|
1567
|
+
(r.prototype.isubn = function (t) {
|
|
1568
|
+
if ((i('number' == typeof t), i(t < 67108864), t < 0))
|
|
1569
|
+
return this.iaddn(-t);
|
|
1570
|
+
if (0 !== this.negative)
|
|
1571
|
+
return (
|
|
1572
|
+
(this.negative = 0),
|
|
1573
|
+
this.iaddn(t),
|
|
1574
|
+
(this.negative = 1),
|
|
1575
|
+
this
|
|
1576
|
+
);
|
|
1577
|
+
if (((this.words[0] -= t), 1 === this.length && this.words[0] < 0))
|
|
1578
|
+
(this.words[0] = -this.words[0]), (this.negative = 1);
|
|
1579
|
+
else
|
|
1580
|
+
for (var e = 0; e < this.length && this.words[e] < 0; e++)
|
|
1581
|
+
(this.words[e] += 67108864), (this.words[e + 1] -= 1);
|
|
1582
|
+
return this._strip();
|
|
1583
|
+
}),
|
|
1584
|
+
(r.prototype.addn = function (t) {
|
|
1585
|
+
return this.clone().iaddn(t);
|
|
1586
|
+
}),
|
|
1587
|
+
(r.prototype.subn = function (t) {
|
|
1588
|
+
return this.clone().isubn(t);
|
|
1589
|
+
}),
|
|
1590
|
+
(r.prototype.iabs = function () {
|
|
1591
|
+
return (this.negative = 0), this;
|
|
1592
|
+
}),
|
|
1593
|
+
(r.prototype.abs = function () {
|
|
1594
|
+
return this.clone().iabs();
|
|
1595
|
+
}),
|
|
1596
|
+
(r.prototype._ishlnsubmul = function (t, e, n) {
|
|
1597
|
+
var r,
|
|
1598
|
+
o,
|
|
1599
|
+
s = t.length + n;
|
|
1600
|
+
this._expand(s);
|
|
1601
|
+
var a = 0;
|
|
1602
|
+
for (r = 0; r < t.length; r++) {
|
|
1603
|
+
o = (0 | this.words[r + n]) + a;
|
|
1604
|
+
var u = (0 | t.words[r]) * e;
|
|
1605
|
+
(a = ((o -= 67108863 & u) >> 26) - ((u / 67108864) | 0)),
|
|
1606
|
+
(this.words[r + n] = 67108863 & o);
|
|
1607
|
+
}
|
|
1608
|
+
for (; r < this.length - n; r++)
|
|
1609
|
+
(a = (o = (0 | this.words[r + n]) + a) >> 26),
|
|
1610
|
+
(this.words[r + n] = 67108863 & o);
|
|
1611
|
+
if (0 === a) return this._strip();
|
|
1612
|
+
for (i(-1 === a), a = 0, r = 0; r < this.length; r++)
|
|
1613
|
+
(a = (o = -(0 | this.words[r]) + a) >> 26),
|
|
1614
|
+
(this.words[r] = 67108863 & o);
|
|
1615
|
+
return (this.negative = 1), this._strip();
|
|
1616
|
+
}),
|
|
1617
|
+
(r.prototype._wordDiv = function (t, e) {
|
|
1618
|
+
var i = (this.length, t.length),
|
|
1619
|
+
n = this.clone(),
|
|
1620
|
+
o = t,
|
|
1621
|
+
s = 0 | o.words[o.length - 1];
|
|
1622
|
+
0 != (i = 26 - this._countBits(s)) &&
|
|
1623
|
+
((o = o.ushln(i)),
|
|
1624
|
+
n.iushln(i),
|
|
1625
|
+
(s = 0 | o.words[o.length - 1]));
|
|
1626
|
+
var a,
|
|
1627
|
+
u = n.length - o.length;
|
|
1628
|
+
if ('mod' !== e) {
|
|
1629
|
+
((a = new r(null)).length = u + 1),
|
|
1630
|
+
(a.words = new Array(a.length));
|
|
1631
|
+
for (var m = 0; m < a.length; m++) a.words[m] = 0;
|
|
1632
|
+
}
|
|
1633
|
+
var h = n.clone()._ishlnsubmul(o, 1, u);
|
|
1634
|
+
0 === h.negative && ((n = h), a && (a.words[u] = 1));
|
|
1635
|
+
for (var l = u - 1; l >= 0; l--) {
|
|
1636
|
+
var d =
|
|
1637
|
+
67108864 * (0 | n.words[o.length + l]) +
|
|
1638
|
+
(0 | n.words[o.length + l - 1]);
|
|
1639
|
+
for (
|
|
1640
|
+
d = Math.min((d / s) | 0, 67108863),
|
|
1641
|
+
n._ishlnsubmul(o, d, l);
|
|
1642
|
+
0 !== n.negative;
|
|
1643
|
+
|
|
1644
|
+
)
|
|
1645
|
+
d--,
|
|
1646
|
+
(n.negative = 0),
|
|
1647
|
+
n._ishlnsubmul(o, 1, l),
|
|
1648
|
+
n.isZero() || (n.negative ^= 1);
|
|
1649
|
+
a && (a.words[l] = d);
|
|
1650
|
+
}
|
|
1651
|
+
return (
|
|
1652
|
+
a && a._strip(),
|
|
1653
|
+
n._strip(),
|
|
1654
|
+
'div' !== e && 0 !== i && n.iushrn(i),
|
|
1655
|
+
{ div: a || null, mod: n }
|
|
1656
|
+
);
|
|
1657
|
+
}),
|
|
1658
|
+
(r.prototype.divmod = function (t, e, n) {
|
|
1659
|
+
return (
|
|
1660
|
+
i(!t.isZero()),
|
|
1661
|
+
this.isZero()
|
|
1662
|
+
? { div: new r(0), mod: new r(0) }
|
|
1663
|
+
: 0 !== this.negative && 0 === t.negative
|
|
1664
|
+
? ((a = this.neg().divmod(t, e)),
|
|
1665
|
+
'mod' !== e && (o = a.div.neg()),
|
|
1666
|
+
'div' !== e &&
|
|
1667
|
+
((s = a.mod.neg()),
|
|
1668
|
+
n && 0 !== s.negative && s.iadd(t)),
|
|
1669
|
+
{ div: o, mod: s })
|
|
1670
|
+
: 0 === this.negative && 0 !== t.negative
|
|
1671
|
+
? ((a = this.divmod(t.neg(), e)),
|
|
1672
|
+
'mod' !== e && (o = a.div.neg()),
|
|
1673
|
+
{ div: o, mod: a.mod })
|
|
1674
|
+
: 0 != (this.negative & t.negative)
|
|
1675
|
+
? ((a = this.neg().divmod(t.neg(), e)),
|
|
1676
|
+
'div' !== e &&
|
|
1677
|
+
((s = a.mod.neg()),
|
|
1678
|
+
n && 0 !== s.negative && s.isub(t)),
|
|
1679
|
+
{ div: a.div, mod: s })
|
|
1680
|
+
: t.length > this.length || this.cmp(t) < 0
|
|
1681
|
+
? { div: new r(0), mod: this }
|
|
1682
|
+
: 1 === t.length
|
|
1683
|
+
? 'div' === e
|
|
1684
|
+
? { div: this.divn(t.words[0]), mod: null }
|
|
1685
|
+
: 'mod' === e
|
|
1686
|
+
? {
|
|
1687
|
+
div: null,
|
|
1688
|
+
mod: new r(this.modrn(t.words[0])),
|
|
1689
|
+
}
|
|
1690
|
+
: {
|
|
1691
|
+
div: this.divn(t.words[0]),
|
|
1692
|
+
mod: new r(this.modrn(t.words[0])),
|
|
1693
|
+
}
|
|
1694
|
+
: this._wordDiv(t, e)
|
|
1695
|
+
);
|
|
1696
|
+
var o, s, a;
|
|
1697
|
+
}),
|
|
1698
|
+
(r.prototype.div = function (t) {
|
|
1699
|
+
return this.divmod(t, 'div', 0).div;
|
|
1700
|
+
}),
|
|
1701
|
+
(r.prototype.mod = function (t) {
|
|
1702
|
+
return this.divmod(t, 'mod', 0).mod;
|
|
1703
|
+
}),
|
|
1704
|
+
(r.prototype.umod = function (t) {
|
|
1705
|
+
return this.divmod(t, 'mod', 1).mod;
|
|
1706
|
+
}),
|
|
1707
|
+
(r.prototype.divRound = function (t) {
|
|
1708
|
+
var e = this.divmod(t);
|
|
1709
|
+
if (e.mod.isZero()) return e.div;
|
|
1710
|
+
var i = 0 !== e.div.negative ? e.mod.isub(t) : e.mod,
|
|
1711
|
+
n = t.ushrn(1),
|
|
1712
|
+
r = t.andln(1),
|
|
1713
|
+
o = i.cmp(n);
|
|
1714
|
+
return o < 0 || (1 === r && 0 === o)
|
|
1715
|
+
? e.div
|
|
1716
|
+
: 0 !== e.div.negative
|
|
1717
|
+
? e.div.isubn(1)
|
|
1718
|
+
: e.div.iaddn(1);
|
|
1719
|
+
}),
|
|
1720
|
+
(r.prototype.modrn = function (t) {
|
|
1721
|
+
var e = t < 0;
|
|
1722
|
+
e && (t = -t), i(t <= 67108863);
|
|
1723
|
+
for (var n = (1 << 26) % t, r = 0, o = this.length - 1; o >= 0; o--)
|
|
1724
|
+
r = (n * r + (0 | this.words[o])) % t;
|
|
1725
|
+
return e ? -r : r;
|
|
1726
|
+
}),
|
|
1727
|
+
(r.prototype.modn = function (t) {
|
|
1728
|
+
return this.modrn(t);
|
|
1729
|
+
}),
|
|
1730
|
+
(r.prototype.idivn = function (t) {
|
|
1731
|
+
var e = t < 0;
|
|
1732
|
+
e && (t = -t), i(t <= 67108863);
|
|
1733
|
+
for (var n = 0, r = this.length - 1; r >= 0; r--) {
|
|
1734
|
+
var o = (0 | this.words[r]) + 67108864 * n;
|
|
1735
|
+
(this.words[r] = (o / t) | 0), (n = o % t);
|
|
1736
|
+
}
|
|
1737
|
+
return this._strip(), e ? this.ineg() : this;
|
|
1738
|
+
}),
|
|
1739
|
+
(r.prototype.divn = function (t) {
|
|
1740
|
+
return this.clone().idivn(t);
|
|
1741
|
+
}),
|
|
1742
|
+
(r.prototype.egcd = function (t) {
|
|
1743
|
+
i(0 === t.negative), i(!t.isZero());
|
|
1744
|
+
var e = this,
|
|
1745
|
+
n = t.clone();
|
|
1746
|
+
e = 0 !== e.negative ? e.umod(t) : e.clone();
|
|
1747
|
+
for (
|
|
1748
|
+
var o = new r(1),
|
|
1749
|
+
s = new r(0),
|
|
1750
|
+
a = new r(0),
|
|
1751
|
+
u = new r(1),
|
|
1752
|
+
m = 0;
|
|
1753
|
+
e.isEven() && n.isEven();
|
|
1754
|
+
|
|
1755
|
+
)
|
|
1756
|
+
e.iushrn(1), n.iushrn(1), ++m;
|
|
1757
|
+
for (var h = n.clone(), l = e.clone(); !e.isZero(); ) {
|
|
1758
|
+
for (
|
|
1759
|
+
var d = 0, c = 1;
|
|
1760
|
+
0 == (e.words[0] & c) && d < 26;
|
|
1761
|
+
++d, c <<= 1
|
|
1762
|
+
);
|
|
1763
|
+
if (d > 0)
|
|
1764
|
+
for (e.iushrn(d); d-- > 0; )
|
|
1765
|
+
(o.isOdd() || s.isOdd()) && (o.iadd(h), s.isub(l)),
|
|
1766
|
+
o.iushrn(1),
|
|
1767
|
+
s.iushrn(1);
|
|
1768
|
+
for (
|
|
1769
|
+
var p = 0, g = 1;
|
|
1770
|
+
0 == (n.words[0] & g) && p < 26;
|
|
1771
|
+
++p, g <<= 1
|
|
1772
|
+
);
|
|
1773
|
+
if (p > 0)
|
|
1774
|
+
for (n.iushrn(p); p-- > 0; )
|
|
1775
|
+
(a.isOdd() || u.isOdd()) && (a.iadd(h), u.isub(l)),
|
|
1776
|
+
a.iushrn(1),
|
|
1777
|
+
u.iushrn(1);
|
|
1778
|
+
e.cmp(n) >= 0
|
|
1779
|
+
? (e.isub(n), o.isub(a), s.isub(u))
|
|
1780
|
+
: (n.isub(e), a.isub(o), u.isub(s));
|
|
1781
|
+
}
|
|
1782
|
+
return { a: a, b: u, gcd: n.iushln(m) };
|
|
1783
|
+
}),
|
|
1784
|
+
(r.prototype._invmp = function (t) {
|
|
1785
|
+
i(0 === t.negative), i(!t.isZero());
|
|
1786
|
+
var e = this,
|
|
1787
|
+
n = t.clone();
|
|
1788
|
+
e = 0 !== e.negative ? e.umod(t) : e.clone();
|
|
1789
|
+
for (
|
|
1790
|
+
var o, s = new r(1), a = new r(0), u = n.clone();
|
|
1791
|
+
e.cmpn(1) > 0 && n.cmpn(1) > 0;
|
|
1792
|
+
|
|
1793
|
+
) {
|
|
1794
|
+
for (
|
|
1795
|
+
var m = 0, h = 1;
|
|
1796
|
+
0 == (e.words[0] & h) && m < 26;
|
|
1797
|
+
++m, h <<= 1
|
|
1798
|
+
);
|
|
1799
|
+
if (m > 0)
|
|
1800
|
+
for (e.iushrn(m); m-- > 0; )
|
|
1801
|
+
s.isOdd() && s.iadd(u), s.iushrn(1);
|
|
1802
|
+
for (
|
|
1803
|
+
var l = 0, d = 1;
|
|
1804
|
+
0 == (n.words[0] & d) && l < 26;
|
|
1805
|
+
++l, d <<= 1
|
|
1806
|
+
);
|
|
1807
|
+
if (l > 0)
|
|
1808
|
+
for (n.iushrn(l); l-- > 0; )
|
|
1809
|
+
a.isOdd() && a.iadd(u), a.iushrn(1);
|
|
1810
|
+
e.cmp(n) >= 0 ? (e.isub(n), s.isub(a)) : (n.isub(e), a.isub(s));
|
|
1811
|
+
}
|
|
1812
|
+
return (o = 0 === e.cmpn(1) ? s : a).cmpn(0) < 0 && o.iadd(t), o;
|
|
1813
|
+
}),
|
|
1814
|
+
(r.prototype.gcd = function (t) {
|
|
1815
|
+
if (this.isZero()) return t.abs();
|
|
1816
|
+
if (t.isZero()) return this.abs();
|
|
1817
|
+
var e = this.clone(),
|
|
1818
|
+
i = t.clone();
|
|
1819
|
+
(e.negative = 0), (i.negative = 0);
|
|
1820
|
+
for (var n = 0; e.isEven() && i.isEven(); n++)
|
|
1821
|
+
e.iushrn(1), i.iushrn(1);
|
|
1822
|
+
for (;;) {
|
|
1823
|
+
for (; e.isEven(); ) e.iushrn(1);
|
|
1824
|
+
for (; i.isEven(); ) i.iushrn(1);
|
|
1825
|
+
var r = e.cmp(i);
|
|
1826
|
+
if (r < 0) {
|
|
1827
|
+
var o = e;
|
|
1828
|
+
(e = i), (i = o);
|
|
1829
|
+
} else if (0 === r || 0 === i.cmpn(1)) break;
|
|
1830
|
+
e.isub(i);
|
|
1831
|
+
}
|
|
1832
|
+
return i.iushln(n);
|
|
1833
|
+
}),
|
|
1834
|
+
(r.prototype.invm = function (t) {
|
|
1835
|
+
return this.egcd(t).a.umod(t);
|
|
1836
|
+
}),
|
|
1837
|
+
(r.prototype.isEven = function () {
|
|
1838
|
+
return 0 == (1 & this.words[0]);
|
|
1839
|
+
}),
|
|
1840
|
+
(r.prototype.isOdd = function () {
|
|
1841
|
+
return 1 == (1 & this.words[0]);
|
|
1842
|
+
}),
|
|
1843
|
+
(r.prototype.andln = function (t) {
|
|
1844
|
+
return this.words[0] & t;
|
|
1845
|
+
}),
|
|
1846
|
+
(r.prototype.bincn = function (t) {
|
|
1847
|
+
i('number' == typeof t);
|
|
1848
|
+
var e = t % 26,
|
|
1849
|
+
n = (t - e) / 26,
|
|
1850
|
+
r = 1 << e;
|
|
1851
|
+
if (this.length <= n)
|
|
1852
|
+
return this._expand(n + 1), (this.words[n] |= r), this;
|
|
1853
|
+
for (var o = r, s = n; 0 !== o && s < this.length; s++) {
|
|
1854
|
+
var a = 0 | this.words[s];
|
|
1855
|
+
(o = (a += o) >>> 26), (a &= 67108863), (this.words[s] = a);
|
|
1856
|
+
}
|
|
1857
|
+
return 0 !== o && ((this.words[s] = o), this.length++), this;
|
|
1858
|
+
}),
|
|
1859
|
+
(r.prototype.isZero = function () {
|
|
1860
|
+
return 1 === this.length && 0 === this.words[0];
|
|
1861
|
+
}),
|
|
1862
|
+
(r.prototype.cmpn = function (t) {
|
|
1863
|
+
var e,
|
|
1864
|
+
n = t < 0;
|
|
1865
|
+
if (0 !== this.negative && !n) return -1;
|
|
1866
|
+
if (0 === this.negative && n) return 1;
|
|
1867
|
+
if ((this._strip(), this.length > 1)) e = 1;
|
|
1868
|
+
else {
|
|
1869
|
+
n && (t = -t), i(t <= 67108863, 'Number is too big');
|
|
1870
|
+
var r = 0 | this.words[0];
|
|
1871
|
+
e = r === t ? 0 : r < t ? -1 : 1;
|
|
1872
|
+
}
|
|
1873
|
+
return 0 !== this.negative ? 0 | -e : e;
|
|
1874
|
+
}),
|
|
1875
|
+
(r.prototype.cmp = function (t) {
|
|
1876
|
+
if (0 !== this.negative && 0 === t.negative) return -1;
|
|
1877
|
+
if (0 === this.negative && 0 !== t.negative) return 1;
|
|
1878
|
+
var e = this.ucmp(t);
|
|
1879
|
+
return 0 !== this.negative ? 0 | -e : e;
|
|
1880
|
+
}),
|
|
1881
|
+
(r.prototype.ucmp = function (t) {
|
|
1882
|
+
if (this.length > t.length) return 1;
|
|
1883
|
+
if (this.length < t.length) return -1;
|
|
1884
|
+
for (var e = 0, i = this.length - 1; i >= 0; i--) {
|
|
1885
|
+
var n = 0 | this.words[i],
|
|
1886
|
+
r = 0 | t.words[i];
|
|
1887
|
+
if (n !== r) {
|
|
1888
|
+
n < r ? (e = -1) : n > r && (e = 1);
|
|
1889
|
+
break;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
return e;
|
|
1893
|
+
}),
|
|
1894
|
+
(r.prototype.gtn = function (t) {
|
|
1895
|
+
return 1 === this.cmpn(t);
|
|
1896
|
+
}),
|
|
1897
|
+
(r.prototype.gt = function (t) {
|
|
1898
|
+
return 1 === this.cmp(t);
|
|
1899
|
+
}),
|
|
1900
|
+
(r.prototype.gten = function (t) {
|
|
1901
|
+
return this.cmpn(t) >= 0;
|
|
1902
|
+
}),
|
|
1903
|
+
(r.prototype.gte = function (t) {
|
|
1904
|
+
return this.cmp(t) >= 0;
|
|
1905
|
+
}),
|
|
1906
|
+
(r.prototype.ltn = function (t) {
|
|
1907
|
+
return -1 === this.cmpn(t);
|
|
1908
|
+
}),
|
|
1909
|
+
(r.prototype.lt = function (t) {
|
|
1910
|
+
return -1 === this.cmp(t);
|
|
1911
|
+
}),
|
|
1912
|
+
(r.prototype.lten = function (t) {
|
|
1913
|
+
return this.cmpn(t) <= 0;
|
|
1914
|
+
}),
|
|
1915
|
+
(r.prototype.lte = function (t) {
|
|
1916
|
+
return this.cmp(t) <= 0;
|
|
1917
|
+
}),
|
|
1918
|
+
(r.prototype.eqn = function (t) {
|
|
1919
|
+
return 0 === this.cmpn(t);
|
|
1920
|
+
}),
|
|
1921
|
+
(r.prototype.eq = function (t) {
|
|
1922
|
+
return 0 === this.cmp(t);
|
|
1923
|
+
}),
|
|
1924
|
+
(r.red = function (t) {
|
|
1925
|
+
return new T(t);
|
|
1926
|
+
}),
|
|
1927
|
+
(r.prototype.toRed = function (t) {
|
|
1928
|
+
return (
|
|
1929
|
+
i(!this.red, 'Already a number in reduction context'),
|
|
1930
|
+
i(0 === this.negative, 'red works only with positives'),
|
|
1931
|
+
t.convertTo(this)._forceRed(t)
|
|
1932
|
+
);
|
|
1933
|
+
}),
|
|
1934
|
+
(r.prototype.fromRed = function () {
|
|
1935
|
+
return (
|
|
1936
|
+
i(
|
|
1937
|
+
this.red,
|
|
1938
|
+
'fromRed works only with numbers in reduction context',
|
|
1939
|
+
),
|
|
1940
|
+
this.red.convertFrom(this)
|
|
1941
|
+
);
|
|
1942
|
+
}),
|
|
1943
|
+
(r.prototype._forceRed = function (t) {
|
|
1944
|
+
return (this.red = t), this;
|
|
1945
|
+
}),
|
|
1946
|
+
(r.prototype.forceRed = function (t) {
|
|
1947
|
+
return (
|
|
1948
|
+
i(!this.red, 'Already a number in reduction context'),
|
|
1949
|
+
this._forceRed(t)
|
|
1950
|
+
);
|
|
1951
|
+
}),
|
|
1952
|
+
(r.prototype.redAdd = function (t) {
|
|
1953
|
+
return (
|
|
1954
|
+
i(this.red, 'redAdd works only with red numbers'),
|
|
1955
|
+
this.red.add(this, t)
|
|
1956
|
+
);
|
|
1957
|
+
}),
|
|
1958
|
+
(r.prototype.redIAdd = function (t) {
|
|
1959
|
+
return (
|
|
1960
|
+
i(this.red, 'redIAdd works only with red numbers'),
|
|
1961
|
+
this.red.iadd(this, t)
|
|
1962
|
+
);
|
|
1963
|
+
}),
|
|
1964
|
+
(r.prototype.redSub = function (t) {
|
|
1965
|
+
return (
|
|
1966
|
+
i(this.red, 'redSub works only with red numbers'),
|
|
1967
|
+
this.red.sub(this, t)
|
|
1968
|
+
);
|
|
1969
|
+
}),
|
|
1970
|
+
(r.prototype.redISub = function (t) {
|
|
1971
|
+
return (
|
|
1972
|
+
i(this.red, 'redISub works only with red numbers'),
|
|
1973
|
+
this.red.isub(this, t)
|
|
1974
|
+
);
|
|
1975
|
+
}),
|
|
1976
|
+
(r.prototype.redShl = function (t) {
|
|
1977
|
+
return (
|
|
1978
|
+
i(this.red, 'redShl works only with red numbers'),
|
|
1979
|
+
this.red.shl(this, t)
|
|
1980
|
+
);
|
|
1981
|
+
}),
|
|
1982
|
+
(r.prototype.redMul = function (t) {
|
|
1983
|
+
return (
|
|
1984
|
+
i(this.red, 'redMul works only with red numbers'),
|
|
1985
|
+
this.red._verify2(this, t),
|
|
1986
|
+
this.red.mul(this, t)
|
|
1987
|
+
);
|
|
1988
|
+
}),
|
|
1989
|
+
(r.prototype.redIMul = function (t) {
|
|
1990
|
+
return (
|
|
1991
|
+
i(this.red, 'redMul works only with red numbers'),
|
|
1992
|
+
this.red._verify2(this, t),
|
|
1993
|
+
this.red.imul(this, t)
|
|
1994
|
+
);
|
|
1995
|
+
}),
|
|
1996
|
+
(r.prototype.redSqr = function () {
|
|
1997
|
+
return (
|
|
1998
|
+
i(this.red, 'redSqr works only with red numbers'),
|
|
1999
|
+
this.red._verify1(this),
|
|
2000
|
+
this.red.sqr(this)
|
|
2001
|
+
);
|
|
2002
|
+
}),
|
|
2003
|
+
(r.prototype.redISqr = function () {
|
|
2004
|
+
return (
|
|
2005
|
+
i(this.red, 'redISqr works only with red numbers'),
|
|
2006
|
+
this.red._verify1(this),
|
|
2007
|
+
this.red.isqr(this)
|
|
2008
|
+
);
|
|
2009
|
+
}),
|
|
2010
|
+
(r.prototype.redSqrt = function () {
|
|
2011
|
+
return (
|
|
2012
|
+
i(this.red, 'redSqrt works only with red numbers'),
|
|
2013
|
+
this.red._verify1(this),
|
|
2014
|
+
this.red.sqrt(this)
|
|
2015
|
+
);
|
|
2016
|
+
}),
|
|
2017
|
+
(r.prototype.redInvm = function () {
|
|
2018
|
+
return (
|
|
2019
|
+
i(this.red, 'redInvm works only with red numbers'),
|
|
2020
|
+
this.red._verify1(this),
|
|
2021
|
+
this.red.invm(this)
|
|
2022
|
+
);
|
|
2023
|
+
}),
|
|
2024
|
+
(r.prototype.redNeg = function () {
|
|
2025
|
+
return (
|
|
2026
|
+
i(this.red, 'redNeg works only with red numbers'),
|
|
2027
|
+
this.red._verify1(this),
|
|
2028
|
+
this.red.neg(this)
|
|
2029
|
+
);
|
|
2030
|
+
}),
|
|
2031
|
+
(r.prototype.redPow = function (t) {
|
|
2032
|
+
return (
|
|
2033
|
+
i(this.red && !t.red, 'redPow(normalNum)'),
|
|
2034
|
+
this.red._verify1(this),
|
|
2035
|
+
this.red.pow(this, t)
|
|
2036
|
+
);
|
|
2037
|
+
});
|
|
2038
|
+
var w = { k256: null, p224: null, p192: null, p25519: null };
|
|
2039
|
+
function k(t, e) {
|
|
2040
|
+
(this.name = t),
|
|
2041
|
+
(this.p = new r(e, 16)),
|
|
2042
|
+
(this.n = this.p.bitLength()),
|
|
2043
|
+
(this.k = new r(1).iushln(this.n).isub(this.p)),
|
|
2044
|
+
(this.tmp = this._tmp());
|
|
2045
|
+
}
|
|
2046
|
+
function b() {
|
|
2047
|
+
k.call(
|
|
2048
|
+
this,
|
|
2049
|
+
'k256',
|
|
2050
|
+
'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
|
|
2051
|
+
);
|
|
2052
|
+
}
|
|
2053
|
+
function P() {
|
|
2054
|
+
k.call(
|
|
2055
|
+
this,
|
|
2056
|
+
'p224',
|
|
2057
|
+
'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
|
|
2058
|
+
);
|
|
2059
|
+
}
|
|
2060
|
+
function S() {
|
|
2061
|
+
k.call(
|
|
2062
|
+
this,
|
|
2063
|
+
'p192',
|
|
2064
|
+
'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
|
|
2065
|
+
);
|
|
2066
|
+
}
|
|
2067
|
+
function A() {
|
|
2068
|
+
k.call(
|
|
2069
|
+
this,
|
|
2070
|
+
'25519',
|
|
2071
|
+
'7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
|
|
2072
|
+
);
|
|
2073
|
+
}
|
|
2074
|
+
function T(t) {
|
|
2075
|
+
if ('string' == typeof t) {
|
|
2076
|
+
var e = r._prime(t);
|
|
2077
|
+
(this.m = e.p), (this.prime = e);
|
|
2078
|
+
} else
|
|
2079
|
+
i(t.gtn(1), 'modulus must be greater than 1'),
|
|
2080
|
+
(this.m = t),
|
|
2081
|
+
(this.prime = null);
|
|
2082
|
+
}
|
|
2083
|
+
function C(t) {
|
|
2084
|
+
T.call(this, t),
|
|
2085
|
+
(this.shift = this.m.bitLength()),
|
|
2086
|
+
this.shift % 26 != 0 && (this.shift += 26 - (this.shift % 26)),
|
|
2087
|
+
(this.r = new r(1).iushln(this.shift)),
|
|
2088
|
+
(this.r2 = this.imod(this.r.sqr())),
|
|
2089
|
+
(this.rinv = this.r._invmp(this.m)),
|
|
2090
|
+
(this.minv = this.rinv.mul(this.r).isubn(1).div(this.m)),
|
|
2091
|
+
(this.minv = this.minv.umod(this.r)),
|
|
2092
|
+
(this.minv = this.r.sub(this.minv));
|
|
2093
|
+
}
|
|
2094
|
+
(k.prototype._tmp = function () {
|
|
2095
|
+
var t = new r(null);
|
|
2096
|
+
return (t.words = new Array(Math.ceil(this.n / 13))), t;
|
|
2097
|
+
}),
|
|
2098
|
+
(k.prototype.ireduce = function (t) {
|
|
2099
|
+
var e,
|
|
2100
|
+
i = t;
|
|
2101
|
+
do {
|
|
2102
|
+
this.split(i, this.tmp),
|
|
2103
|
+
(e = (i = (i = this.imulK(i)).iadd(this.tmp)).bitLength());
|
|
2104
|
+
} while (e > this.n);
|
|
2105
|
+
var n = e < this.n ? -1 : i.ucmp(this.p);
|
|
2106
|
+
return (
|
|
2107
|
+
0 === n
|
|
2108
|
+
? ((i.words[0] = 0), (i.length = 1))
|
|
2109
|
+
: n > 0
|
|
2110
|
+
? i.isub(this.p)
|
|
2111
|
+
: void 0 !== i.strip
|
|
2112
|
+
? i.strip()
|
|
2113
|
+
: i._strip(),
|
|
2114
|
+
i
|
|
2115
|
+
);
|
|
2116
|
+
}),
|
|
2117
|
+
(k.prototype.split = function (t, e) {
|
|
2118
|
+
t.iushrn(this.n, 0, e);
|
|
2119
|
+
}),
|
|
2120
|
+
(k.prototype.imulK = function (t) {
|
|
2121
|
+
return t.imul(this.k);
|
|
2122
|
+
}),
|
|
2123
|
+
n(b, k),
|
|
2124
|
+
(b.prototype.split = function (t, e) {
|
|
2125
|
+
for (var i = 4194303, n = Math.min(t.length, 9), r = 0; r < n; r++)
|
|
2126
|
+
e.words[r] = t.words[r];
|
|
2127
|
+
if (((e.length = n), t.length <= 9))
|
|
2128
|
+
return (t.words[0] = 0), void (t.length = 1);
|
|
2129
|
+
var o = t.words[9];
|
|
2130
|
+
for (e.words[e.length++] = o & i, r = 10; r < t.length; r++) {
|
|
2131
|
+
var s = 0 | t.words[r];
|
|
2132
|
+
(t.words[r - 10] = ((s & i) << 4) | (o >>> 22)), (o = s);
|
|
2133
|
+
}
|
|
2134
|
+
(o >>>= 22),
|
|
2135
|
+
(t.words[r - 10] = o),
|
|
2136
|
+
0 === o && t.length > 10 ? (t.length -= 10) : (t.length -= 9);
|
|
2137
|
+
}),
|
|
2138
|
+
(b.prototype.imulK = function (t) {
|
|
2139
|
+
(t.words[t.length] = 0),
|
|
2140
|
+
(t.words[t.length + 1] = 0),
|
|
2141
|
+
(t.length += 2);
|
|
2142
|
+
for (var e = 0, i = 0; i < t.length; i++) {
|
|
2143
|
+
var n = 0 | t.words[i];
|
|
2144
|
+
(e += 977 * n),
|
|
2145
|
+
(t.words[i] = 67108863 & e),
|
|
2146
|
+
(e = 64 * n + ((e / 67108864) | 0));
|
|
2147
|
+
}
|
|
2148
|
+
return (
|
|
2149
|
+
0 === t.words[t.length - 1] &&
|
|
2150
|
+
(t.length--, 0 === t.words[t.length - 1] && t.length--),
|
|
2151
|
+
t
|
|
2152
|
+
);
|
|
2153
|
+
}),
|
|
2154
|
+
n(P, k),
|
|
2155
|
+
n(S, k),
|
|
2156
|
+
n(A, k),
|
|
2157
|
+
(A.prototype.imulK = function (t) {
|
|
2158
|
+
for (var e = 0, i = 0; i < t.length; i++) {
|
|
2159
|
+
var n = 19 * (0 | t.words[i]) + e,
|
|
2160
|
+
r = 67108863 & n;
|
|
2161
|
+
(n >>>= 26), (t.words[i] = r), (e = n);
|
|
2162
|
+
}
|
|
2163
|
+
return 0 !== e && (t.words[t.length++] = e), t;
|
|
2164
|
+
}),
|
|
2165
|
+
(r._prime = function (t) {
|
|
2166
|
+
if (w[t]) return w[t];
|
|
2167
|
+
var e;
|
|
2168
|
+
if ('k256' === t) e = new b();
|
|
2169
|
+
else if ('p224' === t) e = new P();
|
|
2170
|
+
else if ('p192' === t) e = new S();
|
|
2171
|
+
else {
|
|
2172
|
+
if ('p25519' !== t) throw new Error('Unknown prime ' + t);
|
|
2173
|
+
e = new A();
|
|
2174
|
+
}
|
|
2175
|
+
return (w[t] = e), e;
|
|
2176
|
+
}),
|
|
2177
|
+
(T.prototype._verify1 = function (t) {
|
|
2178
|
+
i(0 === t.negative, 'red works only with positives'),
|
|
2179
|
+
i(t.red, 'red works only with red numbers');
|
|
2180
|
+
}),
|
|
2181
|
+
(T.prototype._verify2 = function (t, e) {
|
|
2182
|
+
i(0 == (t.negative | e.negative), 'red works only with positives'),
|
|
2183
|
+
i(t.red && t.red === e.red, 'red works only with red numbers');
|
|
2184
|
+
}),
|
|
2185
|
+
(T.prototype.imod = function (t) {
|
|
2186
|
+
return this.prime
|
|
2187
|
+
? this.prime.ireduce(t)._forceRed(this)
|
|
2188
|
+
: (m(t, t.umod(this.m)._forceRed(this)), t);
|
|
2189
|
+
}),
|
|
2190
|
+
(T.prototype.neg = function (t) {
|
|
2191
|
+
return t.isZero() ? t.clone() : this.m.sub(t)._forceRed(this);
|
|
2192
|
+
}),
|
|
2193
|
+
(T.prototype.add = function (t, e) {
|
|
2194
|
+
this._verify2(t, e);
|
|
2195
|
+
var i = t.add(e);
|
|
2196
|
+
return i.cmp(this.m) >= 0 && i.isub(this.m), i._forceRed(this);
|
|
2197
|
+
}),
|
|
2198
|
+
(T.prototype.iadd = function (t, e) {
|
|
2199
|
+
this._verify2(t, e);
|
|
2200
|
+
var i = t.iadd(e);
|
|
2201
|
+
return i.cmp(this.m) >= 0 && i.isub(this.m), i;
|
|
2202
|
+
}),
|
|
2203
|
+
(T.prototype.sub = function (t, e) {
|
|
2204
|
+
this._verify2(t, e);
|
|
2205
|
+
var i = t.sub(e);
|
|
2206
|
+
return i.cmpn(0) < 0 && i.iadd(this.m), i._forceRed(this);
|
|
2207
|
+
}),
|
|
2208
|
+
(T.prototype.isub = function (t, e) {
|
|
2209
|
+
this._verify2(t, e);
|
|
2210
|
+
var i = t.isub(e);
|
|
2211
|
+
return i.cmpn(0) < 0 && i.iadd(this.m), i;
|
|
2212
|
+
}),
|
|
2213
|
+
(T.prototype.shl = function (t, e) {
|
|
2214
|
+
return this._verify1(t), this.imod(t.ushln(e));
|
|
2215
|
+
}),
|
|
2216
|
+
(T.prototype.imul = function (t, e) {
|
|
2217
|
+
return this._verify2(t, e), this.imod(t.imul(e));
|
|
2218
|
+
}),
|
|
2219
|
+
(T.prototype.mul = function (t, e) {
|
|
2220
|
+
return this._verify2(t, e), this.imod(t.mul(e));
|
|
2221
|
+
}),
|
|
2222
|
+
(T.prototype.isqr = function (t) {
|
|
2223
|
+
return this.imul(t, t.clone());
|
|
2224
|
+
}),
|
|
2225
|
+
(T.prototype.sqr = function (t) {
|
|
2226
|
+
return this.mul(t, t);
|
|
2227
|
+
}),
|
|
2228
|
+
(T.prototype.sqrt = function (t) {
|
|
2229
|
+
if (t.isZero()) return t.clone();
|
|
2230
|
+
var e = this.m.andln(3);
|
|
2231
|
+
if ((i(e % 2 == 1), 3 === e)) {
|
|
2232
|
+
var n = this.m.add(new r(1)).iushrn(2);
|
|
2233
|
+
return this.pow(t, n);
|
|
2234
|
+
}
|
|
2235
|
+
for (
|
|
2236
|
+
var o = this.m.subn(1), s = 0;
|
|
2237
|
+
!o.isZero() && 0 === o.andln(1);
|
|
2238
|
+
|
|
2239
|
+
)
|
|
2240
|
+
s++, o.iushrn(1);
|
|
2241
|
+
i(!o.isZero());
|
|
2242
|
+
var a = new r(1).toRed(this),
|
|
2243
|
+
u = a.redNeg(),
|
|
2244
|
+
m = this.m.subn(1).iushrn(1),
|
|
2245
|
+
h = this.m.bitLength();
|
|
2246
|
+
for (
|
|
2247
|
+
h = new r(2 * h * h).toRed(this);
|
|
2248
|
+
0 !== this.pow(h, m).cmp(u);
|
|
2249
|
+
|
|
2250
|
+
)
|
|
2251
|
+
h.redIAdd(u);
|
|
2252
|
+
for (
|
|
2253
|
+
var l = this.pow(h, o),
|
|
2254
|
+
d = this.pow(t, o.addn(1).iushrn(1)),
|
|
2255
|
+
c = this.pow(t, o),
|
|
2256
|
+
p = s;
|
|
2257
|
+
0 !== c.cmp(a);
|
|
2258
|
+
|
|
2259
|
+
) {
|
|
2260
|
+
for (var g = c, f = 0; 0 !== g.cmp(a); f++) g = g.redSqr();
|
|
2261
|
+
i(f < p);
|
|
2262
|
+
var y = this.pow(l, new r(1).iushln(p - f - 1));
|
|
2263
|
+
(d = d.redMul(y)), (l = y.redSqr()), (c = c.redMul(l)), (p = f);
|
|
2264
|
+
}
|
|
2265
|
+
return d;
|
|
2266
|
+
}),
|
|
2267
|
+
(T.prototype.invm = function (t) {
|
|
2268
|
+
var e = t._invmp(this.m);
|
|
2269
|
+
return 0 !== e.negative
|
|
2270
|
+
? ((e.negative = 0), this.imod(e).redNeg())
|
|
2271
|
+
: this.imod(e);
|
|
2272
|
+
}),
|
|
2273
|
+
(T.prototype.pow = function (t, e) {
|
|
2274
|
+
if (e.isZero()) return new r(1).toRed(this);
|
|
2275
|
+
if (0 === e.cmpn(1)) return t.clone();
|
|
2276
|
+
var i = new Array(16);
|
|
2277
|
+
(i[0] = new r(1).toRed(this)), (i[1] = t);
|
|
2278
|
+
for (var n = 2; n < i.length; n++) i[n] = this.mul(i[n - 1], t);
|
|
2279
|
+
var o = i[0],
|
|
2280
|
+
s = 0,
|
|
2281
|
+
a = 0,
|
|
2282
|
+
u = e.bitLength() % 26;
|
|
2283
|
+
for (0 === u && (u = 26), n = e.length - 1; n >= 0; n--) {
|
|
2284
|
+
for (var m = e.words[n], h = u - 1; h >= 0; h--) {
|
|
2285
|
+
var l = (m >> h) & 1;
|
|
2286
|
+
o !== i[0] && (o = this.sqr(o)),
|
|
2287
|
+
0 !== l || 0 !== s
|
|
2288
|
+
? ((s <<= 1),
|
|
2289
|
+
(s |= l),
|
|
2290
|
+
(4 == ++a || (0 === n && 0 === h)) &&
|
|
2291
|
+
((o = this.mul(o, i[s])), (a = 0), (s = 0)))
|
|
2292
|
+
: (a = 0);
|
|
2293
|
+
}
|
|
2294
|
+
u = 26;
|
|
2295
|
+
}
|
|
2296
|
+
return o;
|
|
2297
|
+
}),
|
|
2298
|
+
(T.prototype.convertTo = function (t) {
|
|
2299
|
+
var e = t.umod(this.m);
|
|
2300
|
+
return e === t ? e.clone() : e;
|
|
2301
|
+
}),
|
|
2302
|
+
(T.prototype.convertFrom = function (t) {
|
|
2303
|
+
var e = t.clone();
|
|
2304
|
+
return (e.red = null), e;
|
|
2305
|
+
}),
|
|
2306
|
+
(r.mont = function (t) {
|
|
2307
|
+
return new C(t);
|
|
2308
|
+
}),
|
|
2309
|
+
n(C, T),
|
|
2310
|
+
(C.prototype.convertTo = function (t) {
|
|
2311
|
+
return this.imod(t.ushln(this.shift));
|
|
2312
|
+
}),
|
|
2313
|
+
(C.prototype.convertFrom = function (t) {
|
|
2314
|
+
var e = this.imod(t.mul(this.rinv));
|
|
2315
|
+
return (e.red = null), e;
|
|
2316
|
+
}),
|
|
2317
|
+
(C.prototype.imul = function (t, e) {
|
|
2318
|
+
if (t.isZero() || e.isZero())
|
|
2319
|
+
return (t.words[0] = 0), (t.length = 1), t;
|
|
2320
|
+
var i = t.imul(e),
|
|
2321
|
+
n = i
|
|
2322
|
+
.maskn(this.shift)
|
|
2323
|
+
.mul(this.minv)
|
|
2324
|
+
.imaskn(this.shift)
|
|
2325
|
+
.mul(this.m),
|
|
2326
|
+
r = i.isub(n).iushrn(this.shift),
|
|
2327
|
+
o = r;
|
|
2328
|
+
return (
|
|
2329
|
+
r.cmp(this.m) >= 0
|
|
2330
|
+
? (o = r.isub(this.m))
|
|
2331
|
+
: r.cmpn(0) < 0 && (o = r.iadd(this.m)),
|
|
2332
|
+
o._forceRed(this)
|
|
2333
|
+
);
|
|
2334
|
+
}),
|
|
2335
|
+
(C.prototype.mul = function (t, e) {
|
|
2336
|
+
if (t.isZero() || e.isZero()) return new r(0)._forceRed(this);
|
|
2337
|
+
var i = t.mul(e),
|
|
2338
|
+
n = i
|
|
2339
|
+
.maskn(this.shift)
|
|
2340
|
+
.mul(this.minv)
|
|
2341
|
+
.imaskn(this.shift)
|
|
2342
|
+
.mul(this.m),
|
|
2343
|
+
o = i.isub(n).iushrn(this.shift),
|
|
2344
|
+
s = o;
|
|
2345
|
+
return (
|
|
2346
|
+
o.cmp(this.m) >= 0
|
|
2347
|
+
? (s = o.isub(this.m))
|
|
2348
|
+
: o.cmpn(0) < 0 && (s = o.iadd(this.m)),
|
|
2349
|
+
s._forceRed(this)
|
|
2350
|
+
);
|
|
2351
|
+
}),
|
|
2352
|
+
(C.prototype.invm = function (t) {
|
|
2353
|
+
return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this);
|
|
2354
|
+
});
|
|
2355
|
+
})(0, d);
|
|
2356
|
+
var y = c(g.exports);
|
|
2357
|
+
const M = n.struct([
|
|
2358
|
+
n.array(n.u8(), 32, 'a'),
|
|
2359
|
+
n.array(n.u8(), 64, 'b'),
|
|
2360
|
+
n.array(n.u8(), 32, 'c'),
|
|
2361
|
+
]),
|
|
2362
|
+
v = n.struct([
|
|
2363
|
+
n.publicKey('owner'),
|
|
2364
|
+
n.u64('amount'),
|
|
2365
|
+
n.option(n.u64(), 'lamports'),
|
|
2366
|
+
n.u8('merkleTreeIndex'),
|
|
2367
|
+
n.option(n.vecU8(), 'tlv'),
|
|
2368
|
+
]),
|
|
2369
|
+
w = n.struct([n.u8('queueId'), n.u16('index')]),
|
|
2370
|
+
k = n.struct([
|
|
2371
|
+
n.u64('amount'),
|
|
2372
|
+
n.option(n.u8(), 'delegateIndex'),
|
|
2373
|
+
n.struct(
|
|
2374
|
+
[
|
|
2375
|
+
n.u8('merkleTreePubkeyIndex'),
|
|
2376
|
+
n.u8('nullifierQueuePubkeyIndex'),
|
|
2377
|
+
n.u32('leafIndex'),
|
|
2378
|
+
n.option(w, 'queueIndex'),
|
|
2379
|
+
],
|
|
2380
|
+
'merkleContext',
|
|
2381
|
+
),
|
|
2382
|
+
n.u16('rootIndex'),
|
|
2383
|
+
n.option(n.u64(), 'lamports'),
|
|
2384
|
+
n.option(n.vecU8(), 'tlv'),
|
|
2385
|
+
]),
|
|
2386
|
+
b = n.struct([
|
|
2387
|
+
n.publicKey('owner'),
|
|
2388
|
+
n.option(n.u8(), 'delegateChangeAccountIndex'),
|
|
2389
|
+
]),
|
|
2390
|
+
P = n.struct([
|
|
2391
|
+
n.bool('setContext'),
|
|
2392
|
+
n.bool('firstSetContext'),
|
|
2393
|
+
n.u8('cpiContextAccountIndex'),
|
|
2394
|
+
]),
|
|
2395
|
+
S = n.struct([
|
|
2396
|
+
n.option(M, 'proof'),
|
|
2397
|
+
n.publicKey('mint'),
|
|
2398
|
+
n.option(b, 'delegatedTransfer'),
|
|
2399
|
+
n.vec(k, 'inputTokenDataWithContext'),
|
|
2400
|
+
n.vec(v, 'outputCompressedAccounts'),
|
|
2401
|
+
n.bool('isCompress'),
|
|
2402
|
+
n.option(n.u64(), 'compressOrDecompressAmount'),
|
|
2403
|
+
n.option(P, 'cpiContext'),
|
|
2404
|
+
n.option(n.u8(), 'lamportsChangeAccountMerkleTreeIndex'),
|
|
2405
|
+
]),
|
|
2406
|
+
A = n.struct([
|
|
2407
|
+
n.vec(n.publicKey(), 'recipients'),
|
|
2408
|
+
n.vec(n.u64(), 'amounts'),
|
|
2409
|
+
n.option(n.u64(), 'lamports'),
|
|
2410
|
+
]),
|
|
2411
|
+
T = n.struct([
|
|
2412
|
+
n.publicKey('owner'),
|
|
2413
|
+
n.option(n.u64(), 'remainingAmount'),
|
|
2414
|
+
n.option(P, 'cpiContext'),
|
|
2415
|
+
]);
|
|
2416
|
+
function C(t) {
|
|
2417
|
+
const e = r.Buffer.alloc(1e3),
|
|
2418
|
+
i = A.encode(
|
|
2419
|
+
{
|
|
2420
|
+
recipients: t.recipients,
|
|
2421
|
+
amounts: t.amounts,
|
|
2422
|
+
lamports: t.lamports,
|
|
2423
|
+
},
|
|
2424
|
+
e,
|
|
2425
|
+
);
|
|
2426
|
+
return r.Buffer.concat([m, e.slice(0, i)]);
|
|
2427
|
+
}
|
|
2428
|
+
function I(t) {
|
|
2429
|
+
const e = r.Buffer.alloc(1e3),
|
|
2430
|
+
i = T.encode(
|
|
2431
|
+
{
|
|
2432
|
+
owner: t.owner,
|
|
2433
|
+
remainingAmount: t.remainingAmount,
|
|
2434
|
+
cpiContext: t.cpiContext,
|
|
2435
|
+
},
|
|
2436
|
+
e,
|
|
2437
|
+
);
|
|
2438
|
+
return r.Buffer.concat([l, e.slice(0, i)]);
|
|
2439
|
+
}
|
|
2440
|
+
function x(t) {
|
|
2441
|
+
const e = r.Buffer.alloc(1e3),
|
|
2442
|
+
i = S.encode(t, e),
|
|
2443
|
+
n = r.Buffer.alloc(4);
|
|
2444
|
+
return n.writeUInt32LE(i, 0), r.Buffer.concat([h, n, e.slice(0, i)]);
|
|
2445
|
+
}
|
|
2446
|
+
const _ = t => {
|
|
2447
|
+
const {
|
|
2448
|
+
feePayer: e,
|
|
2449
|
+
tokenPoolPda: i,
|
|
2450
|
+
systemProgram: n,
|
|
2451
|
+
mint: r,
|
|
2452
|
+
tokenProgram: o,
|
|
2453
|
+
cpiAuthorityPda: s,
|
|
2454
|
+
} = t;
|
|
2455
|
+
return [
|
|
2456
|
+
{ pubkey: e, isSigner: 1, isWritable: 1 },
|
|
2457
|
+
{ pubkey: i, isSigner: 0, isWritable: 1 },
|
|
2458
|
+
{ pubkey: n, isSigner: 0, isWritable: 0 },
|
|
2459
|
+
{ pubkey: r, isSigner: 0, isWritable: 1 },
|
|
2460
|
+
{ pubkey: o, isSigner: 0, isWritable: 0 },
|
|
2461
|
+
{ pubkey: s, isSigner: 0, isWritable: 0 },
|
|
2462
|
+
];
|
|
2463
|
+
},
|
|
2464
|
+
O = t => {
|
|
2465
|
+
const e = N.programId,
|
|
2466
|
+
{
|
|
2467
|
+
feePayer: i,
|
|
2468
|
+
authority: n,
|
|
2469
|
+
cpiAuthorityPda: r,
|
|
2470
|
+
mint: o,
|
|
2471
|
+
tokenPoolPda: s,
|
|
2472
|
+
tokenProgram: a,
|
|
2473
|
+
lightSystemProgram: u,
|
|
2474
|
+
registeredProgramPda: m,
|
|
2475
|
+
noopProgram: h,
|
|
2476
|
+
accountCompressionAuthority: l,
|
|
2477
|
+
accountCompressionProgram: d,
|
|
2478
|
+
merkleTree: c,
|
|
2479
|
+
selfProgram: p,
|
|
2480
|
+
systemProgram: g,
|
|
2481
|
+
solPoolPda: f,
|
|
2482
|
+
} = t;
|
|
2483
|
+
return [
|
|
2484
|
+
{ pubkey: i, isSigner: 1, isWritable: 1 },
|
|
2485
|
+
{ pubkey: n, isSigner: 1, isWritable: 0 },
|
|
2486
|
+
{ pubkey: r, isSigner: 0, isWritable: 0 },
|
|
2487
|
+
{ pubkey: o, isSigner: 0, isWritable: 1 },
|
|
2488
|
+
{ pubkey: s, isSigner: 0, isWritable: 1 },
|
|
2489
|
+
{ pubkey: a, isSigner: 0, isWritable: 0 },
|
|
2490
|
+
{ pubkey: u, isSigner: 0, isWritable: 0 },
|
|
2491
|
+
{ pubkey: m, isSigner: 0, isWritable: 0 },
|
|
2492
|
+
{ pubkey: h, isSigner: 0, isWritable: 0 },
|
|
2493
|
+
{ pubkey: l, isSigner: 0, isWritable: 0 },
|
|
2494
|
+
{ pubkey: d, isSigner: 0, isWritable: 0 },
|
|
2495
|
+
{ pubkey: c, isSigner: 0, isWritable: 1 },
|
|
2496
|
+
{ pubkey: p, isSigner: 0, isWritable: 0 },
|
|
2497
|
+
{ pubkey: g, isSigner: 0, isWritable: 0 },
|
|
2498
|
+
{ pubkey: null != f ? f : e, isSigner: 0, isWritable: 1 },
|
|
2499
|
+
];
|
|
2500
|
+
},
|
|
2501
|
+
D = t => {
|
|
2502
|
+
const e = N.programId,
|
|
2503
|
+
{
|
|
2504
|
+
feePayer: i,
|
|
2505
|
+
authority: n,
|
|
2506
|
+
cpiAuthorityPda: r,
|
|
2507
|
+
lightSystemProgram: o,
|
|
2508
|
+
registeredProgramPda: s,
|
|
2509
|
+
noopProgram: a,
|
|
2510
|
+
accountCompressionAuthority: u,
|
|
2511
|
+
accountCompressionProgram: m,
|
|
2512
|
+
selfProgram: h,
|
|
2513
|
+
tokenPoolPda: l,
|
|
2514
|
+
compressOrDecompressTokenAccount: d,
|
|
2515
|
+
tokenProgram: c,
|
|
2516
|
+
systemProgram: p,
|
|
2517
|
+
} = t;
|
|
2518
|
+
return [
|
|
2519
|
+
{ pubkey: i, isSigner: 1, isWritable: 1 },
|
|
2520
|
+
{ pubkey: n, isSigner: 1, isWritable: 0 },
|
|
2521
|
+
{ pubkey: r, isSigner: 0, isWritable: 0 },
|
|
2522
|
+
{ pubkey: o, isSigner: 0, isWritable: 0 },
|
|
2523
|
+
{ pubkey: s, isSigner: 0, isWritable: 0 },
|
|
2524
|
+
{ pubkey: a, isSigner: 0, isWritable: 0 },
|
|
2525
|
+
{ pubkey: u, isSigner: 0, isWritable: 0 },
|
|
2526
|
+
{ pubkey: m, isSigner: 0, isWritable: 0 },
|
|
2527
|
+
{ pubkey: h, isSigner: 0, isWritable: 0 },
|
|
2528
|
+
{ pubkey: null != l ? l : e, isSigner: 0, isWritable: 1 },
|
|
2529
|
+
{ pubkey: null != d ? d : e, isSigner: 0, isWritable: 1 },
|
|
2530
|
+
{ pubkey: null != c ? c : e, isSigner: 0, isWritable: 0 },
|
|
2531
|
+
{ pubkey: p, isSigner: 0, isWritable: 0 },
|
|
2532
|
+
];
|
|
2533
|
+
},
|
|
2534
|
+
E = e => e.reduce((t, e) => t.add(e.parsed.amount), t.bn(0)),
|
|
2535
|
+
B = t => {
|
|
2536
|
+
const e = t[0].parsed.owner;
|
|
2537
|
+
t.forEach(t => {
|
|
2538
|
+
if (!t.parsed.owner.equals(e))
|
|
2539
|
+
throw new Error(
|
|
2540
|
+
'Token accounts must be owned by the same owner',
|
|
2541
|
+
);
|
|
2542
|
+
});
|
|
2543
|
+
},
|
|
2544
|
+
K = t => ({
|
|
2545
|
+
mint: t[0].parsed.mint,
|
|
2546
|
+
currentOwner: t[0].parsed.owner,
|
|
2547
|
+
delegate: t[0].parsed.delegate,
|
|
2548
|
+
});
|
|
2549
|
+
function L(e, i, n) {
|
|
2550
|
+
n = t.bn(n);
|
|
2551
|
+
const r = E(e),
|
|
2552
|
+
o = t.sumUpLamports(e.map(t => t.compressedAccount)),
|
|
2553
|
+
s = r.sub(n);
|
|
2554
|
+
return (
|
|
2555
|
+
t.validateSufficientBalance(s),
|
|
2556
|
+
s.eq(t.bn(0)) && o.eq(t.bn(0))
|
|
2557
|
+
? [{ owner: i, amount: n, lamports: o, tlv: null }]
|
|
2558
|
+
: (t.validateSameOwner(e.map(t => t.compressedAccount)),
|
|
2559
|
+
B(e),
|
|
2560
|
+
[
|
|
2561
|
+
{
|
|
2562
|
+
owner: e[0].parsed.owner,
|
|
2563
|
+
amount: s,
|
|
2564
|
+
lamports: o,
|
|
2565
|
+
tlv: null,
|
|
2566
|
+
},
|
|
2567
|
+
{ owner: i, amount: n, lamports: t.bn(0), tlv: null },
|
|
2568
|
+
])
|
|
2569
|
+
);
|
|
2570
|
+
}
|
|
2571
|
+
function R(e, i) {
|
|
2572
|
+
i = t.bn(i);
|
|
2573
|
+
const n = t.sumUpLamports(e.map(t => t.compressedAccount)),
|
|
2574
|
+
r = E(e).sub(i);
|
|
2575
|
+
return (
|
|
2576
|
+
t.validateSufficientBalance(r),
|
|
2577
|
+
r.eq(t.bn(0)) && n.eq(t.bn(0))
|
|
2578
|
+
? []
|
|
2579
|
+
: (t.validateSameOwner(e.map(t => t.compressedAccount)),
|
|
2580
|
+
B(e),
|
|
2581
|
+
[{ owner: e[0].parsed.owner, amount: r, lamports: n, tlv: null }])
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
class N {
|
|
2585
|
+
constructor() {}
|
|
2586
|
+
static setProgramId(t) {
|
|
2587
|
+
this.programId = 'string' == typeof t ? new e.PublicKey(t) : t;
|
|
2588
|
+
}
|
|
2589
|
+
static deriveTokenPoolPda(t) {
|
|
2590
|
+
const i = [s, t.toBuffer()],
|
|
2591
|
+
[n, r] = e.PublicKey.findProgramAddressSync(i, this.programId);
|
|
2592
|
+
return n;
|
|
2593
|
+
}
|
|
2594
|
+
static get deriveCpiAuthorityPda() {
|
|
2595
|
+
const [t, i] = e.PublicKey.findProgramAddressSync([a], this.programId);
|
|
2596
|
+
return t;
|
|
2597
|
+
}
|
|
2598
|
+
static async createMint(t) {
|
|
2599
|
+
const {
|
|
2600
|
+
mint: n,
|
|
2601
|
+
authority: r,
|
|
2602
|
+
feePayer: o,
|
|
2603
|
+
rentExemptBalance: s,
|
|
2604
|
+
tokenProgramId: a,
|
|
2605
|
+
freezeAuthority: u,
|
|
2606
|
+
mintSize: m,
|
|
2607
|
+
} = t,
|
|
2608
|
+
h = null != a ? a : i.TOKEN_PROGRAM_ID;
|
|
2609
|
+
return [
|
|
2610
|
+
e.SystemProgram.createAccount({
|
|
2611
|
+
fromPubkey: o,
|
|
2612
|
+
lamports: s,
|
|
2613
|
+
newAccountPubkey: n,
|
|
2614
|
+
programId: h,
|
|
2615
|
+
space: null != m ? m : i.MINT_SIZE,
|
|
2616
|
+
}),
|
|
2617
|
+
i.createInitializeMint2Instruction(n, t.decimals, r, u, h),
|
|
2618
|
+
await this.createTokenPool({
|
|
2619
|
+
feePayer: o,
|
|
2620
|
+
mint: n,
|
|
2621
|
+
tokenProgramId: h,
|
|
2622
|
+
}),
|
|
2623
|
+
];
|
|
2624
|
+
}
|
|
2625
|
+
static async createTokenPool(t) {
|
|
2626
|
+
const { mint: n, feePayer: r, tokenProgramId: o } = t,
|
|
2627
|
+
s = null != o ? o : i.TOKEN_PROGRAM_ID,
|
|
2628
|
+
a = this.deriveTokenPoolPda(n),
|
|
2629
|
+
m = _({
|
|
2630
|
+
mint: n,
|
|
2631
|
+
feePayer: r,
|
|
2632
|
+
tokenPoolPda: a,
|
|
2633
|
+
tokenProgram: s,
|
|
2634
|
+
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
2635
|
+
systemProgram: e.SystemProgram.programId,
|
|
2636
|
+
});
|
|
2637
|
+
return new e.TransactionInstruction({
|
|
2638
|
+
programId: this.programId,
|
|
2639
|
+
keys: m,
|
|
2640
|
+
data: u,
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
static async mintTo(n) {
|
|
2644
|
+
const r = t.defaultStaticAccountsStruct(),
|
|
2645
|
+
{
|
|
2646
|
+
mint: o,
|
|
2647
|
+
feePayer: s,
|
|
2648
|
+
authority: a,
|
|
2649
|
+
merkleTree: u,
|
|
2650
|
+
toPubkey: m,
|
|
2651
|
+
amount: h,
|
|
2652
|
+
tokenProgramId: l,
|
|
2653
|
+
} = n,
|
|
2654
|
+
d = null != l ? l : i.TOKEN_PROGRAM_ID,
|
|
2655
|
+
c = this.deriveTokenPoolPda(o),
|
|
2656
|
+
p = t.toArray(h).map(e => t.bn(e)),
|
|
2657
|
+
g = t.toArray(m);
|
|
2658
|
+
if (p.length !== g.length)
|
|
2659
|
+
throw new Error(
|
|
2660
|
+
'Amount and toPubkey arrays must have the same length',
|
|
2661
|
+
);
|
|
2662
|
+
const f = O({
|
|
2663
|
+
mint: o,
|
|
2664
|
+
feePayer: s,
|
|
2665
|
+
authority: a,
|
|
2666
|
+
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
2667
|
+
tokenProgram: d,
|
|
2668
|
+
tokenPoolPda: c,
|
|
2669
|
+
lightSystemProgram: t.LightSystemProgram.programId,
|
|
2670
|
+
registeredProgramPda: r.registeredProgramPda,
|
|
2671
|
+
noopProgram: r.noopProgram,
|
|
2672
|
+
accountCompressionAuthority: r.accountCompressionAuthority,
|
|
2673
|
+
accountCompressionProgram: r.accountCompressionProgram,
|
|
2674
|
+
merkleTree:
|
|
2675
|
+
null != u ? u : t.defaultTestStateTreeAccounts().merkleTree,
|
|
2676
|
+
selfProgram: this.programId,
|
|
2677
|
+
systemProgram: e.SystemProgram.programId,
|
|
2678
|
+
solPoolPda: null,
|
|
2679
|
+
}),
|
|
2680
|
+
y = C({ recipients: g, amounts: p, lamports: null });
|
|
2681
|
+
return new e.TransactionInstruction({
|
|
2682
|
+
programId: this.programId,
|
|
2683
|
+
keys: f,
|
|
2684
|
+
data: y,
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
static async approveAndMintTo(t) {
|
|
2688
|
+
const {
|
|
2689
|
+
mint: e,
|
|
2690
|
+
feePayer: n,
|
|
2691
|
+
authorityTokenAccount: r,
|
|
2692
|
+
authority: o,
|
|
2693
|
+
merkleTree: s,
|
|
2694
|
+
toPubkey: a,
|
|
2695
|
+
tokenProgramId: u,
|
|
2696
|
+
} = t,
|
|
2697
|
+
m = BigInt(t.amount.toString());
|
|
2698
|
+
return [
|
|
2699
|
+
i.createMintToInstruction(e, r, o, m, [], u),
|
|
2700
|
+
await this.compress({
|
|
2701
|
+
payer: n,
|
|
2702
|
+
owner: o,
|
|
2703
|
+
source: r,
|
|
2704
|
+
toAddress: a,
|
|
2705
|
+
mint: e,
|
|
2706
|
+
amount: t.amount,
|
|
2707
|
+
outputStateTree: s,
|
|
2708
|
+
tokenProgramId: u,
|
|
2709
|
+
}),
|
|
2710
|
+
];
|
|
2711
|
+
}
|
|
2712
|
+
static async transfer(i) {
|
|
2713
|
+
const {
|
|
2714
|
+
payer: n,
|
|
2715
|
+
inputCompressedTokenAccounts: r,
|
|
2716
|
+
recentInputStateRootIndices: s,
|
|
2717
|
+
recentValidityProof: a,
|
|
2718
|
+
amount: u,
|
|
2719
|
+
outputStateTrees: m,
|
|
2720
|
+
toAddress: h,
|
|
2721
|
+
} = i,
|
|
2722
|
+
l = L(r, h, u),
|
|
2723
|
+
{
|
|
2724
|
+
inputTokenDataWithContext: d,
|
|
2725
|
+
packedOutputTokenData: c,
|
|
2726
|
+
remainingAccountMetas: p,
|
|
2727
|
+
} = o({
|
|
2728
|
+
inputCompressedTokenAccounts: r,
|
|
2729
|
+
outputStateTrees: m,
|
|
2730
|
+
rootIndices: s,
|
|
2731
|
+
tokenTransferOutputs: l,
|
|
2732
|
+
}),
|
|
2733
|
+
{ mint: g, currentOwner: f } = K(r),
|
|
2734
|
+
y = x({
|
|
2735
|
+
proof: a,
|
|
2736
|
+
mint: g,
|
|
2737
|
+
delegatedTransfer: null,
|
|
2738
|
+
inputTokenDataWithContext: d,
|
|
2739
|
+
outputCompressedAccounts: c,
|
|
2740
|
+
compressOrDecompressAmount: null,
|
|
2741
|
+
isCompress: 0,
|
|
2742
|
+
cpiContext: null,
|
|
2743
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
2744
|
+
}),
|
|
2745
|
+
{
|
|
2746
|
+
accountCompressionAuthority: M,
|
|
2747
|
+
noopProgram: v,
|
|
2748
|
+
registeredProgramPda: w,
|
|
2749
|
+
accountCompressionProgram: k,
|
|
2750
|
+
} = t.defaultStaticAccountsStruct(),
|
|
2751
|
+
b = D({
|
|
2752
|
+
feePayer: n,
|
|
2753
|
+
authority: f,
|
|
2754
|
+
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
2755
|
+
lightSystemProgram: t.LightSystemProgram.programId,
|
|
2756
|
+
registeredProgramPda: w,
|
|
2757
|
+
noopProgram: v,
|
|
2758
|
+
accountCompressionAuthority: M,
|
|
2759
|
+
accountCompressionProgram: k,
|
|
2760
|
+
selfProgram: this.programId,
|
|
2761
|
+
tokenPoolPda: void 0,
|
|
2762
|
+
compressOrDecompressTokenAccount: void 0,
|
|
2763
|
+
tokenProgram: void 0,
|
|
2764
|
+
systemProgram: e.SystemProgram.programId,
|
|
2765
|
+
});
|
|
2766
|
+
return (
|
|
2767
|
+
b.push(...p),
|
|
2768
|
+
new e.TransactionInstruction({
|
|
2769
|
+
programId: this.programId,
|
|
2770
|
+
keys: b,
|
|
2771
|
+
data: y,
|
|
2772
|
+
})
|
|
2773
|
+
);
|
|
2774
|
+
}
|
|
2775
|
+
static async createTokenProgramLookupTable(n) {
|
|
2776
|
+
const {
|
|
2777
|
+
authority: r,
|
|
2778
|
+
mints: o,
|
|
2779
|
+
recentSlot: s,
|
|
2780
|
+
payer: a,
|
|
2781
|
+
remainingAccounts: u,
|
|
2782
|
+
} = n,
|
|
2783
|
+
[m, h] = e.AddressLookupTableProgram.createLookupTable({
|
|
2784
|
+
authority: r,
|
|
2785
|
+
payer: r,
|
|
2786
|
+
recentSlot: s,
|
|
2787
|
+
});
|
|
2788
|
+
let l = [];
|
|
2789
|
+
return (
|
|
2790
|
+
o && (l = [...o, ...o.map(t => this.deriveTokenPoolPda(t))]),
|
|
2791
|
+
{
|
|
2792
|
+
instructions: [
|
|
2793
|
+
m,
|
|
2794
|
+
e.AddressLookupTableProgram.extendLookupTable({
|
|
2795
|
+
payer: a,
|
|
2796
|
+
authority: r,
|
|
2797
|
+
lookupTable: h,
|
|
2798
|
+
addresses: [
|
|
2799
|
+
this.deriveCpiAuthorityPda,
|
|
2800
|
+
t.LightSystemProgram.programId,
|
|
2801
|
+
t.defaultStaticAccountsStruct()
|
|
2802
|
+
.registeredProgramPda,
|
|
2803
|
+
t.defaultStaticAccountsStruct().noopProgram,
|
|
2804
|
+
t.defaultStaticAccountsStruct()
|
|
2805
|
+
.accountCompressionAuthority,
|
|
2806
|
+
t.defaultStaticAccountsStruct()
|
|
2807
|
+
.accountCompressionProgram,
|
|
2808
|
+
t.defaultTestStateTreeAccounts().merkleTree,
|
|
2809
|
+
t.defaultTestStateTreeAccounts().nullifierQueue,
|
|
2810
|
+
t.defaultTestStateTreeAccounts().addressTree,
|
|
2811
|
+
t.defaultTestStateTreeAccounts().addressQueue,
|
|
2812
|
+
this.programId,
|
|
2813
|
+
i.TOKEN_PROGRAM_ID,
|
|
2814
|
+
i.TOKEN_2022_PROGRAM_ID,
|
|
2815
|
+
r,
|
|
2816
|
+
...l,
|
|
2817
|
+
...(null != u ? u : []),
|
|
2818
|
+
],
|
|
2819
|
+
}),
|
|
2820
|
+
],
|
|
2821
|
+
address: h,
|
|
2822
|
+
}
|
|
2823
|
+
);
|
|
2824
|
+
}
|
|
2825
|
+
static async compress(n) {
|
|
2826
|
+
const {
|
|
2827
|
+
payer: r,
|
|
2828
|
+
owner: s,
|
|
2829
|
+
source: a,
|
|
2830
|
+
toAddress: u,
|
|
2831
|
+
mint: m,
|
|
2832
|
+
outputStateTree: h,
|
|
2833
|
+
tokenProgramId: l,
|
|
2834
|
+
} = n;
|
|
2835
|
+
if (Array.isArray(n.amount) !== Array.isArray(n.toAddress))
|
|
2836
|
+
throw new Error(
|
|
2837
|
+
'Both amount and toAddress must be arrays or both must be single values',
|
|
2838
|
+
);
|
|
2839
|
+
let d;
|
|
2840
|
+
if (Array.isArray(n.amount) && Array.isArray(n.toAddress)) {
|
|
2841
|
+
if (n.amount.length !== n.toAddress.length)
|
|
2842
|
+
throw new Error(
|
|
2843
|
+
'Amount and toAddress arrays must have the same length',
|
|
2844
|
+
);
|
|
2845
|
+
d = n.amount.map((e, i) => {
|
|
2846
|
+
const r = t.bn(e);
|
|
2847
|
+
return {
|
|
2848
|
+
owner: n.toAddress[i],
|
|
2849
|
+
amount: r,
|
|
2850
|
+
lamports: t.bn(0),
|
|
2851
|
+
tlv: null,
|
|
2852
|
+
};
|
|
2853
|
+
});
|
|
2854
|
+
} else
|
|
2855
|
+
d = [
|
|
2856
|
+
{
|
|
2857
|
+
owner: u,
|
|
2858
|
+
amount: t.bn(n.amount),
|
|
2859
|
+
lamports: t.bn(0),
|
|
2860
|
+
tlv: null,
|
|
2861
|
+
},
|
|
2862
|
+
];
|
|
2863
|
+
const {
|
|
2864
|
+
inputTokenDataWithContext: c,
|
|
2865
|
+
packedOutputTokenData: p,
|
|
2866
|
+
remainingAccountMetas: g,
|
|
2867
|
+
} = o({
|
|
2868
|
+
inputCompressedTokenAccounts: [],
|
|
2869
|
+
outputStateTrees: h,
|
|
2870
|
+
rootIndices: [],
|
|
2871
|
+
tokenTransferOutputs: d,
|
|
2872
|
+
}),
|
|
2873
|
+
f = x({
|
|
2874
|
+
proof: null,
|
|
2875
|
+
mint: m,
|
|
2876
|
+
delegatedTransfer: null,
|
|
2877
|
+
inputTokenDataWithContext: c,
|
|
2878
|
+
outputCompressedAccounts: p,
|
|
2879
|
+
compressOrDecompressAmount: Array.isArray(n.amount)
|
|
2880
|
+
? n.amount
|
|
2881
|
+
.map(t => new y(t))
|
|
2882
|
+
.reduce((t, e) => t.add(e), new y(0))
|
|
2883
|
+
: new y(n.amount),
|
|
2884
|
+
isCompress: 1,
|
|
2885
|
+
cpiContext: null,
|
|
2886
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
2887
|
+
}),
|
|
2888
|
+
M = null != l ? l : i.TOKEN_PROGRAM_ID,
|
|
2889
|
+
v = D(
|
|
2890
|
+
Object.assign(
|
|
2891
|
+
Object.assign({}, t.defaultStaticAccountsStruct()),
|
|
2892
|
+
{
|
|
2893
|
+
feePayer: r,
|
|
2894
|
+
authority: s,
|
|
2895
|
+
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
2896
|
+
lightSystemProgram: t.LightSystemProgram.programId,
|
|
2897
|
+
selfProgram: this.programId,
|
|
2898
|
+
systemProgram: e.SystemProgram.programId,
|
|
2899
|
+
tokenPoolPda: this.deriveTokenPoolPda(m),
|
|
2900
|
+
compressOrDecompressTokenAccount: a,
|
|
2901
|
+
tokenProgram: M,
|
|
2902
|
+
},
|
|
2903
|
+
),
|
|
2904
|
+
);
|
|
2905
|
+
return (
|
|
2906
|
+
v.push(...g),
|
|
2907
|
+
new e.TransactionInstruction({
|
|
2908
|
+
programId: this.programId,
|
|
2909
|
+
keys: v,
|
|
2910
|
+
data: f,
|
|
2911
|
+
})
|
|
2912
|
+
);
|
|
2913
|
+
}
|
|
2914
|
+
static async decompress(n) {
|
|
2915
|
+
const {
|
|
2916
|
+
payer: r,
|
|
2917
|
+
inputCompressedTokenAccounts: s,
|
|
2918
|
+
toAddress: a,
|
|
2919
|
+
outputStateTree: u,
|
|
2920
|
+
recentValidityProof: m,
|
|
2921
|
+
recentInputStateRootIndices: h,
|
|
2922
|
+
tokenProgramId: l,
|
|
2923
|
+
} = n,
|
|
2924
|
+
d = t.bn(n.amount),
|
|
2925
|
+
c = R(s, d),
|
|
2926
|
+
{
|
|
2927
|
+
inputTokenDataWithContext: p,
|
|
2928
|
+
packedOutputTokenData: g,
|
|
2929
|
+
remainingAccountMetas: f,
|
|
2930
|
+
} = o({
|
|
2931
|
+
inputCompressedTokenAccounts: s,
|
|
2932
|
+
outputStateTrees: u,
|
|
2933
|
+
rootIndices: h,
|
|
2934
|
+
tokenTransferOutputs: c,
|
|
2935
|
+
}),
|
|
2936
|
+
{ mint: y, currentOwner: M } = K(s),
|
|
2937
|
+
v = x({
|
|
2938
|
+
proof: m,
|
|
2939
|
+
mint: y,
|
|
2940
|
+
delegatedTransfer: null,
|
|
2941
|
+
inputTokenDataWithContext: p,
|
|
2942
|
+
outputCompressedAccounts: g,
|
|
2943
|
+
compressOrDecompressAmount: d,
|
|
2944
|
+
isCompress: 0,
|
|
2945
|
+
cpiContext: null,
|
|
2946
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
2947
|
+
}),
|
|
2948
|
+
w = null != l ? l : i.TOKEN_PROGRAM_ID,
|
|
2949
|
+
{
|
|
2950
|
+
accountCompressionAuthority: k,
|
|
2951
|
+
noopProgram: b,
|
|
2952
|
+
registeredProgramPda: P,
|
|
2953
|
+
accountCompressionProgram: S,
|
|
2954
|
+
} = t.defaultStaticAccountsStruct(),
|
|
2955
|
+
A = D({
|
|
2956
|
+
feePayer: r,
|
|
2957
|
+
authority: M,
|
|
2958
|
+
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
2959
|
+
lightSystemProgram: t.LightSystemProgram.programId,
|
|
2960
|
+
registeredProgramPda: P,
|
|
2961
|
+
noopProgram: b,
|
|
2962
|
+
accountCompressionAuthority: k,
|
|
2963
|
+
accountCompressionProgram: S,
|
|
2964
|
+
selfProgram: this.programId,
|
|
2965
|
+
tokenPoolPda: this.deriveTokenPoolPda(y),
|
|
2966
|
+
compressOrDecompressTokenAccount: a,
|
|
2967
|
+
tokenProgram: w,
|
|
2968
|
+
systemProgram: e.SystemProgram.programId,
|
|
2969
|
+
});
|
|
2970
|
+
return (
|
|
2971
|
+
A.push(...f),
|
|
2972
|
+
new e.TransactionInstruction({
|
|
2973
|
+
programId: this.programId,
|
|
2974
|
+
keys: A,
|
|
2975
|
+
data: v,
|
|
2976
|
+
})
|
|
2977
|
+
);
|
|
2978
|
+
}
|
|
2979
|
+
static async mergeTokenAccounts(t) {
|
|
2980
|
+
const {
|
|
2981
|
+
payer: e,
|
|
2982
|
+
owner: i,
|
|
2983
|
+
inputCompressedTokenAccounts: n,
|
|
2984
|
+
outputStateTree: r,
|
|
2985
|
+
recentValidityProof: o,
|
|
2986
|
+
recentInputStateRootIndices: s,
|
|
2987
|
+
} = t;
|
|
2988
|
+
if (n.length > 3)
|
|
2989
|
+
throw new Error('Cannot merge more than 3 token accounts at once');
|
|
2990
|
+
return [
|
|
2991
|
+
await this.transfer({
|
|
2992
|
+
payer: e,
|
|
2993
|
+
inputCompressedTokenAccounts: n,
|
|
2994
|
+
toAddress: i,
|
|
2995
|
+
amount: n.reduce((t, e) => t.add(e.parsed.amount), new y(0)),
|
|
2996
|
+
outputStateTrees: r,
|
|
2997
|
+
recentInputStateRootIndices: s,
|
|
2998
|
+
recentValidityProof: o,
|
|
2999
|
+
}),
|
|
3000
|
+
];
|
|
3001
|
+
}
|
|
3002
|
+
static async compressSplTokenAccount(n) {
|
|
3003
|
+
const {
|
|
3004
|
+
feePayer: r,
|
|
3005
|
+
authority: o,
|
|
3006
|
+
tokenAccount: s,
|
|
3007
|
+
mint: a,
|
|
3008
|
+
remainingAmount: u,
|
|
3009
|
+
outputStateTree: m,
|
|
3010
|
+
tokenProgramId: h,
|
|
3011
|
+
} = n,
|
|
3012
|
+
l = null != h ? h : i.TOKEN_PROGRAM_ID,
|
|
3013
|
+
d = [{ pubkey: m, isSigner: 0, isWritable: 1 }],
|
|
3014
|
+
c = I({
|
|
3015
|
+
owner: o,
|
|
3016
|
+
remainingAmount: null != u ? u : null,
|
|
3017
|
+
cpiContext: null,
|
|
3018
|
+
}),
|
|
3019
|
+
{
|
|
3020
|
+
accountCompressionAuthority: p,
|
|
3021
|
+
noopProgram: g,
|
|
3022
|
+
registeredProgramPda: f,
|
|
3023
|
+
accountCompressionProgram: y,
|
|
3024
|
+
} = t.defaultStaticAccountsStruct(),
|
|
3025
|
+
M = D({
|
|
3026
|
+
feePayer: r,
|
|
3027
|
+
authority: o,
|
|
3028
|
+
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
3029
|
+
lightSystemProgram: t.LightSystemProgram.programId,
|
|
3030
|
+
registeredProgramPda: f,
|
|
3031
|
+
noopProgram: g,
|
|
3032
|
+
accountCompressionAuthority: p,
|
|
3033
|
+
accountCompressionProgram: y,
|
|
3034
|
+
selfProgram: this.programId,
|
|
3035
|
+
tokenPoolPda: this.deriveTokenPoolPda(a),
|
|
3036
|
+
compressOrDecompressTokenAccount: s,
|
|
3037
|
+
tokenProgram: l,
|
|
3038
|
+
systemProgram: e.SystemProgram.programId,
|
|
3039
|
+
});
|
|
3040
|
+
return (
|
|
3041
|
+
M.push(...d),
|
|
3042
|
+
new e.TransactionInstruction({
|
|
3043
|
+
programId: this.programId,
|
|
3044
|
+
keys: M,
|
|
3045
|
+
data: c,
|
|
3046
|
+
})
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
static async get_mint_program_id(t, e) {
|
|
3050
|
+
var i;
|
|
3051
|
+
return null === (i = await e.getAccountInfo(t)) || void 0 === i
|
|
3052
|
+
? void 0
|
|
3053
|
+
: i.owner;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
function W(e, i) {
|
|
3057
|
+
let n = t.bn(0),
|
|
3058
|
+
r = t.bn(0);
|
|
3059
|
+
const o = [];
|
|
3060
|
+
e.sort((t, e) => e.parsed.amount.cmp(t.parsed.amount));
|
|
3061
|
+
for (const s of e) {
|
|
3062
|
+
if (n.gte(t.bn(i))) break;
|
|
3063
|
+
(n = n.add(s.parsed.amount)),
|
|
3064
|
+
(r = r.add(s.compressedAccount.lamports)),
|
|
3065
|
+
o.push(s);
|
|
3066
|
+
}
|
|
3067
|
+
if (n.lt(t.bn(i)))
|
|
3068
|
+
throw new Error(
|
|
3069
|
+
`Not enough balance for transfer. Required: ${i.toString()}, available: ${n.toString()}`,
|
|
3070
|
+
);
|
|
3071
|
+
return [o, n, r.lt(t.bn(0)) ? r : null];
|
|
3072
|
+
}
|
|
3073
|
+
(N.programId = new e.PublicKey('cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m')),
|
|
3074
|
+
(exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR = l),
|
|
3075
|
+
(exports.CPI_AUTHORITY_SEED = a),
|
|
3076
|
+
(exports.CREATE_TOKEN_POOL_DISCRIMINATOR = u),
|
|
3077
|
+
(exports.CompressedTokenInstructionDataTransferLayout = S),
|
|
3078
|
+
(exports.CompressedTokenProgram = N),
|
|
3079
|
+
(exports.CpiContextLayout = P),
|
|
3080
|
+
(exports.DelegatedTransferLayout = b),
|
|
3081
|
+
(exports.IDL = {
|
|
3082
|
+
version: '1.2.0',
|
|
3083
|
+
name: 'light_compressed_token',
|
|
3084
|
+
instructions: [
|
|
3085
|
+
{
|
|
3086
|
+
name: 'createTokenPool',
|
|
3087
|
+
docs: [
|
|
3088
|
+
'This instruction creates a token pool for a given mint. Every spl mint',
|
|
3089
|
+
'can have one token pool. When a token is compressed the tokens are',
|
|
3090
|
+
'transferrred to the token pool, and their compressed equivalent is',
|
|
3091
|
+
'minted into a Merkle tree.',
|
|
3092
|
+
],
|
|
3093
|
+
accounts: [
|
|
3094
|
+
{
|
|
3095
|
+
name: 'feePayer',
|
|
3096
|
+
isMut: 1,
|
|
3097
|
+
isSigner: 1,
|
|
3098
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3099
|
+
},
|
|
3100
|
+
{ name: 'tokenPoolPda', isMut: 1, isSigner: 0 },
|
|
3101
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3102
|
+
{ name: 'mint', isMut: 1, isSigner: 0 },
|
|
3103
|
+
{ name: 'tokenProgram', isMut: 0, isSigner: 0 },
|
|
3104
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3105
|
+
],
|
|
3106
|
+
args: [],
|
|
3107
|
+
},
|
|
3108
|
+
{
|
|
3109
|
+
name: 'addTokenPool',
|
|
3110
|
+
docs: [
|
|
3111
|
+
'This instruction creates an additional token pool for a given mint.',
|
|
3112
|
+
'The maximum number of token pools per mint is 5.',
|
|
3113
|
+
],
|
|
3114
|
+
accounts: [
|
|
3115
|
+
{
|
|
3116
|
+
name: 'feePayer',
|
|
3117
|
+
isMut: 1,
|
|
3118
|
+
isSigner: 1,
|
|
3119
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3120
|
+
},
|
|
3121
|
+
{ name: 'tokenPoolPda', isMut: 1, isSigner: 0 },
|
|
3122
|
+
{ name: 'existingTokenPoolPda', isMut: 0, isSigner: 0 },
|
|
3123
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3124
|
+
{ name: 'mint', isMut: 1, isSigner: 0 },
|
|
3125
|
+
{ name: 'tokenProgram', isMut: 0, isSigner: 0 },
|
|
3126
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3127
|
+
],
|
|
3128
|
+
args: [{ name: 'tokenPoolIndex', type: 'u8' }],
|
|
3129
|
+
},
|
|
3130
|
+
{
|
|
3131
|
+
name: 'mintTo',
|
|
3132
|
+
docs: [
|
|
3133
|
+
'Mints tokens from an spl token mint to a list of compressed accounts.',
|
|
3134
|
+
'Minted tokens are transferred to a pool account owned by the compressed',
|
|
3135
|
+
'token program. The instruction creates one compressed output account for',
|
|
3136
|
+
'every amount and pubkey input pair. A constant amount of lamports can be',
|
|
3137
|
+
'transferred to each output account to enable. A use case to add lamports',
|
|
3138
|
+
'to a compressed token account is to prevent spam. This is the only way',
|
|
3139
|
+
'to add lamports to a compressed token account.',
|
|
3140
|
+
],
|
|
3141
|
+
accounts: [
|
|
3142
|
+
{
|
|
3143
|
+
name: 'feePayer',
|
|
3144
|
+
isMut: 1,
|
|
3145
|
+
isSigner: 1,
|
|
3146
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3147
|
+
},
|
|
3148
|
+
{ name: 'authority', isMut: 0, isSigner: 1 },
|
|
3149
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3150
|
+
{ name: 'mint', isMut: 1, isSigner: 0 },
|
|
3151
|
+
{ name: 'tokenPoolPda', isMut: 1, isSigner: 0 },
|
|
3152
|
+
{ name: 'tokenProgram', isMut: 0, isSigner: 0 },
|
|
3153
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3154
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3155
|
+
{
|
|
3156
|
+
name: 'noopProgram',
|
|
3157
|
+
isMut: 0,
|
|
3158
|
+
isSigner: 0,
|
|
3159
|
+
docs: ['programs'],
|
|
3160
|
+
},
|
|
3161
|
+
{
|
|
3162
|
+
name: 'accountCompressionAuthority',
|
|
3163
|
+
isMut: 0,
|
|
3164
|
+
isSigner: 0,
|
|
3165
|
+
},
|
|
3166
|
+
{
|
|
3167
|
+
name: 'accountCompressionProgram',
|
|
3168
|
+
isMut: 0,
|
|
3169
|
+
isSigner: 0,
|
|
3170
|
+
},
|
|
3171
|
+
{ name: 'merkleTree', isMut: 1, isSigner: 0 },
|
|
3172
|
+
{ name: 'selfProgram', isMut: 0, isSigner: 0 },
|
|
3173
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3174
|
+
{
|
|
3175
|
+
name: 'solPoolPda',
|
|
3176
|
+
isMut: 1,
|
|
3177
|
+
isSigner: 0,
|
|
3178
|
+
isOptional: 1,
|
|
3179
|
+
},
|
|
3180
|
+
],
|
|
3181
|
+
args: [
|
|
3182
|
+
{ name: 'publicKeys', type: { vec: 'publicKey' } },
|
|
3183
|
+
{ name: 'amounts', type: { vec: 'u64' } },
|
|
3184
|
+
{ name: 'lamports', type: { option: 'u64' } },
|
|
3185
|
+
],
|
|
3186
|
+
},
|
|
3187
|
+
{
|
|
3188
|
+
name: 'compressSplTokenAccount',
|
|
3189
|
+
docs: [
|
|
3190
|
+
'Compresses the balance of an spl token account sub an optional remaining',
|
|
3191
|
+
'amount. This instruction does not close the spl token account. To close',
|
|
3192
|
+
'the account bundle a close spl account instruction in your transaction.',
|
|
3193
|
+
],
|
|
3194
|
+
accounts: [
|
|
3195
|
+
{
|
|
3196
|
+
name: 'feePayer',
|
|
3197
|
+
isMut: 1,
|
|
3198
|
+
isSigner: 1,
|
|
3199
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3200
|
+
},
|
|
3201
|
+
{
|
|
3202
|
+
name: 'authority',
|
|
3203
|
+
isMut: 0,
|
|
3204
|
+
isSigner: 1,
|
|
3205
|
+
docs: [
|
|
3206
|
+
'Authority is verified through proof since both owner and delegate',
|
|
3207
|
+
'are included in the token data hash, which is a public input to the',
|
|
3208
|
+
'validity proof.',
|
|
3209
|
+
],
|
|
3210
|
+
},
|
|
3211
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3212
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3213
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3214
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3215
|
+
{
|
|
3216
|
+
name: 'accountCompressionAuthority',
|
|
3217
|
+
isMut: 0,
|
|
3218
|
+
isSigner: 0,
|
|
3219
|
+
},
|
|
3220
|
+
{
|
|
3221
|
+
name: 'accountCompressionProgram',
|
|
3222
|
+
isMut: 0,
|
|
3223
|
+
isSigner: 0,
|
|
3224
|
+
},
|
|
3225
|
+
{
|
|
3226
|
+
name: 'selfProgram',
|
|
3227
|
+
isMut: 0,
|
|
3228
|
+
isSigner: 0,
|
|
3229
|
+
docs: ['this program is the signer of the cpi.'],
|
|
3230
|
+
},
|
|
3231
|
+
{
|
|
3232
|
+
name: 'tokenPoolPda',
|
|
3233
|
+
isMut: 1,
|
|
3234
|
+
isSigner: 0,
|
|
3235
|
+
isOptional: 1,
|
|
3236
|
+
},
|
|
3237
|
+
{
|
|
3238
|
+
name: 'compressOrDecompressTokenAccount',
|
|
3239
|
+
isMut: 1,
|
|
3240
|
+
isSigner: 0,
|
|
3241
|
+
isOptional: 1,
|
|
3242
|
+
},
|
|
3243
|
+
{
|
|
3244
|
+
name: 'tokenProgram',
|
|
3245
|
+
isMut: 0,
|
|
3246
|
+
isSigner: 0,
|
|
3247
|
+
isOptional: 1,
|
|
3248
|
+
},
|
|
3249
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3250
|
+
],
|
|
3251
|
+
args: [
|
|
3252
|
+
{ name: 'owner', type: 'publicKey' },
|
|
3253
|
+
{ name: 'remainingAmount', type: { option: 'u64' } },
|
|
3254
|
+
{
|
|
3255
|
+
name: 'cpiContext',
|
|
3256
|
+
type: { option: { defined: 'CompressedCpiContext' } },
|
|
3257
|
+
},
|
|
3258
|
+
],
|
|
3259
|
+
},
|
|
3260
|
+
{
|
|
3261
|
+
name: 'transfer',
|
|
3262
|
+
docs: [
|
|
3263
|
+
'Transfers compressed tokens from one account to another. All accounts',
|
|
3264
|
+
'must be of the same mint. Additional spl tokens can be compressed or',
|
|
3265
|
+
'decompressed. In one transaction only compression or decompression is',
|
|
3266
|
+
'possible. Lamports can be transferred alongside tokens. If output token',
|
|
3267
|
+
'accounts specify less lamports than inputs the remaining lamports are',
|
|
3268
|
+
'transferred to an output compressed account. Signer must be owner or',
|
|
3269
|
+
'delegate. If a delegated token account is transferred the delegate is',
|
|
3270
|
+
'not preserved.',
|
|
3271
|
+
],
|
|
3272
|
+
accounts: [
|
|
3273
|
+
{
|
|
3274
|
+
name: 'feePayer',
|
|
3275
|
+
isMut: 1,
|
|
3276
|
+
isSigner: 1,
|
|
3277
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3278
|
+
},
|
|
3279
|
+
{
|
|
3280
|
+
name: 'authority',
|
|
3281
|
+
isMut: 0,
|
|
3282
|
+
isSigner: 1,
|
|
3283
|
+
docs: [
|
|
3284
|
+
'Authority is verified through proof since both owner and delegate',
|
|
3285
|
+
'are included in the token data hash, which is a public input to the',
|
|
3286
|
+
'validity proof.',
|
|
3287
|
+
],
|
|
3288
|
+
},
|
|
3289
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3290
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3291
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3292
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3293
|
+
{
|
|
3294
|
+
name: 'accountCompressionAuthority',
|
|
3295
|
+
isMut: 0,
|
|
3296
|
+
isSigner: 0,
|
|
3297
|
+
},
|
|
3298
|
+
{
|
|
3299
|
+
name: 'accountCompressionProgram',
|
|
3300
|
+
isMut: 0,
|
|
3301
|
+
isSigner: 0,
|
|
3302
|
+
},
|
|
3303
|
+
{
|
|
3304
|
+
name: 'selfProgram',
|
|
3305
|
+
isMut: 0,
|
|
3306
|
+
isSigner: 0,
|
|
3307
|
+
docs: ['this program is the signer of the cpi.'],
|
|
3308
|
+
},
|
|
3309
|
+
{
|
|
3310
|
+
name: 'tokenPoolPda',
|
|
3311
|
+
isMut: 1,
|
|
3312
|
+
isSigner: 0,
|
|
3313
|
+
isOptional: 1,
|
|
3314
|
+
},
|
|
3315
|
+
{
|
|
3316
|
+
name: 'compressOrDecompressTokenAccount',
|
|
3317
|
+
isMut: 1,
|
|
3318
|
+
isSigner: 0,
|
|
3319
|
+
isOptional: 1,
|
|
3320
|
+
},
|
|
3321
|
+
{
|
|
3322
|
+
name: 'tokenProgram',
|
|
3323
|
+
isMut: 0,
|
|
3324
|
+
isSigner: 0,
|
|
3325
|
+
isOptional: 1,
|
|
3326
|
+
},
|
|
3327
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3328
|
+
],
|
|
3329
|
+
args: [{ name: 'inputs', type: 'bytes' }],
|
|
3330
|
+
},
|
|
3331
|
+
{
|
|
3332
|
+
name: 'approve',
|
|
3333
|
+
docs: [
|
|
3334
|
+
'Delegates an amount to a delegate. A compressed token account is either',
|
|
3335
|
+
'completely delegated or not. Prior delegates are not preserved. Cannot',
|
|
3336
|
+
'be called by a delegate.',
|
|
3337
|
+
'The instruction creates two output accounts:',
|
|
3338
|
+
'1. one account with delegated amount',
|
|
3339
|
+
'2. one account with remaining(change) amount',
|
|
3340
|
+
],
|
|
3341
|
+
accounts: [
|
|
3342
|
+
{
|
|
3343
|
+
name: 'feePayer',
|
|
3344
|
+
isMut: 1,
|
|
3345
|
+
isSigner: 1,
|
|
3346
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3347
|
+
},
|
|
3348
|
+
{
|
|
3349
|
+
name: 'authority',
|
|
3350
|
+
isMut: 0,
|
|
3351
|
+
isSigner: 1,
|
|
3352
|
+
docs: [
|
|
3353
|
+
'Authority is verified through proof since both owner and delegate',
|
|
3354
|
+
'are included in the token data hash, which is a public input to the',
|
|
3355
|
+
'validity proof.',
|
|
3356
|
+
],
|
|
3357
|
+
},
|
|
3358
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3359
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3360
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3361
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3362
|
+
{
|
|
3363
|
+
name: 'accountCompressionAuthority',
|
|
3364
|
+
isMut: 0,
|
|
3365
|
+
isSigner: 0,
|
|
3366
|
+
},
|
|
3367
|
+
{
|
|
3368
|
+
name: 'accountCompressionProgram',
|
|
3369
|
+
isMut: 0,
|
|
3370
|
+
isSigner: 0,
|
|
3371
|
+
},
|
|
3372
|
+
{
|
|
3373
|
+
name: 'selfProgram',
|
|
3374
|
+
isMut: 0,
|
|
3375
|
+
isSigner: 0,
|
|
3376
|
+
docs: ['this program is the signer of the cpi.'],
|
|
3377
|
+
},
|
|
3378
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3379
|
+
],
|
|
3380
|
+
args: [{ name: 'inputs', type: 'bytes' }],
|
|
3381
|
+
},
|
|
3382
|
+
{
|
|
3383
|
+
name: 'revoke',
|
|
3384
|
+
docs: [
|
|
3385
|
+
'Revokes a delegation. The instruction merges all inputs into one output',
|
|
3386
|
+
'account. Cannot be called by a delegate. Delegates are not preserved.',
|
|
3387
|
+
],
|
|
3388
|
+
accounts: [
|
|
3389
|
+
{
|
|
3390
|
+
name: 'feePayer',
|
|
3391
|
+
isMut: 1,
|
|
3392
|
+
isSigner: 1,
|
|
3393
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3394
|
+
},
|
|
3395
|
+
{
|
|
3396
|
+
name: 'authority',
|
|
3397
|
+
isMut: 0,
|
|
3398
|
+
isSigner: 1,
|
|
3399
|
+
docs: [
|
|
3400
|
+
'Authority is verified through proof since both owner and delegate',
|
|
3401
|
+
'are included in the token data hash, which is a public input to the',
|
|
3402
|
+
'validity proof.',
|
|
3403
|
+
],
|
|
3404
|
+
},
|
|
3405
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3406
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3407
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3408
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3409
|
+
{
|
|
3410
|
+
name: 'accountCompressionAuthority',
|
|
3411
|
+
isMut: 0,
|
|
3412
|
+
isSigner: 0,
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
name: 'accountCompressionProgram',
|
|
3416
|
+
isMut: 0,
|
|
3417
|
+
isSigner: 0,
|
|
3418
|
+
},
|
|
3419
|
+
{
|
|
3420
|
+
name: 'selfProgram',
|
|
3421
|
+
isMut: 0,
|
|
3422
|
+
isSigner: 0,
|
|
3423
|
+
docs: ['this program is the signer of the cpi.'],
|
|
3424
|
+
},
|
|
3425
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3426
|
+
],
|
|
3427
|
+
args: [{ name: 'inputs', type: 'bytes' }],
|
|
3428
|
+
},
|
|
3429
|
+
{
|
|
3430
|
+
name: 'freeze',
|
|
3431
|
+
docs: [
|
|
3432
|
+
'Freezes compressed token accounts. Inputs must not be frozen. Creates as',
|
|
3433
|
+
'many outputs as inputs. Balances and delegates are preserved.',
|
|
3434
|
+
],
|
|
3435
|
+
accounts: [
|
|
3436
|
+
{
|
|
3437
|
+
name: 'feePayer',
|
|
3438
|
+
isMut: 1,
|
|
3439
|
+
isSigner: 1,
|
|
3440
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3441
|
+
},
|
|
3442
|
+
{ name: 'authority', isMut: 0, isSigner: 1 },
|
|
3443
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3444
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3445
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3446
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3447
|
+
{
|
|
3448
|
+
name: 'accountCompressionAuthority',
|
|
3449
|
+
isMut: 0,
|
|
3450
|
+
isSigner: 0,
|
|
3451
|
+
},
|
|
3452
|
+
{
|
|
3453
|
+
name: 'accountCompressionProgram',
|
|
3454
|
+
isMut: 0,
|
|
3455
|
+
isSigner: 0,
|
|
3456
|
+
},
|
|
3457
|
+
{
|
|
3458
|
+
name: 'selfProgram',
|
|
3459
|
+
isMut: 0,
|
|
3460
|
+
isSigner: 0,
|
|
3461
|
+
docs: ['that this program is the signer of the cpi.'],
|
|
3462
|
+
},
|
|
3463
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3464
|
+
{ name: 'mint', isMut: 0, isSigner: 0 },
|
|
3465
|
+
],
|
|
3466
|
+
args: [{ name: 'inputs', type: 'bytes' }],
|
|
3467
|
+
},
|
|
3468
|
+
{
|
|
3469
|
+
name: 'thaw',
|
|
3470
|
+
docs: [
|
|
3471
|
+
'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',
|
|
3472
|
+
'as many outputs as inputs. Balances and delegates are preserved.',
|
|
3473
|
+
],
|
|
3474
|
+
accounts: [
|
|
3475
|
+
{
|
|
3476
|
+
name: 'feePayer',
|
|
3477
|
+
isMut: 1,
|
|
3478
|
+
isSigner: 1,
|
|
3479
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3480
|
+
},
|
|
3481
|
+
{ name: 'authority', isMut: 0, isSigner: 1 },
|
|
3482
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3483
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3484
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3485
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3486
|
+
{
|
|
3487
|
+
name: 'accountCompressionAuthority',
|
|
3488
|
+
isMut: 0,
|
|
3489
|
+
isSigner: 0,
|
|
3490
|
+
},
|
|
3491
|
+
{
|
|
3492
|
+
name: 'accountCompressionProgram',
|
|
3493
|
+
isMut: 0,
|
|
3494
|
+
isSigner: 0,
|
|
3495
|
+
},
|
|
3496
|
+
{
|
|
3497
|
+
name: 'selfProgram',
|
|
3498
|
+
isMut: 0,
|
|
3499
|
+
isSigner: 0,
|
|
3500
|
+
docs: ['that this program is the signer of the cpi.'],
|
|
3501
|
+
},
|
|
3502
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3503
|
+
{ name: 'mint', isMut: 0, isSigner: 0 },
|
|
3504
|
+
],
|
|
3505
|
+
args: [{ name: 'inputs', type: 'bytes' }],
|
|
3506
|
+
},
|
|
3507
|
+
{
|
|
3508
|
+
name: 'burn',
|
|
3509
|
+
docs: [
|
|
3510
|
+
'Burns compressed tokens and spl tokens from the pool account. Delegates',
|
|
3511
|
+
'can burn tokens. The output compressed token account remains delegated.',
|
|
3512
|
+
'Creates one output compressed token account.',
|
|
3513
|
+
],
|
|
3514
|
+
accounts: [
|
|
3515
|
+
{
|
|
3516
|
+
name: 'feePayer',
|
|
3517
|
+
isMut: 1,
|
|
3518
|
+
isSigner: 1,
|
|
3519
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3520
|
+
},
|
|
3521
|
+
{
|
|
3522
|
+
name: 'authority',
|
|
3523
|
+
isMut: 0,
|
|
3524
|
+
isSigner: 1,
|
|
3525
|
+
docs: [
|
|
3526
|
+
'Authority is verified through proof since both owner and delegate',
|
|
3527
|
+
'are included in the token data hash, which is a public input to the',
|
|
3528
|
+
'validity proof.',
|
|
3529
|
+
],
|
|
3530
|
+
},
|
|
3531
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3532
|
+
{ name: 'mint', isMut: 1, isSigner: 0 },
|
|
3533
|
+
{ name: 'tokenPoolPda', isMut: 1, isSigner: 0 },
|
|
3534
|
+
{ name: 'tokenProgram', isMut: 0, isSigner: 0 },
|
|
3535
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3536
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3537
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3538
|
+
{
|
|
3539
|
+
name: 'accountCompressionAuthority',
|
|
3540
|
+
isMut: 0,
|
|
3541
|
+
isSigner: 0,
|
|
3542
|
+
},
|
|
3543
|
+
{
|
|
3544
|
+
name: 'accountCompressionProgram',
|
|
3545
|
+
isMut: 0,
|
|
3546
|
+
isSigner: 0,
|
|
3547
|
+
},
|
|
3548
|
+
{ name: 'selfProgram', isMut: 0, isSigner: 0 },
|
|
3549
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3550
|
+
],
|
|
3551
|
+
args: [{ name: 'inputs', type: 'bytes' }],
|
|
3552
|
+
},
|
|
3553
|
+
{
|
|
3554
|
+
name: 'stubIdlBuild',
|
|
3555
|
+
docs: [
|
|
3556
|
+
'This function is a stub to allow Anchor to include the input types in',
|
|
3557
|
+
'the IDL. It should not be included in production builds nor be called in',
|
|
3558
|
+
'practice.',
|
|
3559
|
+
],
|
|
3560
|
+
accounts: [
|
|
3561
|
+
{
|
|
3562
|
+
name: 'feePayer',
|
|
3563
|
+
isMut: 1,
|
|
3564
|
+
isSigner: 1,
|
|
3565
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
3566
|
+
},
|
|
3567
|
+
{
|
|
3568
|
+
name: 'authority',
|
|
3569
|
+
isMut: 0,
|
|
3570
|
+
isSigner: 1,
|
|
3571
|
+
docs: [
|
|
3572
|
+
'Authority is verified through proof since both owner and delegate',
|
|
3573
|
+
'are included in the token data hash, which is a public input to the',
|
|
3574
|
+
'validity proof.',
|
|
3575
|
+
],
|
|
3576
|
+
},
|
|
3577
|
+
{ name: 'cpiAuthorityPda', isMut: 0, isSigner: 0 },
|
|
3578
|
+
{ name: 'lightSystemProgram', isMut: 0, isSigner: 0 },
|
|
3579
|
+
{ name: 'registeredProgramPda', isMut: 0, isSigner: 0 },
|
|
3580
|
+
{ name: 'noopProgram', isMut: 0, isSigner: 0 },
|
|
3581
|
+
{
|
|
3582
|
+
name: 'accountCompressionAuthority',
|
|
3583
|
+
isMut: 0,
|
|
3584
|
+
isSigner: 0,
|
|
3585
|
+
},
|
|
3586
|
+
{
|
|
3587
|
+
name: 'accountCompressionProgram',
|
|
3588
|
+
isMut: 0,
|
|
3589
|
+
isSigner: 0,
|
|
3590
|
+
},
|
|
3591
|
+
{
|
|
3592
|
+
name: 'selfProgram',
|
|
3593
|
+
isMut: 0,
|
|
3594
|
+
isSigner: 0,
|
|
3595
|
+
docs: ['this program is the signer of the cpi.'],
|
|
3596
|
+
},
|
|
3597
|
+
{
|
|
3598
|
+
name: 'tokenPoolPda',
|
|
3599
|
+
isMut: 1,
|
|
3600
|
+
isSigner: 0,
|
|
3601
|
+
isOptional: 1,
|
|
3602
|
+
},
|
|
3603
|
+
{
|
|
3604
|
+
name: 'compressOrDecompressTokenAccount',
|
|
3605
|
+
isMut: 1,
|
|
3606
|
+
isSigner: 0,
|
|
3607
|
+
isOptional: 1,
|
|
3608
|
+
},
|
|
3609
|
+
{
|
|
3610
|
+
name: 'tokenProgram',
|
|
3611
|
+
isMut: 0,
|
|
3612
|
+
isSigner: 0,
|
|
3613
|
+
isOptional: 1,
|
|
3614
|
+
},
|
|
3615
|
+
{ name: 'systemProgram', isMut: 0, isSigner: 0 },
|
|
3616
|
+
],
|
|
3617
|
+
args: [
|
|
3618
|
+
{
|
|
3619
|
+
name: 'inputs1',
|
|
3620
|
+
type: {
|
|
3621
|
+
defined: 'CompressedTokenInstructionDataTransfer',
|
|
3622
|
+
},
|
|
3623
|
+
},
|
|
3624
|
+
{ name: 'inputs2', type: { defined: 'TokenData' } },
|
|
3625
|
+
],
|
|
3626
|
+
},
|
|
3627
|
+
],
|
|
3628
|
+
types: [
|
|
3629
|
+
{
|
|
3630
|
+
name: 'AccountState',
|
|
3631
|
+
type: {
|
|
3632
|
+
kind: 'enum',
|
|
3633
|
+
variants: [{ name: 'Initialized' }, { name: 'Frozen' }],
|
|
3634
|
+
},
|
|
3635
|
+
},
|
|
3636
|
+
{
|
|
3637
|
+
name: 'CompressedAccount',
|
|
3638
|
+
type: {
|
|
3639
|
+
kind: 'struct',
|
|
3640
|
+
fields: [
|
|
3641
|
+
{ name: 'owner', type: 'publicKey' },
|
|
3642
|
+
{ name: 'lamports', type: 'u64' },
|
|
3643
|
+
{
|
|
3644
|
+
name: 'address',
|
|
3645
|
+
type: { option: { array: ['u8', 32] } },
|
|
3646
|
+
},
|
|
3647
|
+
{
|
|
3648
|
+
name: 'data',
|
|
3649
|
+
type: {
|
|
3650
|
+
option: { defined: 'CompressedAccountData' },
|
|
3651
|
+
},
|
|
3652
|
+
},
|
|
3653
|
+
],
|
|
3654
|
+
},
|
|
3655
|
+
},
|
|
3656
|
+
{
|
|
3657
|
+
name: 'CompressedAccountData',
|
|
3658
|
+
type: {
|
|
3659
|
+
kind: 'struct',
|
|
3660
|
+
fields: [
|
|
3661
|
+
{ name: 'discriminator', type: { array: ['u8', 8] } },
|
|
3662
|
+
{ name: 'data', type: 'bytes' },
|
|
3663
|
+
{ name: 'dataHash', type: { array: ['u8', 32] } },
|
|
3664
|
+
],
|
|
3665
|
+
},
|
|
3666
|
+
},
|
|
3667
|
+
{
|
|
3668
|
+
name: 'CompressedCpiContext',
|
|
3669
|
+
type: {
|
|
3670
|
+
kind: 'struct',
|
|
3671
|
+
fields: [
|
|
3672
|
+
{
|
|
3673
|
+
name: 'setContext',
|
|
3674
|
+
docs: [
|
|
3675
|
+
'Is set by the program that is invoking the CPI to signal that is should',
|
|
3676
|
+
'set the cpi context.',
|
|
3677
|
+
],
|
|
3678
|
+
type: 'bool',
|
|
3679
|
+
},
|
|
3680
|
+
{
|
|
3681
|
+
name: 'firstSetContext',
|
|
3682
|
+
docs: [
|
|
3683
|
+
'Is set to wipe the cpi context since someone could have set it before',
|
|
3684
|
+
'with unrelated data.',
|
|
3685
|
+
],
|
|
3686
|
+
type: 'bool',
|
|
3687
|
+
},
|
|
3688
|
+
{
|
|
3689
|
+
name: 'cpiContextAccountIndex',
|
|
3690
|
+
docs: [
|
|
3691
|
+
'Index of cpi context account in remaining accounts.',
|
|
3692
|
+
],
|
|
3693
|
+
type: 'u8',
|
|
3694
|
+
},
|
|
3695
|
+
],
|
|
3696
|
+
},
|
|
3697
|
+
},
|
|
3698
|
+
{
|
|
3699
|
+
name: 'CompressedProof',
|
|
3700
|
+
type: {
|
|
3701
|
+
kind: 'struct',
|
|
3702
|
+
fields: [
|
|
3703
|
+
{ name: 'a', type: { array: ['u8', 32] } },
|
|
3704
|
+
{ name: 'b', type: { array: ['u8', 64] } },
|
|
3705
|
+
{ name: 'c', type: { array: ['u8', 32] } },
|
|
3706
|
+
],
|
|
3707
|
+
},
|
|
3708
|
+
},
|
|
3709
|
+
{
|
|
3710
|
+
name: 'CompressedTokenInstructionDataTransfer',
|
|
3711
|
+
type: {
|
|
3712
|
+
kind: 'struct',
|
|
3713
|
+
fields: [
|
|
3714
|
+
{
|
|
3715
|
+
name: 'proof',
|
|
3716
|
+
type: { option: { defined: 'CompressedProof' } },
|
|
3717
|
+
},
|
|
3718
|
+
{ name: 'mint', type: 'publicKey' },
|
|
3719
|
+
{
|
|
3720
|
+
name: 'delegatedTransfer',
|
|
3721
|
+
docs: [
|
|
3722
|
+
'Is required if the signer is delegate,',
|
|
3723
|
+
'-> delegate is authority account,',
|
|
3724
|
+
'owner = Some(owner) is the owner of the token account.',
|
|
3725
|
+
],
|
|
3726
|
+
type: { option: { defined: 'DelegatedTransfer' } },
|
|
3727
|
+
},
|
|
3728
|
+
{
|
|
3729
|
+
name: 'inputTokenDataWithContext',
|
|
3730
|
+
type: {
|
|
3731
|
+
vec: { defined: 'InputTokenDataWithContext' },
|
|
3732
|
+
},
|
|
3733
|
+
},
|
|
3734
|
+
{
|
|
3735
|
+
name: 'outputCompressedAccounts',
|
|
3736
|
+
type: {
|
|
3737
|
+
vec: {
|
|
3738
|
+
defined: 'PackedTokenTransferOutputData',
|
|
3739
|
+
},
|
|
3740
|
+
},
|
|
3741
|
+
},
|
|
3742
|
+
{ name: 'isCompress', type: 'bool' },
|
|
3743
|
+
{
|
|
3744
|
+
name: 'compressOrDecompressAmount',
|
|
3745
|
+
type: { option: 'u64' },
|
|
3746
|
+
},
|
|
3747
|
+
{
|
|
3748
|
+
name: 'cpiContext',
|
|
3749
|
+
type: {
|
|
3750
|
+
option: { defined: 'CompressedCpiContext' },
|
|
3751
|
+
},
|
|
3752
|
+
},
|
|
3753
|
+
{
|
|
3754
|
+
name: 'lamportsChangeAccountMerkleTreeIndex',
|
|
3755
|
+
type: { option: 'u8' },
|
|
3756
|
+
},
|
|
3757
|
+
],
|
|
3758
|
+
},
|
|
3759
|
+
},
|
|
3760
|
+
{
|
|
3761
|
+
name: 'DelegatedTransfer',
|
|
3762
|
+
docs: [
|
|
3763
|
+
'Struct to provide the owner when the delegate is signer of the transaction.',
|
|
3764
|
+
],
|
|
3765
|
+
type: {
|
|
3766
|
+
kind: 'struct',
|
|
3767
|
+
fields: [
|
|
3768
|
+
{ name: 'owner', type: 'publicKey' },
|
|
3769
|
+
{
|
|
3770
|
+
name: 'delegateChangeAccountIndex',
|
|
3771
|
+
docs: [
|
|
3772
|
+
'Index of change compressed account in output compressed accounts. In',
|
|
3773
|
+
"case that the delegate didn't spend the complete delegated compressed",
|
|
3774
|
+
'account balance the change compressed account will be delegated to her',
|
|
3775
|
+
'as well.',
|
|
3776
|
+
],
|
|
3777
|
+
type: { option: 'u8' },
|
|
3778
|
+
},
|
|
3779
|
+
],
|
|
3780
|
+
},
|
|
3781
|
+
},
|
|
3782
|
+
{
|
|
3783
|
+
name: 'InputTokenDataWithContext',
|
|
3784
|
+
type: {
|
|
3785
|
+
kind: 'struct',
|
|
3786
|
+
fields: [
|
|
3787
|
+
{ name: 'amount', type: 'u64' },
|
|
3788
|
+
{ name: 'delegateIndex', type: { option: 'u8' } },
|
|
3789
|
+
{
|
|
3790
|
+
name: 'merkleContext',
|
|
3791
|
+
type: { defined: 'PackedMerkleContext' },
|
|
3792
|
+
},
|
|
3793
|
+
{ name: 'rootIndex', type: 'u16' },
|
|
3794
|
+
{ name: 'lamports', type: { option: 'u64' } },
|
|
3795
|
+
{
|
|
3796
|
+
name: 'tlv',
|
|
3797
|
+
docs: [
|
|
3798
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
3799
|
+
],
|
|
3800
|
+
type: { option: 'bytes' },
|
|
3801
|
+
},
|
|
3802
|
+
],
|
|
3803
|
+
},
|
|
3804
|
+
},
|
|
3805
|
+
{
|
|
3806
|
+
name: 'InstructionDataInvoke',
|
|
3807
|
+
type: {
|
|
3808
|
+
kind: 'struct',
|
|
3809
|
+
fields: [
|
|
3810
|
+
{
|
|
3811
|
+
name: 'proof',
|
|
3812
|
+
type: { option: { defined: 'CompressedProof' } },
|
|
3813
|
+
},
|
|
3814
|
+
{
|
|
3815
|
+
name: 'inputCompressedAccountsWithMerkleContext',
|
|
3816
|
+
type: {
|
|
3817
|
+
vec: {
|
|
3818
|
+
defined:
|
|
3819
|
+
'PackedCompressedAccountWithMerkleContext',
|
|
3820
|
+
},
|
|
3821
|
+
},
|
|
3822
|
+
},
|
|
3823
|
+
{
|
|
3824
|
+
name: 'outputCompressedAccounts',
|
|
3825
|
+
type: {
|
|
3826
|
+
vec: {
|
|
3827
|
+
defined:
|
|
3828
|
+
'OutputCompressedAccountWithPackedContext',
|
|
3829
|
+
},
|
|
3830
|
+
},
|
|
3831
|
+
},
|
|
3832
|
+
{ name: 'relayFee', type: { option: 'u64' } },
|
|
3833
|
+
{
|
|
3834
|
+
name: 'newAddressParams',
|
|
3835
|
+
type: {
|
|
3836
|
+
vec: { defined: 'NewAddressParamsPacked' },
|
|
3837
|
+
},
|
|
3838
|
+
},
|
|
3839
|
+
{
|
|
3840
|
+
name: 'compressOrDecompressLamports',
|
|
3841
|
+
type: { option: 'u64' },
|
|
3842
|
+
},
|
|
3843
|
+
{ name: 'isCompress', type: 'bool' },
|
|
3844
|
+
],
|
|
3845
|
+
},
|
|
3846
|
+
},
|
|
3847
|
+
{
|
|
3848
|
+
name: 'InstructionDataInvokeCpi',
|
|
3849
|
+
type: {
|
|
3850
|
+
kind: 'struct',
|
|
3851
|
+
fields: [
|
|
3852
|
+
{
|
|
3853
|
+
name: 'proof',
|
|
3854
|
+
type: { option: { defined: 'CompressedProof' } },
|
|
3855
|
+
},
|
|
3856
|
+
{
|
|
3857
|
+
name: 'newAddressParams',
|
|
3858
|
+
type: {
|
|
3859
|
+
vec: { defined: 'NewAddressParamsPacked' },
|
|
3860
|
+
},
|
|
3861
|
+
},
|
|
3862
|
+
{
|
|
3863
|
+
name: 'inputCompressedAccountsWithMerkleContext',
|
|
3864
|
+
type: {
|
|
3865
|
+
vec: {
|
|
3866
|
+
defined:
|
|
3867
|
+
'PackedCompressedAccountWithMerkleContext',
|
|
3868
|
+
},
|
|
3869
|
+
},
|
|
3870
|
+
},
|
|
3871
|
+
{
|
|
3872
|
+
name: 'outputCompressedAccounts',
|
|
3873
|
+
type: {
|
|
3874
|
+
vec: {
|
|
3875
|
+
defined:
|
|
3876
|
+
'OutputCompressedAccountWithPackedContext',
|
|
3877
|
+
},
|
|
3878
|
+
},
|
|
3879
|
+
},
|
|
3880
|
+
{ name: 'relayFee', type: { option: 'u64' } },
|
|
3881
|
+
{
|
|
3882
|
+
name: 'compressOrDecompressLamports',
|
|
3883
|
+
type: { option: 'u64' },
|
|
3884
|
+
},
|
|
3885
|
+
{ name: 'isCompress', type: 'bool' },
|
|
3886
|
+
{
|
|
3887
|
+
name: 'cpiContext',
|
|
3888
|
+
type: {
|
|
3889
|
+
option: { defined: 'CompressedCpiContext' },
|
|
3890
|
+
},
|
|
3891
|
+
},
|
|
3892
|
+
],
|
|
3893
|
+
},
|
|
3894
|
+
},
|
|
3895
|
+
{
|
|
3896
|
+
name: 'MerkleTreeSequenceNumber',
|
|
3897
|
+
type: {
|
|
3898
|
+
kind: 'struct',
|
|
3899
|
+
fields: [
|
|
3900
|
+
{ name: 'pubkey', type: 'publicKey' },
|
|
3901
|
+
{ name: 'seq', type: 'u64' },
|
|
3902
|
+
],
|
|
3903
|
+
},
|
|
3904
|
+
},
|
|
3905
|
+
{
|
|
3906
|
+
name: 'NewAddressParamsPacked',
|
|
3907
|
+
type: {
|
|
3908
|
+
kind: 'struct',
|
|
3909
|
+
fields: [
|
|
3910
|
+
{ name: 'seed', type: { array: ['u8', 32] } },
|
|
3911
|
+
{ name: 'addressQueueAccountIndex', type: 'u8' },
|
|
3912
|
+
{ name: 'addressMerkleTreeAccountIndex', type: 'u8' },
|
|
3913
|
+
{ name: 'addressMerkleTreeRootIndex', type: 'u16' },
|
|
3914
|
+
],
|
|
3915
|
+
},
|
|
3916
|
+
},
|
|
3917
|
+
{
|
|
3918
|
+
name: 'OutputCompressedAccountWithPackedContext',
|
|
3919
|
+
type: {
|
|
3920
|
+
kind: 'struct',
|
|
3921
|
+
fields: [
|
|
3922
|
+
{
|
|
3923
|
+
name: 'compressedAccount',
|
|
3924
|
+
type: { defined: 'CompressedAccount' },
|
|
3925
|
+
},
|
|
3926
|
+
{ name: 'merkleTreeIndex', type: 'u8' },
|
|
3927
|
+
],
|
|
3928
|
+
},
|
|
3929
|
+
},
|
|
3930
|
+
{
|
|
3931
|
+
name: 'PackedCompressedAccountWithMerkleContext',
|
|
3932
|
+
type: {
|
|
3933
|
+
kind: 'struct',
|
|
3934
|
+
fields: [
|
|
3935
|
+
{
|
|
3936
|
+
name: 'compressedAccount',
|
|
3937
|
+
type: { defined: 'CompressedAccount' },
|
|
3938
|
+
},
|
|
3939
|
+
{
|
|
3940
|
+
name: 'merkleContext',
|
|
3941
|
+
type: { defined: 'PackedMerkleContext' },
|
|
3942
|
+
},
|
|
3943
|
+
{
|
|
3944
|
+
name: 'rootIndex',
|
|
3945
|
+
docs: [
|
|
3946
|
+
'Index of root used in inclusion validity proof.',
|
|
3947
|
+
],
|
|
3948
|
+
type: 'u16',
|
|
3949
|
+
},
|
|
3950
|
+
{
|
|
3951
|
+
name: 'readOnly',
|
|
3952
|
+
docs: [
|
|
3953
|
+
'Placeholder to mark accounts read-only unimplemented set to false.',
|
|
3954
|
+
],
|
|
3955
|
+
type: 'bool',
|
|
3956
|
+
},
|
|
3957
|
+
],
|
|
3958
|
+
},
|
|
3959
|
+
},
|
|
3960
|
+
{
|
|
3961
|
+
name: 'PackedMerkleContext',
|
|
3962
|
+
type: {
|
|
3963
|
+
kind: 'struct',
|
|
3964
|
+
fields: [
|
|
3965
|
+
{ name: 'merkleTreePubkeyIndex', type: 'u8' },
|
|
3966
|
+
{ name: 'nullifierQueuePubkeyIndex', type: 'u8' },
|
|
3967
|
+
{ name: 'leafIndex', type: 'u32' },
|
|
3968
|
+
{
|
|
3969
|
+
name: 'queueIndex',
|
|
3970
|
+
type: { option: { defined: 'QueueIndex' } },
|
|
3971
|
+
},
|
|
3972
|
+
],
|
|
3973
|
+
},
|
|
3974
|
+
},
|
|
3975
|
+
{
|
|
3976
|
+
name: 'PackedTokenTransferOutputData',
|
|
3977
|
+
type: {
|
|
3978
|
+
kind: 'struct',
|
|
3979
|
+
fields: [
|
|
3980
|
+
{ name: 'owner', type: 'publicKey' },
|
|
3981
|
+
{ name: 'amount', type: 'u64' },
|
|
3982
|
+
{ name: 'lamports', type: { option: 'u64' } },
|
|
3983
|
+
{ name: 'merkleTreeIndex', type: 'u8' },
|
|
3984
|
+
{
|
|
3985
|
+
name: 'tlv',
|
|
3986
|
+
docs: [
|
|
3987
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
3988
|
+
],
|
|
3989
|
+
type: { option: 'bytes' },
|
|
3990
|
+
},
|
|
3991
|
+
],
|
|
3992
|
+
},
|
|
3993
|
+
},
|
|
3994
|
+
{
|
|
3995
|
+
name: 'PublicTransactionEvent',
|
|
3996
|
+
type: {
|
|
3997
|
+
kind: 'struct',
|
|
3998
|
+
fields: [
|
|
3999
|
+
{
|
|
4000
|
+
name: 'inputCompressedAccountHashes',
|
|
4001
|
+
type: { vec: { array: ['u8', 32] } },
|
|
4002
|
+
},
|
|
4003
|
+
{
|
|
4004
|
+
name: 'outputCompressedAccountHashes',
|
|
4005
|
+
type: { vec: { array: ['u8', 32] } },
|
|
4006
|
+
},
|
|
4007
|
+
{
|
|
4008
|
+
name: 'outputCompressedAccounts',
|
|
4009
|
+
type: {
|
|
4010
|
+
vec: {
|
|
4011
|
+
defined:
|
|
4012
|
+
'OutputCompressedAccountWithPackedContext',
|
|
4013
|
+
},
|
|
4014
|
+
},
|
|
4015
|
+
},
|
|
4016
|
+
{ name: 'outputLeafIndices', type: { vec: 'u32' } },
|
|
4017
|
+
{
|
|
4018
|
+
name: 'sequenceNumbers',
|
|
4019
|
+
type: {
|
|
4020
|
+
vec: { defined: 'MerkleTreeSequenceNumber' },
|
|
4021
|
+
},
|
|
4022
|
+
},
|
|
4023
|
+
{ name: 'relayFee', type: { option: 'u64' } },
|
|
4024
|
+
{ name: 'isCompress', type: 'bool' },
|
|
4025
|
+
{
|
|
4026
|
+
name: 'compressOrDecompressLamports',
|
|
4027
|
+
type: { option: 'u64' },
|
|
4028
|
+
},
|
|
4029
|
+
{ name: 'pubkeyArray', type: { vec: 'publicKey' } },
|
|
4030
|
+
{ name: 'message', type: { option: 'bytes' } },
|
|
4031
|
+
],
|
|
4032
|
+
},
|
|
4033
|
+
},
|
|
4034
|
+
{
|
|
4035
|
+
name: 'QueueIndex',
|
|
4036
|
+
type: {
|
|
4037
|
+
kind: 'struct',
|
|
4038
|
+
fields: [
|
|
4039
|
+
{
|
|
4040
|
+
name: 'queueId',
|
|
4041
|
+
docs: ['Id of queue in queue account.'],
|
|
4042
|
+
type: 'u8',
|
|
4043
|
+
},
|
|
4044
|
+
{
|
|
4045
|
+
name: 'index',
|
|
4046
|
+
docs: [
|
|
4047
|
+
'Index of compressed account hash in queue.',
|
|
4048
|
+
],
|
|
4049
|
+
type: 'u16',
|
|
4050
|
+
},
|
|
4051
|
+
],
|
|
4052
|
+
},
|
|
4053
|
+
},
|
|
4054
|
+
{
|
|
4055
|
+
name: 'TokenData',
|
|
4056
|
+
type: {
|
|
4057
|
+
kind: 'struct',
|
|
4058
|
+
fields: [
|
|
4059
|
+
{
|
|
4060
|
+
name: 'mint',
|
|
4061
|
+
docs: ['The mint associated with this account'],
|
|
4062
|
+
type: 'publicKey',
|
|
4063
|
+
},
|
|
4064
|
+
{
|
|
4065
|
+
name: 'owner',
|
|
4066
|
+
docs: ['The owner of this account.'],
|
|
4067
|
+
type: 'publicKey',
|
|
4068
|
+
},
|
|
4069
|
+
{
|
|
4070
|
+
name: 'amount',
|
|
4071
|
+
docs: ['The amount of tokens this account holds.'],
|
|
4072
|
+
type: 'u64',
|
|
4073
|
+
},
|
|
4074
|
+
{
|
|
4075
|
+
name: 'delegate',
|
|
4076
|
+
docs: [
|
|
4077
|
+
'If `delegate` is `Some` then `delegated_amount` represents',
|
|
4078
|
+
'the amount authorized by the delegate',
|
|
4079
|
+
],
|
|
4080
|
+
type: { option: 'publicKey' },
|
|
4081
|
+
},
|
|
4082
|
+
{
|
|
4083
|
+
name: 'state',
|
|
4084
|
+
docs: ["The account's state"],
|
|
4085
|
+
type: { defined: 'AccountState' },
|
|
4086
|
+
},
|
|
4087
|
+
{
|
|
4088
|
+
name: 'tlv',
|
|
4089
|
+
docs: [
|
|
4090
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
4091
|
+
],
|
|
4092
|
+
type: { option: 'bytes' },
|
|
4093
|
+
},
|
|
4094
|
+
],
|
|
4095
|
+
},
|
|
4096
|
+
},
|
|
4097
|
+
],
|
|
4098
|
+
errors: [
|
|
4099
|
+
{
|
|
4100
|
+
code: 6e3,
|
|
4101
|
+
name: 'PublicKeyAmountMissmatch',
|
|
4102
|
+
msg: 'public keys and amounts must be of same length',
|
|
4103
|
+
},
|
|
4104
|
+
{
|
|
4105
|
+
code: 6001,
|
|
4106
|
+
name: 'ComputeInputSumFailed',
|
|
4107
|
+
msg: 'ComputeInputSumFailed',
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
code: 6002,
|
|
4111
|
+
name: 'ComputeOutputSumFailed',
|
|
4112
|
+
msg: 'ComputeOutputSumFailed',
|
|
4113
|
+
},
|
|
4114
|
+
{
|
|
4115
|
+
code: 6003,
|
|
4116
|
+
name: 'ComputeCompressSumFailed',
|
|
4117
|
+
msg: 'ComputeCompressSumFailed',
|
|
4118
|
+
},
|
|
4119
|
+
{
|
|
4120
|
+
code: 6004,
|
|
4121
|
+
name: 'ComputeDecompressSumFailed',
|
|
4122
|
+
msg: 'ComputeDecompressSumFailed',
|
|
4123
|
+
},
|
|
4124
|
+
{ code: 6005, name: 'SumCheckFailed', msg: 'SumCheckFailed' },
|
|
4125
|
+
{
|
|
4126
|
+
code: 6006,
|
|
4127
|
+
name: 'DecompressRecipientUndefinedForDecompress',
|
|
4128
|
+
msg: 'DecompressRecipientUndefinedForDecompress',
|
|
4129
|
+
},
|
|
4130
|
+
{
|
|
4131
|
+
code: 6007,
|
|
4132
|
+
name: 'CompressedPdaUndefinedForDecompress',
|
|
4133
|
+
msg: 'CompressedPdaUndefinedForDecompress',
|
|
4134
|
+
},
|
|
4135
|
+
{
|
|
4136
|
+
code: 6008,
|
|
4137
|
+
name: 'DeCompressAmountUndefinedForDecompress',
|
|
4138
|
+
msg: 'DeCompressAmountUndefinedForDecompress',
|
|
4139
|
+
},
|
|
4140
|
+
{
|
|
4141
|
+
code: 6009,
|
|
4142
|
+
name: 'CompressedPdaUndefinedForCompress',
|
|
4143
|
+
msg: 'CompressedPdaUndefinedForCompress',
|
|
4144
|
+
},
|
|
4145
|
+
{
|
|
4146
|
+
code: 6010,
|
|
4147
|
+
name: 'DeCompressAmountUndefinedForCompress',
|
|
4148
|
+
msg: 'DeCompressAmountUndefinedForCompress',
|
|
4149
|
+
},
|
|
4150
|
+
{
|
|
4151
|
+
code: 6011,
|
|
4152
|
+
name: 'DelegateSignerCheckFailed',
|
|
4153
|
+
msg: 'DelegateSignerCheckFailed',
|
|
4154
|
+
},
|
|
4155
|
+
{
|
|
4156
|
+
code: 6012,
|
|
4157
|
+
name: 'MintTooLarge',
|
|
4158
|
+
msg: 'Minted amount greater than u64::MAX',
|
|
4159
|
+
},
|
|
4160
|
+
{
|
|
4161
|
+
code: 6013,
|
|
4162
|
+
name: 'SplTokenSupplyMismatch',
|
|
4163
|
+
msg: 'SplTokenSupplyMismatch',
|
|
4164
|
+
},
|
|
4165
|
+
{
|
|
4166
|
+
code: 6014,
|
|
4167
|
+
name: 'HeapMemoryCheckFailed',
|
|
4168
|
+
msg: 'HeapMemoryCheckFailed',
|
|
4169
|
+
},
|
|
4170
|
+
{
|
|
4171
|
+
code: 6015,
|
|
4172
|
+
name: 'InstructionNotCallable',
|
|
4173
|
+
msg: 'The instruction is not callable',
|
|
4174
|
+
},
|
|
4175
|
+
{
|
|
4176
|
+
code: 6016,
|
|
4177
|
+
name: 'ArithmeticUnderflow',
|
|
4178
|
+
msg: 'ArithmeticUnderflow',
|
|
4179
|
+
},
|
|
4180
|
+
{ code: 6017, name: 'HashToFieldError', msg: 'HashToFieldError' },
|
|
4181
|
+
{
|
|
4182
|
+
code: 6018,
|
|
4183
|
+
name: 'InvalidAuthorityMint',
|
|
4184
|
+
msg: 'Expected the authority to be also a mint authority',
|
|
4185
|
+
},
|
|
4186
|
+
{
|
|
4187
|
+
code: 6019,
|
|
4188
|
+
name: 'InvalidFreezeAuthority',
|
|
4189
|
+
msg: 'Provided authority is not the freeze authority',
|
|
4190
|
+
},
|
|
4191
|
+
{ code: 6020, name: 'InvalidDelegateIndex' },
|
|
4192
|
+
{ code: 6021, name: 'TokenPoolPdaUndefined' },
|
|
4193
|
+
{
|
|
4194
|
+
code: 6022,
|
|
4195
|
+
name: 'IsTokenPoolPda',
|
|
4196
|
+
msg: 'Compress or decompress recipient is the same account as the token pool pda.',
|
|
4197
|
+
},
|
|
4198
|
+
{ code: 6023, name: 'InvalidTokenPoolPda' },
|
|
4199
|
+
{ code: 6024, name: 'NoInputTokenAccountsProvided' },
|
|
4200
|
+
{ code: 6025, name: 'NoInputsProvided' },
|
|
4201
|
+
{ code: 6026, name: 'MintHasNoFreezeAuthority' },
|
|
4202
|
+
{ code: 6027, name: 'MintWithInvalidExtension' },
|
|
4203
|
+
{
|
|
4204
|
+
code: 6028,
|
|
4205
|
+
name: 'InsufficientTokenAccountBalance',
|
|
4206
|
+
msg: 'The token account balance is less than the remaining amount.',
|
|
4207
|
+
},
|
|
4208
|
+
{
|
|
4209
|
+
code: 6029,
|
|
4210
|
+
name: 'InvalidTokenPoolBump',
|
|
4211
|
+
msg: 'Max number of token pools reached.',
|
|
4212
|
+
},
|
|
4213
|
+
{ code: 6030, name: 'FailedToDecompress' },
|
|
4214
|
+
{ code: 6031, name: 'FailedToBurnSplTokensFromTokenPool' },
|
|
4215
|
+
{ code: 6032, name: 'NoMatchingBumpFound' },
|
|
4216
|
+
],
|
|
4217
|
+
}),
|
|
4218
|
+
(exports.MINT_TO_DISCRIMINATOR = m),
|
|
4219
|
+
(exports.POOL_SEED = s),
|
|
4220
|
+
(exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600),
|
|
4221
|
+
(exports.TRANSFER_DISCRIMINATOR = h),
|
|
4222
|
+
(exports.approveAndMintTo = async function (n, r, o, s, a, u, m, h, l) {
|
|
4223
|
+
l = l || (await N.get_mint_program_id(o, n));
|
|
4224
|
+
const d = await i.getOrCreateAssociatedTokenAccount(
|
|
4225
|
+
n,
|
|
4226
|
+
r,
|
|
4227
|
+
o,
|
|
4228
|
+
a.publicKey,
|
|
4229
|
+
void 0,
|
|
4230
|
+
void 0,
|
|
4231
|
+
h,
|
|
4232
|
+
l,
|
|
4233
|
+
);
|
|
4234
|
+
if (!m) {
|
|
4235
|
+
const e = await n.getCachedActiveStateTreeInfo(),
|
|
4236
|
+
{ tree: i } = t.pickRandomTreeAndQueue(e);
|
|
4237
|
+
m = i;
|
|
4238
|
+
}
|
|
4239
|
+
const c = await N.approveAndMintTo({
|
|
4240
|
+
feePayer: r.publicKey,
|
|
4241
|
+
mint: o,
|
|
4242
|
+
authority: a.publicKey,
|
|
4243
|
+
authorityTokenAccount: d.address,
|
|
4244
|
+
amount: u,
|
|
4245
|
+
toPubkey: s,
|
|
4246
|
+
merkleTree: m,
|
|
4247
|
+
tokenProgramId: l,
|
|
4248
|
+
}),
|
|
4249
|
+
{ blockhash: p } = await n.getLatestBlockhash(),
|
|
4250
|
+
g = t.dedupeSigner(r, [a]),
|
|
4251
|
+
f = t.buildAndSignTx(
|
|
4252
|
+
[
|
|
4253
|
+
e.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }),
|
|
4254
|
+
...c,
|
|
4255
|
+
],
|
|
4256
|
+
r,
|
|
4257
|
+
p,
|
|
4258
|
+
g,
|
|
4259
|
+
);
|
|
4260
|
+
return await t.sendAndConfirmTx(n, f, h);
|
|
4261
|
+
}),
|
|
4262
|
+
(exports.compress = async function (i, n, r, o, s, a, u, m, h, l) {
|
|
4263
|
+
if (((l = l || (await N.get_mint_program_id(r, i))), !m)) {
|
|
4264
|
+
const e = await i.getCachedActiveStateTreeInfo(),
|
|
4265
|
+
{ tree: n } = t.pickRandomTreeAndQueue(e);
|
|
4266
|
+
m = n;
|
|
4267
|
+
}
|
|
4268
|
+
const d = await N.compress({
|
|
4269
|
+
payer: n.publicKey,
|
|
4270
|
+
owner: s.publicKey,
|
|
4271
|
+
source: a,
|
|
4272
|
+
toAddress: u,
|
|
4273
|
+
amount: o,
|
|
4274
|
+
mint: r,
|
|
4275
|
+
outputStateTree: m,
|
|
4276
|
+
tokenProgramId: l,
|
|
4277
|
+
}),
|
|
4278
|
+
c = await i.getLatestBlockhash(),
|
|
4279
|
+
p = t.dedupeSigner(n, [s]),
|
|
4280
|
+
g = t.buildAndSignTx(
|
|
4281
|
+
[e.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }), d],
|
|
4282
|
+
n,
|
|
4283
|
+
c.blockhash,
|
|
4284
|
+
p,
|
|
4285
|
+
);
|
|
4286
|
+
return await t.sendAndConfirmTx(i, g, h, c);
|
|
4287
|
+
}),
|
|
4288
|
+
(exports.compressSplTokenAccount = async function (
|
|
4289
|
+
i,
|
|
4290
|
+
n,
|
|
4291
|
+
r,
|
|
4292
|
+
o,
|
|
4293
|
+
s,
|
|
4294
|
+
a,
|
|
4295
|
+
u,
|
|
4296
|
+
m,
|
|
4297
|
+
h,
|
|
4298
|
+
) {
|
|
4299
|
+
h = h || (await N.get_mint_program_id(r, i));
|
|
4300
|
+
const l = await N.compressSplTokenAccount({
|
|
4301
|
+
feePayer: n.publicKey,
|
|
4302
|
+
authority: o.publicKey,
|
|
4303
|
+
tokenAccount: s,
|
|
4304
|
+
mint: r,
|
|
4305
|
+
remainingAmount: u,
|
|
4306
|
+
outputStateTree: a,
|
|
4307
|
+
tokenProgramId: h,
|
|
4308
|
+
}),
|
|
4309
|
+
d = await i.getLatestBlockhash(),
|
|
4310
|
+
c = t.dedupeSigner(n, [o]),
|
|
4311
|
+
p = t.buildAndSignTx(
|
|
4312
|
+
[e.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }), l],
|
|
4313
|
+
n,
|
|
4314
|
+
d.blockhash,
|
|
4315
|
+
c,
|
|
4316
|
+
);
|
|
4317
|
+
return await t.sendAndConfirmTx(i, p, m, d);
|
|
4318
|
+
}),
|
|
4319
|
+
(exports.compressSplTokenAccountInstructionDataLayout = T),
|
|
4320
|
+
(exports.createDecompressOutputState = R),
|
|
4321
|
+
(exports.createMint = async function (
|
|
4322
|
+
n,
|
|
4323
|
+
r,
|
|
4324
|
+
o,
|
|
4325
|
+
s,
|
|
4326
|
+
a = e.Keypair.generate(),
|
|
4327
|
+
u,
|
|
4328
|
+
m,
|
|
4329
|
+
h,
|
|
4330
|
+
) {
|
|
4331
|
+
const l = await n.getMinimumBalanceForRentExemption(i.MINT_SIZE),
|
|
4332
|
+
d = 1 == m ? i.TOKEN_2022_PROGRAM_ID : m || i.TOKEN_PROGRAM_ID,
|
|
4333
|
+
c = await N.createMint({
|
|
4334
|
+
feePayer: r.publicKey,
|
|
4335
|
+
mint: a.publicKey,
|
|
4336
|
+
decimals: s,
|
|
4337
|
+
authority: o,
|
|
4338
|
+
freezeAuthority: h || null,
|
|
4339
|
+
rentExemptBalance: l,
|
|
4340
|
+
tokenProgramId: d,
|
|
4341
|
+
}),
|
|
4342
|
+
{ blockhash: p } = await n.getLatestBlockhash(),
|
|
4343
|
+
g = t.dedupeSigner(r, [a]),
|
|
4344
|
+
f = t.buildAndSignTx(c, r, p, g),
|
|
4345
|
+
y = await t.sendAndConfirmTx(n, f, u);
|
|
4346
|
+
return { mint: a.publicKey, transactionSignature: y };
|
|
4347
|
+
}),
|
|
4348
|
+
(exports.createTokenPool = async function (e, i, n, r, o) {
|
|
4349
|
+
o = o || (await N.get_mint_program_id(n, e));
|
|
4350
|
+
const s = await N.createTokenPool({
|
|
4351
|
+
feePayer: i.publicKey,
|
|
4352
|
+
mint: n,
|
|
4353
|
+
tokenProgramId: o,
|
|
4354
|
+
}),
|
|
4355
|
+
{ blockhash: a } = await e.getLatestBlockhash(),
|
|
4356
|
+
u = t.buildAndSignTx([s], i, a);
|
|
4357
|
+
return await t.sendAndConfirmTx(e, u, r);
|
|
4358
|
+
}),
|
|
4359
|
+
(exports.createTokenPoolAccountsLayout = _),
|
|
4360
|
+
(exports.createTokenProgramLookupTable = async function (e, i, n, r, o) {
|
|
4361
|
+
const s = await e.getSlot('finalized'),
|
|
4362
|
+
{ instructions: a, address: u } =
|
|
4363
|
+
await N.createTokenProgramLookupTable({
|
|
4364
|
+
payer: i.publicKey,
|
|
4365
|
+
authority: n.publicKey,
|
|
4366
|
+
mints: r,
|
|
4367
|
+
remainingAccounts: o,
|
|
4368
|
+
recentSlot: s,
|
|
4369
|
+
}),
|
|
4370
|
+
m = t.dedupeSigner(i, [n]),
|
|
4371
|
+
h = await e.getLatestBlockhash(),
|
|
4372
|
+
l = t.buildAndSignTx([a[0]], i, h.blockhash, m),
|
|
4373
|
+
d = await t.sendAndConfirmTx(e, l, { commitment: 'finalized' }, h),
|
|
4374
|
+
c = await e.getLatestBlockhash(),
|
|
4375
|
+
p = t.buildAndSignTx([a[1]], i, c.blockhash, m);
|
|
4376
|
+
return {
|
|
4377
|
+
txIds: [
|
|
4378
|
+
d,
|
|
4379
|
+
await t.sendAndConfirmTx(e, p, { commitment: 'finalized' }, c),
|
|
4380
|
+
],
|
|
4381
|
+
address: u,
|
|
4382
|
+
};
|
|
4383
|
+
}),
|
|
4384
|
+
(exports.createTransferOutputState = L),
|
|
4385
|
+
(exports.decodeCompressSplTokenAccountInstructionData = function (t) {
|
|
4386
|
+
const e = T.decode(t.slice(l.length));
|
|
4387
|
+
return {
|
|
4388
|
+
owner: e.owner,
|
|
4389
|
+
remainingAmount: e.remainingAmount,
|
|
4390
|
+
cpiContext: e.cpiContext,
|
|
4391
|
+
};
|
|
4392
|
+
}),
|
|
4393
|
+
(exports.decodeMintToInstructionData = function (t) {
|
|
4394
|
+
const e = A.decode(t.slice(m.length));
|
|
4395
|
+
return {
|
|
4396
|
+
recipients: e.recipients,
|
|
4397
|
+
amounts: e.amounts,
|
|
4398
|
+
lamports: e.lamports,
|
|
4399
|
+
};
|
|
4400
|
+
}),
|
|
4401
|
+
(exports.decodeTransferInstructionData = function (t) {
|
|
4402
|
+
return S.decode(t.slice(h.length + 4));
|
|
4403
|
+
}),
|
|
4404
|
+
(exports.decompress = async function (i, n, r, o, s, a, u, m, h) {
|
|
4405
|
+
(h = h || (await N.get_mint_program_id(r, i))), (o = t.bn(o));
|
|
4406
|
+
const l = await i.getCompressedTokenAccountsByOwner(s.publicKey, {
|
|
4407
|
+
mint: r,
|
|
4408
|
+
}),
|
|
4409
|
+
[d] = W(l.items, o),
|
|
4410
|
+
c = await i.getValidityProof(
|
|
4411
|
+
d.map(e => t.bn(e.compressedAccount.hash)),
|
|
4412
|
+
),
|
|
4413
|
+
p = await N.decompress({
|
|
4414
|
+
payer: n.publicKey,
|
|
4415
|
+
inputCompressedTokenAccounts: d,
|
|
4416
|
+
toAddress: a,
|
|
4417
|
+
amount: o,
|
|
4418
|
+
outputStateTree: u,
|
|
4419
|
+
recentInputStateRootIndices: c.rootIndices,
|
|
4420
|
+
recentValidityProof: c.compressedProof,
|
|
4421
|
+
tokenProgramId: h,
|
|
4422
|
+
}),
|
|
4423
|
+
{ blockhash: g } = await i.getLatestBlockhash(),
|
|
4424
|
+
f = t.dedupeSigner(n, [s]),
|
|
4425
|
+
y = t.buildAndSignTx(
|
|
4426
|
+
[e.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }), p],
|
|
4427
|
+
n,
|
|
4428
|
+
g,
|
|
4429
|
+
f,
|
|
4430
|
+
);
|
|
4431
|
+
return await t.sendAndConfirmTx(i, y, m);
|
|
4432
|
+
}),
|
|
4433
|
+
(exports.encodeCompressSplTokenAccountInstructionData = I),
|
|
4434
|
+
(exports.encodeMintToInstructionData = C),
|
|
4435
|
+
(exports.encodeTransferInstructionData = x),
|
|
4436
|
+
(exports.mergeTokenAccounts = async function (i, n, r, o, s, a) {
|
|
4437
|
+
const u = await i.getCompressedTokenAccountsByOwner(o.publicKey, {
|
|
4438
|
+
mint: r,
|
|
4439
|
+
});
|
|
4440
|
+
if (0 === u.items.length)
|
|
4441
|
+
throw new Error(
|
|
4442
|
+
`No compressed token accounts found for mint ${r.toBase58()}`,
|
|
4443
|
+
);
|
|
4444
|
+
if (u.items.length >= 6)
|
|
4445
|
+
throw new Error(
|
|
4446
|
+
`Too many compressed token accounts used for mint ${r.toBase58()}`,
|
|
4447
|
+
);
|
|
4448
|
+
const m = [e.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 })];
|
|
4449
|
+
for (let e = 0; e < u.items.slice(0, 6).length; e += 3) {
|
|
4450
|
+
const a = u.items.slice(e, e + 3),
|
|
4451
|
+
h = await i.getValidityProof(
|
|
4452
|
+
a.map(e => t.bn(e.compressedAccount.hash)),
|
|
4453
|
+
),
|
|
4454
|
+
l = await N.mergeTokenAccounts({
|
|
4455
|
+
payer: n.publicKey,
|
|
4456
|
+
owner: o.publicKey,
|
|
4457
|
+
mint: r,
|
|
4458
|
+
inputCompressedTokenAccounts: a,
|
|
4459
|
+
outputStateTree: s,
|
|
4460
|
+
recentValidityProof: h.compressedProof,
|
|
4461
|
+
recentInputStateRootIndices: h.rootIndices,
|
|
4462
|
+
});
|
|
4463
|
+
m.push(...l);
|
|
4464
|
+
}
|
|
4465
|
+
const { blockhash: h } = await i.getLatestBlockhash(),
|
|
4466
|
+
l = t.dedupeSigner(n, [o]),
|
|
4467
|
+
d = t.buildAndSignTx(m, n, h, l);
|
|
4468
|
+
return await t.sendAndConfirmTx(i, d, a);
|
|
4469
|
+
}),
|
|
4470
|
+
(exports.mintTo = async function (i, n, r, o, s, a, u, m, h) {
|
|
4471
|
+
h = h || (await N.get_mint_program_id(r, i));
|
|
4472
|
+
const l = t.dedupeSigner(n, [s]);
|
|
4473
|
+
if (!u) {
|
|
4474
|
+
const e = await i.getCachedActiveStateTreeInfo(),
|
|
4475
|
+
{ tree: n } = t.pickRandomTreeAndQueue(e);
|
|
4476
|
+
u = n;
|
|
4477
|
+
}
|
|
4478
|
+
const d = await N.mintTo({
|
|
4479
|
+
feePayer: n.publicKey,
|
|
4480
|
+
mint: r,
|
|
4481
|
+
authority: s.publicKey,
|
|
4482
|
+
amount: a,
|
|
4483
|
+
toPubkey: o,
|
|
4484
|
+
merkleTree: u,
|
|
4485
|
+
tokenProgramId: h,
|
|
4486
|
+
}),
|
|
4487
|
+
{ blockhash: c } = await i.getLatestBlockhash(),
|
|
4488
|
+
p = t.buildAndSignTx(
|
|
4489
|
+
[e.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }), d],
|
|
4490
|
+
n,
|
|
4491
|
+
c,
|
|
4492
|
+
l,
|
|
4493
|
+
);
|
|
4494
|
+
return await t.sendAndConfirmTx(i, p, m);
|
|
4495
|
+
}),
|
|
4496
|
+
(exports.mintToAccountsLayout = O),
|
|
4497
|
+
(exports.mintToLayout = A),
|
|
4498
|
+
(exports.packCompressedTokenAccounts = o),
|
|
4499
|
+
(exports.parseTokenData = K),
|
|
4500
|
+
(exports.selectMinCompressedTokenAccountsForTransfer = W),
|
|
4501
|
+
(exports.sumUpTokenAmount = E),
|
|
4502
|
+
(exports.transfer = async function (i, n, r, o, s, a, u, m) {
|
|
4503
|
+
o = t.bn(o);
|
|
4504
|
+
const h = await i.getCompressedTokenAccountsByOwner(s.publicKey, {
|
|
4505
|
+
mint: r,
|
|
4506
|
+
}),
|
|
4507
|
+
[l] = W(h.items, o),
|
|
4508
|
+
d = await i.getValidityProof(
|
|
4509
|
+
l.map(e => t.bn(e.compressedAccount.hash)),
|
|
4510
|
+
),
|
|
4511
|
+
c = await N.transfer({
|
|
4512
|
+
payer: n.publicKey,
|
|
4513
|
+
inputCompressedTokenAccounts: l,
|
|
4514
|
+
toAddress: a,
|
|
4515
|
+
amount: o,
|
|
4516
|
+
recentInputStateRootIndices: d.rootIndices,
|
|
4517
|
+
recentValidityProof: d.compressedProof,
|
|
4518
|
+
outputStateTrees: u,
|
|
4519
|
+
}),
|
|
4520
|
+
{ blockhash: p } = await i.getLatestBlockhash(),
|
|
4521
|
+
g = t.dedupeSigner(n, [s]),
|
|
4522
|
+
f = t.buildAndSignTx(
|
|
4523
|
+
[e.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }), c],
|
|
4524
|
+
n,
|
|
4525
|
+
p,
|
|
4526
|
+
g,
|
|
4527
|
+
);
|
|
4528
|
+
return await t.sendAndConfirmTx(i, f, m);
|
|
4529
|
+
}),
|
|
4530
|
+
(exports.transferAccountsLayout = D),
|
|
4531
|
+
(exports.validateSameTokenOwner = B);
|
|
2
4532
|
//# sourceMappingURL=index.cjs.map
|