test-raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 1.74 kB
JavaScript
import{PublicKey as b}from"@solana/web3.js";import u from"bn.js";var y=new u(25),I=new u(1e4),c={4:3,5:3};import{get as m,set as p}from"lodash";import f from"dayjs";import d from"dayjs/plugin/utc";f.extend(d);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 f().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 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}},a={},v={};function L(r){let e=m(a,r);if(!e){let t=m(v,r);e=new n({name:r,logLevel:t}),p(a,r,e)}return e}var h=L("Raydium_liquidity_serum");function V(r){let e=c[r];return e||h.logWithError("invalid version","version",r),e}function D({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=b.createProgramAddressSync(i,r)}catch(i){if(i instanceof TypeError)throw i;o++;continue}return{publicKey:s,nonce:o}}throw h.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{D as getSerumAssociatedAuthority,V as getSerumVersion};
//# sourceMappingURL=serum.mjs.map