@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 1.65 kB
JavaScript
import{PublicKey as v}from"@solana/web3.js";import u from"bn.js";var b=new u(25),E=new u(1e4),c={4:3,5:3};import{get as m,set as h}from"lodash";var n=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 Date.now().toString()}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 t=e.map(o=>typeof o=="object"?JSON.stringify(o):o).join(", ");throw new Error(t)}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}},L={},p={};function a(r){let e=m(L,r);if(!e){let t=m(p,r);e=new n({name:r,logLevel:t}),h(L,r,e)}return e}var f=a("Raydium_liquidity_serum");function N(r){let e=c[r];return e||f.logWithError("invalid version","version",r),e}function O({programId:r,marketId:e}){let t=[e.toBuffer()],o=0,s;for(;o<100;){try{let i=t.concat(Buffer.from([o]),Buffer.alloc(7));s=v.createProgramAddressSync(i,r)}catch(i){if(i instanceof TypeError)throw i;o++;continue}return{publicKey:s,nonce:o}}throw f.logWithError("unable to find a viable program address nonce","params",{programId:r,marketId:e}),new Error("unable to find a viable program address nonce")}export{O as getSerumAssociatedAuthority,N as getSerumVersion};
//# sourceMappingURL=serum.mjs.map