@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 6.39 kB
JavaScript
var j=Object.create;var d=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols,O=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var D=(n,r,t)=>r in n?d(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,_=(n,r)=>{for(var t in r||(r={}))I.call(r,t)&&D(n,t,r[t]);if(C)for(var t of C(r))H.call(r,t)&&D(n,t,r[t]);return n};var J=(n,r)=>{for(var t in r)d(n,t,{get:r[t],enumerable:!0})},N=(n,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of M(r))!I.call(n,s)&&s!==t&&d(n,s,{get:()=>r[s],enumerable:!(o=z(r,s))||o.enumerable});return n};var Q=(n,r,t)=>(t=n!=null?j(O(n)):{},N(r||!n||!n.__esModule?d(t,"default",{value:n,enumerable:!0}):t,n)),X=n=>N(d({},"__esModule",{value:!0}),n);var He={};J(He,{BNLayout:()=>i,BitStructure:()=>Z,Blob:()=>w,Layout:()=>p,OptionLayout:()=>h,Structure:()=>T,UInt:()=>m,Union:()=>S,WideBits:()=>B,WrappedLayout:()=>a,array:()=>ze,bits:()=>g,blob:()=>f,bool:()=>qe,cstr:()=>ke,decodeBool:()=>R,encodeBool:()=>F,f32:()=>Se,f32be:()=>_e,f64:()=>we,f64be:()=>Be,greedy:()=>$,i128:()=>Ve,i64:()=>Ae,i8:()=>Ee,ns64:()=>be,ns64be:()=>Te,nu64:()=>re,nu64be:()=>ye,offset:()=>L,option:()=>Ke,publicKey:()=>ve,rustEnum:()=>je,s16:()=>pe,s16be:()=>me,s24:()=>Pe,s24be:()=>le,s32:()=>de,s32be:()=>ge,s40:()=>xe,s40be:()=>Le,s48:()=>fe,s48be:()=>he,s8:()=>ce,seq:()=>k,str:()=>Ge,struct:()=>b,tagged:()=>Fe,u128:()=>Ne,u16:()=>W,u16be:()=>oe,u24:()=>ee,u24be:()=>se,u32:()=>Ie,u32be:()=>ue,u40:()=>te,u40be:()=>ae,u48:()=>ne,u48be:()=>ie,u64:()=>q,u8:()=>De,union:()=>Me,unionLayoutDiscriminator:()=>Ue,utf8:()=>Ce,vec:()=>Re,vecU8:()=>G,zeros:()=>Oe});module.exports=X(He);var K=require("@solana/web3.js"),P=Q(require("bn.js"));var e=require("@solana/buffer-layout"),p=e.Layout,E=e.Structure,A=e.Union,Z=e.BitStructure,m=e.UInt,w=e.Blob,$=e.greedy,l=e.u8,W=e.u16,ee=e.u24,x=e.u32,te=e.u40,ne=e.u48,re=e.nu64,oe=e.u16be,se=e.u24be,ue=e.u32be,ae=e.u40be,ie=e.u48be,ye=e.nu64be,ce=e.s8,pe=e.s16,Pe=e.s24,de=e.s32,xe=e.s40,fe=e.s48,be=e.ns64,me=e.s16be,le=e.s24be,ge=e.s32be,Le=e.s40be,he=e.s48be,Te=e.ns64be,Se=e.f32,_e=e.f32be,we=e.f64,Be=e.f64be;var V=e.seq,v=e.union,Ue=e.unionLayoutDiscriminator,f=e.blob,ke=e.cstr,Ce=e.utf8,g=e.bits,L=e.offset;var i=class extends p{constructor(t,o,s){super(t,s);this.blob=f(t),this.signed=o}decode(t,o=0){let s=new P.default(this.blob.decode(t,o),10,"le");return this.signed?s.fromTwos(this.span*8).clone():s}encode(t,o,s=0){return typeof t=="number"&&(t=new P.default(t)),this.signed&&(t=t.toTwos(this.span*8)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),o,s)}},B=class extends p{constructor(t){super(8,t);this._lower=g(x(),!1),this._upper=g(x(),!1)}addBoolean(t){this._lower.fields.length<32?this._lower.addBoolean(t):this._upper.addBoolean(t)}decode(t,o=0){let s=this._lower.decode(t,o),u=this._upper.decode(t,o+this._lower.span);return _(_({},s),u)}encode(t,o,s=0){return this._lower.encode(t,o,s)+this._upper.encode(t,o,s+this._lower.span)}};function De(n){return new m(1,n)}function Ie(n){return new m(4,n)}function q(n){return new i(8,!1,n)}function Ne(n){return new i(16,!1,n)}function Ee(n){return new i(1,!0,n)}function Ae(n){return new i(8,!0,n)}function Ve(n){return new i(16,!0,n)}var a=class extends p{constructor(t,o,s,u){super(t.span,u);this.layout=t,this.decoder=o,this.encoder=s}decode(t,o){return this.decoder(this.layout.decode(t,o))}encode(t,o,s){return this.layout.encode(this.encoder(t),o,s)}getSpan(t,o){return this.layout.getSpan(t,o)}};function ve(n){return new a(f(32),r=>new K.PublicKey(r),r=>r.toBuffer(),n)}var h=class extends p{constructor(t,o){super(-1,o);this.layout=t,this.discriminator=l()}encode(t,o,s=0){return t==null?this.discriminator.encode(0,o,s):(this.discriminator.encode(1,o,s),this.layout.encode(t,o,s+1)+1)}decode(t,o=0){let s=this.discriminator.decode(t,o);if(s===0)return null;if(s===1)return this.layout.decode(t,o+1);throw new Error("Invalid option "+this.property)}getSpan(t,o=0){let s=this.discriminator.decode(t,o);if(s===0)return 1;if(s===1)return this.layout.getSpan(t,o+1)+1;throw new Error("Invalid option "+this.property)}};function Ke(n,r){return new h(n,r)}function qe(n){return new a(l(),R,F,n)}function R(n){if(n===0)return!1;if(n===1)return!0;throw new Error("Invalid bool: "+n)}function F(n){return n?1:0}function Re(n,r){let t=x("length"),o=b([t,k(n,L(t,-t.span),"values")]);return new a(o,({values:s})=>s,s=>({values:s}),r)}function Fe(n,r,t){let o=b([q("tag"),r.replicate("data")]);function s({tag:u,data:y}){if(!u.eq(n))throw new Error("Invalid tag, expected: "+n.toString("hex")+", got: "+u.toString("hex"));return y}return new a(o,s,u=>({tag:n,data:u}),t)}function G(n){let r=x("length"),t=b([r,f(L(r,-r.span),"data")]);return new a(t,({data:o})=>o,o=>({data:o}),n)}function Ge(n){return new a(G(),r=>r.toString("utf-8"),r=>Buffer.from(r,"utf-8"),n)}function je(n,r){let t=v(l(),r);return n.forEach((o,s)=>t.addVariant(s,o,o.property)),t}function ze(n,r,t){let o=b([k(n,r,"values")]);return new a(o,({values:s})=>s,s=>({values:s}),t)}var T=class extends E{decode(r,t){return super.decode(r,t)}};function b(n,r,t){return new T(n,r,t)}var S=class extends A{encodeInstruction(r){let t=Math.max(...Object.values(this.registry).map(s=>s.span)),o=Buffer.alloc(t);return o.slice(0,this.encode(r,o))}decodeInstruction(r){return this.decode(r)}};function Me(n,r,t){return new S(n,r,t)}var U=class extends w{decode(r,t){let o=super.decode(r,t);if(!o.every(s=>s===0))throw new Error("nonzero padding bytes");return o}};function Oe(n){return new U(n)}function k(n,r,t){let o,s=typeof r=="number"?r:(0,P.isBN)(r)?r.toNumber():new Proxy(r,{get(u,y){if(!o){let c=Reflect.get(u,"count");o=(0,P.isBN)(c)?c.toNumber():c,Reflect.set(u,"count",o)}return Reflect.get(u,y)},set(u,y,c){return y==="count"&&(o=c),Reflect.set(u,y,c)}});return V(n,s,t)}0&&(module.exports={BNLayout,BitStructure,Blob,Layout,OptionLayout,Structure,UInt,Union,WideBits,WrappedLayout,array,bits,blob,bool,cstr,decodeBool,encodeBool,f32,f32be,f64,f64be,greedy,i128,i64,i8,ns64,ns64be,nu64,nu64be,offset,option,publicKey,rustEnum,s16,s16be,s24,s24be,s32,s32be,s40,s40be,s48,s48be,s8,seq,str,struct,tagged,u128,u16,u16be,u24,u24be,u32,u32be,u40,u40be,u48,u48be,u64,u8,union,unionLayoutDiscriminator,utf8,vec,vecU8,zeros});
//# sourceMappingURL=index.js.map