test-raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 2.44 kB
JavaScript
var E=Object.create;var g=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var w=(r,e)=>{for(var o in e)g(r,o,{get:e[o],enumerable:!0})},a=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of I(e))!_.call(r,i)&&i!==o&&g(r,i,{get:()=>e[i],enumerable:!(t=y(e,i))||t.enumerable});return r};var l=(r,e,o)=>(o=r!=null?E(S(r)):{},a(e||!r||!r.__esModule?g(o,"default",{value:r,enumerable:!0}):o,r)),x=r=>a(g({},"__esModule",{value:!0}),r);var T={};w(T,{getSerumAssociatedAuthority:()=>R,getSerumVersion:()=>O});module.exports=x(T);var v=require("@solana/web3.js");var u=l(require("bn.js")),D=new u.default(25),M=new u.default(1e4),L={4:3,5:3};var n=require("lodash"),m=l(require("dayjs")),p=l(require("dayjs/plugin/utc"));m.default.extend(p.default);var c=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return(0,m.default)().utc().format("YYYY/MM/DD HH:mm:ss UTC")}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let o=e.map(t=>typeof t=="object"?JSON.stringify(t):t).join(", ");throw new Error(o)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},h={},N={};function d(r){let e=(0,n.get)(h,r);if(!e){let o=(0,n.get)(N,r);e=new c({name:r,logLevel:o}),(0,n.set)(h,r,e)}return e}var b=d("Raydium_liquidity_serum");function O(r){let e=L[r];return e||b.logWithError("invalid version","version",r),e}function R({programId:r,marketId:e}){let o=[e.toBuffer()],t=0,i;for(;t<100;){try{let s=o.concat(Buffer.from([t]),Buffer.alloc(7));i=v.PublicKey.createProgramAddressSync(s,r)}catch(s){if(s instanceof TypeError)throw s;t++;continue}return{publicKey:i,nonce:t}}throw b.logWithError("unable to find a viable program address nonce","params",{programId:r,marketId:e}),new Error("unable to find a viable program address nonce")}0&&(module.exports={getSerumAssociatedAuthority,getSerumVersion});
//# sourceMappingURL=serum.js.map