PageSourceSearch

https://referware.vercel.app/_next/static/chunks/3a91511d-80502ddd78ef0f54.js

js referware.vercel.app collected 2026-10-03 07:35:54 UTC 110,337 bytes, 8 lines download raw bytes

vendor: 38,931 bytes, lines 1-8
1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3814],{45429:function(e,t,r){r.d(t,{ew:function(){return t3},go:function(){return rg},j5:function(){return rp},nh:function(){return C}});var i,n,s=r(9109),a=r(2552),o=r(58171),c=r.n(o),l=r(46124),u=r.n(l),d=r(65530),h=r(5810),g=r(24459),p=r(12653),b=r(66517),m=r(53733),y=r.n(m),f=r(13900),k=r(67331),w=r(35743),S=r(68347);a.UN.utils.randomPrivateKey;let _=()=>{let e=a.UN.utils.randomPrivateKey(),t=I(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),{publicKey:t,secretKey:r}},I=a.UN.getPublicKey;function A(e){try{return a.UN.ExtendedPoint.fromHex(e),!0}catch{return!1}}let v=(e,t)=>a.UN.sign(e,t.slice(0,32)),B=a.UN.verify,x=e=>s.Buffer.isBuffer(e)?e:e instanceof Uint8Array?s.Buffer.from(e.buffer,e.byteOffset,e.byteLength):s.Buffer.from(e);class P{constructor(e){Object.assign(this,e)}encode(){return s.Buffer.from((0,h.serialize)(E,this))}static decode(e){return(0,h.deserialize)(E,this,e)}static decodeUnchecked(e){return(0,h.deserializeUnchecked)(E,this,e)}}let E=new Map,T=1;class C extends P{constructor(e){if(super({}),this._bn=void 0,void 0!==e._bn)this._bn=e._bn;else{if("string"==typeof e){let t=u().decode(e);if(32!=t.length)throw Error("Invalid public key input");this._bn=new(c())(t)}else this._bn=new(c())(e);if(this._bn.byteLength()>32)throw Error("Invalid public key input")}}static unique(){let e=new C(T);return T+=1,new C(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return u().encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(s.Buffer);if(32===e.length)return e;let t=s.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){let i=s.Buffer.concat([e.toBuffer(),s.Buffer.from(t),r.toBuffer()]);return new C((0,d.J)(i))}static createProgramAddressSync(e,t){let r=s.Buffer.alloc(0);e.forEach(function(e){if(e.length>32)throw TypeError("Max seed length exceeded");r=s.Buffer.concat([r,x(e)])}),r=s.Buffer.concat([r,t.toBuffer(),s.Buffer.from("ProgramDerivedAddress")]);let i=(0,d.J)(r);if(A(i))throw Error("Invalid seeds, address must fall off the curve");return new C(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r,i=255;for(;0!=i;){try{let n=e.concat(s.Buffer.from([i]));r=this.createProgramAddressSync(n,t)}catch(e){if(e instanceof TypeError)throw e;i--;continue}return[r,i]}throw Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){return A(new C(e).toBytes())}}C.default=new C("11111111111111111111111111111111"),E.set(C,{kind:"struct",fields:[["_bn","u256"]]}),new C("BPFLoader1111111111111111111111111111111111");class W extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(W.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class q extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(q.prototype,"name",{value:"TransactionExpiredTimeoutError"});class L extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(L.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class R{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error("Account index overflow encountered during compilation");let t=new Map;this.keySegments().flat().forEach((e,r)=>{t.set(e.toBase58(),r)});let r=e=>{let r=t.get(e.toBase58());if(void 0===r)throw Error("Encountered an unknown instruction account key during compilation");return r};return e.map(e=>({programIdIndex:r(e.programId),accountKeyIndexes:e.keys.map(e=>r(e.pubkey)),data:e.data}))}}let z=(e="publicKey")=>g.Ik(32,e),O=(e="string")=>{let t=g.n_([g.Jq("length"),g.Jq("lengthPadding"),g.Ik(g.cv(g.Jq(),-8),"chars")],e),r=t.decode.bind(t),i=t.encode.bind(t);return t.decode=(e,t)=>r(e,t).chars.toString(),t.encode=(e,t,r)=>i({chars:s.Buffer.from(e,"utf8")},t,r),t.alloc=e=>g.Jq().span+g.Jq().span+s.Buffer.from(e,"utf8").length,t};function K(e){let t=0,r=0;for(;;){let i=e.shift();if(t|=(127&i)<<7*r,r+=1,(128&i)==0)break}return t}function N(e,t){let r=t;for(;;){let t=127&r;if(0==(r>>=7)){e.push(t);break}t|=128,e.push(t)}}function M(e,t){if(!e)throw Error(t||"Assertion failed")}class J{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){let r=new Map,i=e=>{let t=e.toBase58(),i=r.get(t);return void 0===i&&(i={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,i)),i},n=i(t);for(let t of(n.isSigner=!0,n.isWritable=!0,e))for(let e of(i(t.programId).isInvoked=!0,t.keys)){let t=i(e.pubkey);t.isSigner||=e.isSigner,t.isWritable||=e.isWritable}return new J(t,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];M(e.length<=256,"Max static account keys length exceeded");let t=e.filter(([,e])=>e.isSigner&&e.isWritable),r=e.filter(([,e])=>e.isSigner&&!e.isWritable),i=e.filter(([,e])=>!e.isSigner&&e.isWritable),n=e.filter(([,e])=>!e.isSigner&&!e.isWritable),s={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:n.length};{M(t.length>0,"Expected at least one writable signer key");let[e]=t[0];M(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[s,[...t.map(([e])=>new C(e)),...r.map(([e])=>new C(e)),...i.map(([e])=>new C(e)),...n.map(([e])=>new C(e))]]}extractTableLookup(e){let[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[i,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(0!==t.length||0!==i.length)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:i},{writable:r,readonly:n}]}drainKeysFoundInLookupTable(e,t){let r=[],i=[];for(let[n,s]of this.keyMetaMap.entries())if(t(s)){let t=new C(n),s=e.findIndex(e=>e.equals(t));s>=0&&(M(s<256,"Max lookup table index exceeded"),r.push(s),i.push(t),this.keyMetaMap.delete(n))}return[r,i]}}let U="Reached end of buffer unexpectedly";function $(e){if(0===e.length)throw Error(U);return e.shift()}function H(e,...t){let[r]=t;if(2===t.length?r+(t[1]??0)>e.length:r>=e.length)throw Error(U);return e.splice(...t)}class F{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new C(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:u().decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new R(this.staticAccountKeys)}static compile(e){let[t,r]=J.compile(e.instructions,e.payerKey).getMessageComponents(),i=new R(r).compileInstructions(e.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:u().encode(e.data)}));return new F({header:t,accountKeys:r,recentBlockhash:e.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;if(!(e>=this.header.numRequiredSignatures))return e<t-this.header.numReadonlySignedAccounts;{let r=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return e-t<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];N(t,e);let r=this.instructions.map(e=>{let{accounts:t,programIdIndex:r}=e,i=Array.from(u().decode(e.data)),n=[];N(n,t.length);let a=[];return N(a,i.length),{programIdIndex:r,keyIndicesCount:s.Buffer.from(n),keyIndices:t,dataLength:s.Buffer.from(a),data:i}}),i=[];N(i,r.length);let n=s.Buffer.alloc(1232);s.Buffer.from(i).copy(n);let a=i.length;r.forEach(e=>{let t=g.n_([g.u8("programIdIndex"),g.Ik(e.keyIndicesCount.length,"keyIndicesCount"),g.A9(g.u8("keyIndex"),e.keyIndices.length,"keyIndices"),g.Ik(e.dataLength.length,"dataLength"),g.A9(g.u8("userdatum"),e.data.length,"data")]).encode(e,n,a);a+=t}),n=n.slice(0,a);let o=g.n_([g.Ik(1,"numRequiredSignatures"),g.Ik(1,"numReadonlySignedAccounts"),g.Ik(1,"numReadonlyUnsignedAccounts"),g.Ik(t.length,"keyCount"),g.A9(z("key"),e,"keys"),z("recentBlockhash")]),c={numRequiredSignatures:s.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:s.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:s.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:s.Buffer.from(t),keys:this.accountKeys.map(e=>x(e.toBytes())),recentBlockhash:u().decode(this.recentBlockhash)},l=s.Buffer.alloc(2048),d=o.encode(c,l);return n.copy(l,d),l.slice(0,d+n.length)}static from(e){let t=[...e],r=$(t);if(r!==(127&r))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let i=$(t),n=$(t),a=K(t),o=[];for(let e=0;e<a;e++){let e=H(t,0,32);o.push(new C(s.Buffer.from(e)))}let c=H(t,0,32),l=K(t),d=[];for(let e=0;e<l;e++){let e=$(t),r=K(t),i=H(t,0,r),n=K(t),a=H(t,0,n),o=u().encode(s.Buffer.from(a));d.push({programIdIndex:e,accounts:i,data:o})}return new F({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:n},recentBlockhash:u().encode(s.Buffer.from(c)),accountKeys:o,instructions:d})}}class D{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error("Failed to get account keys because address table lookups were not resolved");return new R(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r)return e-r<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0);if(!(e>=this.header.numRequiredSignatures))return e<t-this.header.numReadonlySignedAccounts;{let i=r-t-this.header.numReadonlyUnsignedAccounts;return e-t<i}}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let r of this.addressTableLookups){let i=e.find(e=>e.key.equals(r.accountKey));if(!i)throw Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(let e of r.writableIndexes)if(e<i.state.addresses.length)t.writable.push(i.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${r.accountKey.toBase58()}`);for(let e of r.readonlyIndexes)if(e<i.state.addresses.length)t.readonly.push(i.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${r.accountKey.toBase58()}`)}return t}static compile(e){let t=J.compile(e.instructions,e.payerKey),r=[],i={writable:[],readonly:[]};for(let n of e.addressLookupTableAccounts||[]){let e=t.extractTableLookup(n);if(void 0!==e){let[t,{writable:n,readonly:s}]=e;r.push(t),i.writable.push(...n),i.readonly.push(...s)}}let[n,s]=t.getMessageComponents(),a=new R(s,i).compileInstructions(e.instructions);return new D({header:n,staticAccountKeys:s,recentBlockhash:e.recentBlockhash,compiledInstructions:a,addressTableLookups:r})}serialize(){let e=[];N(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),r=[];N(r,this.compiledInstructions.length);let i=this.serializeAddressTableLookups(),n=[];N(n,this.addressTableLookups.length);let s=g.n_([g.u8("prefix"),g.n_([g.u8("numRequiredSignatures"),g.u8("numReadonlySignedAccounts"),g.u8("numReadonlyUnsignedAccounts")],"header"),g.Ik(e.length,"staticAccountKeysLength"),g.A9(z(),this.staticAccountKeys.length,"staticAccountKeys"),z("recentBlockhash"),g.Ik(r.length,"instructionsLength"),g.Ik(t.length,"serializedInstructions"),g.Ik(n.length,"addressTableLookupsLength"),g.Ik(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(1232),o=s.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:u().decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(n),serializedAddressTableLookups:i},a);return a.slice(0,o)}serializeInstructions(){let e=0,t=new Uint8Array(1232);for(let r of this.compiledInstructions){let i=[];N(i,r.accountKeyIndexes.length);let n=[];N(n,r.data.length);let s=g.n_([g.u8("programIdIndex"),g.Ik(i.length,"encodedAccountKeyIndexesLength"),g.A9(g.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),g.Ik(n.length,"encodedDataLength"),g.Ik(r.data.length,"data")]);e+=s.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(n),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(1232);for(let r of this.addressTableLookups){let i=[];N(i,r.writableIndexes.length);let n=[];N(n,r.readonlyIndexes.length);let s=g.n_([z("accountKey"),g.Ik(i.length,"encodedWritableIndexesLength"),g.A9(g.u8(),r.writableIndexes.length,"writableIndexes"),g.Ik(n.length,"encodedReadonlyIndexesLength"),g.A9(g.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=s.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(n),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],r=$(t),i=127&r;M(r!==i,"Expected versioned message but received legacy message"),M(0===i,`Expected versioned message with version 0 but found version ${i}`);let n={numRequiredSignatures:$(t),numReadonlySignedAccounts:$(t),numReadonlyUnsignedAccounts:$(t)},s=[],a=K(t);for(let e=0;e<a;e++)s.push(new C(H(t,0,32)));let o=u().encode(H(t,0,32)),c=K(t),l=[];for(let e=0;e<c;e++){let e=$(t),r=K(t),i=H(t,0,r),n=K(t),s=new Uint8Array(H(t,0,n));l.push({programIdIndex:e,accountKeyIndexes:i,data:s})}let d=K(t),h=[];for(let e=0;e<d;e++){let e=new C(H(t,0,32)),r=K(t),i=H(t,0,r),n=K(t),s=H(t,0,n);h.push({accountKey:e,writableIndexes:i,readonlyIndexes:s})}return new D({header:n,staticAccountKeys:s,recentBlockhash:o,compiledInstructions:l,addressTableLookups:h})}}let j=((i={})[i.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",i[i.PROCESSED=1]="PROCESSED",i[i.TIMED_OUT=2]="TIMED_OUT",i[i.NONCE_INVALID=3]="NONCE_INVALID",i),V=s.Buffer.alloc(64).fill(0);class G{constructor(e){this.keys=void 0,this.programId=void 0,this.data=s.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class X{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!e)return;if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){let{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){let{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{let{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(0===e.length)throw Error("No instructions");return e.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new G(e))}),this}compileMessage(){let e,t,r;if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw Error("Transaction recentBlockhash required");if(t.length<1&&console.warn("No instructions provided"),this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw Error("Transaction fee payer required");for(let e=0;e<t.length;e++)if(void 0===t[e].programId)throw Error(`Transaction instruction index ${e} has undefined program id`);let i=[],n=[];t.forEach(e=>{e.keys.forEach(e=>{n.push({...e})});let t=e.programId.toString();i.includes(t)||i.push(t)}),i.forEach(e=>{n.push({pubkey:new C(e),isSigner:!1,isWritable:!1})});let s=[];n.forEach(e=>{let t=e.pubkey.toString(),r=s.findIndex(e=>e.pubkey.toString()===t);r>-1?(s[r].isWritable=s[r].isWritable||e.isWritable,s[r].isSigner=s[r].isSigner||e.isSigner):s.push(e)}),s.sort(function(e,t){return e.isSigner!==t.isSigner?e.isSigner?-1:1:e.isWritable!==t.isWritable?e.isWritable?-1:1:e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})});let a=s.findIndex(e=>e.pubkey.equals(r));if(a>-1){let[e]=s.splice(a,1);e.isSigner=!0,e.isWritable=!0,s.unshift(e)}else s.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=s.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)s[t].isSigner||(s[t].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let o=0,c=0,l=0,d=[],h=[];s.forEach(({pubkey:e,isSigner:t,isWritable:r})=>{t?(d.push(e.toString()),o+=1,r||(c+=1)):(h.push(e.toString()),r||(l+=1))});let g=d.concat(h),p=t.map(e=>{let{data:t,programId:r}=e;return{programIdIndex:g.indexOf(r.toString()),accounts:e.keys.map(e=>g.indexOf(e.pubkey.toString())),data:u().encode(t)}});return p.forEach(e=>{M(e.programIdIndex>=0),e.accounts.forEach(e=>M(e>=0))}),new F({header:{numRequiredSignatures:o,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:g,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,r)=>t[r].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(0===e.length)throw Error("No signers");let t=new Set;this.signatures=e.filter(e=>{let r=e.toString();return!t.has(r)&&(t.add(r),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(0===e.length)throw Error("No signers");let t=new Set,r=[];for(let i of e){let e=i.publicKey.toString();t.has(e)||(t.add(e),r.push(i))}this.signatures=r.map(e=>({signature:null,publicKey:e.publicKey}));let i=this._compile();this._partialSign(i,...r)}partialSign(...e){if(0===e.length)throw Error("No signers");let t=new Set,r=[];for(let i of e){let e=i.publicKey.toString();t.has(e)||(t.add(e),r.push(i))}let i=this._compile();this._partialSign(i,...r)}_partialSign(e,...t){let r=e.serialize();t.forEach(e=>{let t=v(r,e.secretKey);this._addSignature(e.publicKey,x(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){M(64===t.length);let r=this.signatures.findIndex(t=>e.equals(t.publicKey));if(r<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=s.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let r={};for(let{signature:i,publicKey:n}of this.signatures)null===i?t&&(r.missing||=[]).push(n):B(i,e,n.toBytes())||(r.invalid||=[]).push(n);return r.invalid||r.missing?r:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(r){let e=this._getMessageSignednessErrors(i,t);if(e){let t="Signature verification failed.";throw e.invalid&&(t+=`
2Invalid signature for public key${1===e.invalid.length?"":"(s)"} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`
3Missing signature for public key${1===e.missing.length?"":"(s)"} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(i)}_serialize(e){let{signatures:t}=this,r=[];N(r,t.length);let i=r.length+64*t.length+e.length,n=s.Buffer.alloc(i);return M(t.length<256),s.Buffer.from(r).copy(n,0),t.forEach(({signature:e},t)=>{null!==e&&(M(64===e.length,"signature has invalid length"),s.Buffer.from(e).copy(n,r.length+64*t))}),e.copy(n,r.length+64*t.length),M(n.length<=1232,`Transaction too large: ${n.length} > 1232`),n}get keys(){return M(1===this.instructions.length),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return M(1===this.instructions.length),this.instructions[0].programId}get data(){return M(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e],r=K(t),i=[];for(let e=0;e<r;e++){let e=H(t,0,64);i.push(u().encode(s.Buffer.from(e)))}return X.populate(F.from(t),i)}static populate(e,t=[]){let r=new X;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((t,i)=>{let n={signature:t==u().encode(V)?null:u().decode(t),publicKey:e.accountKeys[i]};r.signatures.push(n)}),e.instructions.forEach(t=>{let i=t.accounts.map(t=>{let i=e.accountKeys[t];return{pubkey:i,isSigner:r.signatures.some(e=>e.publicKey.toString()===i.toString())||e.isAccountSigner(t),isWritable:e.isAccountWritable(t)}});r.instructions.push(new G({keys:i,programId:e.accountKeys[t.programIdIndex],data:u().decode(t.data)}))}),r._message=e,r._json=r.toJSON(),r}}let Z=new C("SysvarC1ock11111111111111111111111111111111");new C("SysvarEpochSchedu1e111111111111111111111111"),new C("Sysvar1nstructions1111111111111111111111111");let Y=new C("SysvarRecentB1ockHashes11111111111111111111"),Q=new C("SysvarRent111111111111111111111111111111111");new C("SysvarRewards111111111111111111111111111111"),new C("SysvarS1otHashes111111111111111111111111111"),new C("SysvarS1otHistory11111111111111111111111111");let ee=new C("SysvarStakeHistory1111111111111111111111111");class et extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:i}){let n;switch(e){case"send":n=`Transaction ${t} resulted in an error. 
4${r}. `+(i?`Logs: 
5${JSON.stringify(i.slice(-10),null,2)}. `:"")+"\nCatch the SendTransactionError and call `getLogs()` on it for full details.";break;case"simulate":n=`Simulation failed. 
6Message: ${r}. 
7`+(i?`Logs: 
8${JSON.stringify(i.slice(-10),null,2)}. `:"")+"\nCatch the SendTransactionError and call `getLogs()` on it for full details.";break;default:n="Unknown action"}super(n),this.signature=void 0,this.transactionMessage=void 0,this.logs=void 0,this.signature=t,this.transactionMessage=r,this.logs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.logs)?this.logs:void 0}}async getLogs(e){return Array.isArray(this.logs)||(this.logs=new Promise((t,r)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let r=e.meta.logMessages;this.logs=r,t(r)}else r(Error("Log messages not found"))}).catch(r)})),await this.logs}}class er extends Error{constructor({code:e,message:t,data:r},i){super(null!=i?`${i}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}async function ei(e,t,r,i){let n;let s=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,maxRetries:i.maxRetries,minContextSlot:i.minContextSlot},a=await e.sendTransaction(t,r,s);if(null!=t.recentBlockhash&&null!=t.lastValidBlockHeight)n=(await e.confirmTransaction({abortSignal:i?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},i&&i.commitment)).value;else if(null!=t.minNonceContextSlot&&null!=t.nonceInfo){let{nonceInstruction:r}=t.nonceInfo,s=r.keys[0].pubkey;n=(await e.confirmTransaction({abortSignal:i?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:s,nonceValue:t.nonceInfo.nonce,signature:a},i&&i.commitment)).value}else i?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),n=(await e.confirmTransaction(a,i&&i.commitment)).value;if(n.err){if(null!=a)throw new et({action:"send",signature:a,transactionMessage:`Status: (${JSON.stringify(n)})`});throw Error(`Transaction ${a} failed (${JSON.stringify(n)})`)}return a}function en(e){return new Promise(t=>setTimeout(t,e))}function es(e,t){let r=e.layout.span>=0?e.layout.span:function e(t,r){let i=t=>{if(t.span>=0)return t.span;if("function"==typeof t.alloc)return t.alloc(r[t.property]);if("count"in t&&"elementLayout"in t){let e=r[t.property];if(Array.isArray(e))return e.length*i(t.elementLayout)}else if("fields"in t)return e({layout:t},r[t.property]);return 0},n=0;return t.layout.fields.forEach(e=>{n+=i(e)}),n}(e,t),i=s.Buffer.alloc(r),n=Object.assign({instruction:e.index},t);return e.layout.encode(n,i),i}let ea=g._O("lamportsPerSignature"),eo=g.n_([g.Jq("version"),g.Jq("state"),z("authorizedPubkey"),z("nonce"),g.n_([ea],"feeCalculator")]),ec=eo.span;class el{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){let t=eo.decode(x(e),0);return new el({authorizedPubkey:new C(t.authorizedPubkey),nonce:new C(t.nonce).toString(),feeCalculator:t.feeCalculator})}}let eu=e=>({decode:e.decode.bind(e),encode:e.encode.bind(e)}),ed=e=>{let t=(0,g.Ik)(8,e),{encode:r,decode:i}=eu(t);return t.decode=(e,t)=>{let r=i(e,t);return(0,p.oU)(s.Buffer.from(r))},t.encode=(e,t,i)=>r((0,p.k$)(e,8),t,i),t},eh=Object.freeze({Create:{index:0,layout:g.n_([g.Jq("instruction"),g.gM("lamports"),g.gM("space"),z("programId")])},Assign:{index:1,layout:g.n_([g.Jq("instruction"),z("programId")])},Transfer:{index:2,layout:g.n_([g.Jq("instruction"),ed("lamports")])},CreateWithSeed:{index:3,layout:g.n_([g.Jq("instruction"),z("base"),O("seed"),g.gM("lamports"),g.gM("space"),z("programId")])},AdvanceNonceAccount:{index:4,layout:g.n_([g.Jq("instruction")])},WithdrawNonceAccount:{index:5,layout:g.n_([g.Jq("instruction"),g.gM("lamports")])},InitializeNonceAccount:{index:6,layout:g.n_([g.Jq("instruction"),z("authorized")])},AuthorizeNonceAccount:{index:7,layout:g.n_([g.Jq("instruction"),z("authorized")])},Allocate:{index:8,layout:g.n_([g.Jq("instruction"),g.gM("space")])},AllocateWithSeed:{index:9,layout:g.n_([g.Jq("instruction"),z("base"),O("seed"),g.gM("space"),z("programId")])},AssignWithSeed:{index:10,layout:g.n_([g.Jq("instruction"),z("base"),O("seed"),z("programId")])},TransferWithSeed:{index:11,layout:g.n_([g.Jq("instruction"),ed("lamports"),O("seed"),z("programId")])},UpgradeNonceAccount:{index:12,layout:g.n_([g.Jq("instruction")])}});class eg{constructor(){}static createAccount(e){let t=es(eh.Create,{lamports:e.lamports,space:e.space,programId:x(e.programId.toBuffer())});return new G({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:t})}static transfer(e){let t,r;return"basePubkey"in e?(t=es(eh.TransferWithSeed,{lamports:BigInt(e.lamports),seed:e.seed,programId:x(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]):(t=es(eh.Transfer,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]),new G({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;return"basePubkey"in e?(t=es(eh.AssignWithSeed,{base:x(e.basePubkey.toBuffer()),seed:e.seed,programId:x(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]):(t=es(eh.Assign,{programId:x(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]),new G({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=es(eh.CreateWithSeed,{base:x(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:x(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey!=e.fromPubkey&&r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new G({keys:r,programId:this.programId,data:t})}static createNonceAccount(e){let t=new X;"basePubkey"in e&&"seed"in e?t.add(eg.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:ec,programId:this.programId})):t.add(eg.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:ec,programId:this.programId}));let r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){let t=es(eh.InitializeNonceAccount,{authorized:x(e.authorizedPubkey.toBuffer())});return new G({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!1,isWritable:!1}],programId:this.programId,data:t})}static nonceAdvance(e){let t=es(eh.AdvanceNonceAccount);return new G({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static nonceWithdraw(e){let t=es(eh.WithdrawNonceAccount,{lamports:e.lamports});return new G({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static nonceAuthorize(e){let t=es(eh.AuthorizeNonceAccount,{authorized:x(e.newAuthorizedPubkey.toBuffer())});return new G({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static allocate(e){let t,r;return"basePubkey"in e?(t=es(eh.AllocateWithSeed,{base:x(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:x(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]):(t=es(eh.Allocate,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]),new G({keys:r,programId:this.programId,data:t})}}eg.programId=new C("11111111111111111111111111111111");class ep{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/ep.chunkSize)+1+1)}static async load(e,t,r,i,n){{let s=await e.getMinimumBalanceForRentExemption(n.length),a=await e.getAccountInfo(r.publicKey,"confirmed"),o=null;if(null!==a){if(a.executable)return console.error("Program load failed, account is already executable"),!1;a.data.length!==n.length&&(o=o||new X).add(eg.allocate({accountPubkey:r.publicKey,space:n.length})),a.owner.equals(i)||(o=o||new X).add(eg.assign({accountPubkey:r.publicKey,programId:i})),a.lamports<s&&(o=o||new X).add(eg.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:s-a.lamports}))}else o=new X().add(eg.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:s>0?s:1,space:n.length,programId:i}));null!==o&&await ei(e,o,[t,r],{commitment:"confirmed"})}let a=g.n_([g.Jq("instruction"),g.Jq("offset"),g.Jq("bytesLength"),g.Jq("bytesLengthPadding"),g.A9(g.u8("byte"),g.cv(g.Jq(),-8),"bytes")]),o=ep.chunkSize,c=0,l=n,u=[];for(;l.length>0;){let n=l.slice(0,o),d=s.Buffer.alloc(o+16);a.encode({instruction:0,offset:c,bytes:n,bytesLength:0,bytesLengthPadding:0},d);let h=new X().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:d});u.push(ei(e,h,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await en(250),c+=o,l=l.slice(o)}await Promise.all(u);{let n=g.n_([g.Jq("instruction")]),a=s.Buffer.alloc(n.span);n.encode({instruction:1},a);let o=new X().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!1}],programId:i,data:a}),c="processed",l=await e.sendTransaction(o,[t,r],{preflightCommitment:c}),{context:u,value:d}=await e.confirmTransaction({signature:l,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},c);if(d.err)throw Error(`Transaction ${l} failed (${JSON.stringify(d)})`);for(;;){try{if(await e.getSlot({commitment:c})>u.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(200)))}}return!0}}ep.chunkSize=932,new C("BPFLoader2111111111111111111111111111111111");var eb=Object.prototype.toString,em=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},ey=(n=function(e){var t=function e(t,r){var i,n,s,a,o,c,l;if(!0===t)return"true";if(!1===t)return"false";switch(typeof t){case"object":if(null===t)return null;if(t.toJSON&&"function"==typeof t.toJSON)return e(t.toJSON(),r);if("[object Array]"===(l=eb.call(t))){for(i=0,s="[",n=t.length-1;i<n;i++)s+=e(t[i],!0)+",";return n>-1&&(s+=e(t[i],!0)),s+"]"}if("[object Object]"!==l)return JSON.stringify(t);for(n=(a=em(t).sort()).length,s="",i=0;i<n;)void 0!==(c=e(t[o=a[i]],!1))&&(s&&(s+=","),s+=JSON.stringify(o)+":"+c),i++;return"{"+s+"}";case"function":case"undefined":return r?null:void 0;case"string":return JSON.stringify(t);default:return isFinite(t)?t:null}}(e,!1);if(void 0!==t)return""+t}).__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;function ef(e){let t=0;for(;e>1;)e/=2,t++;return t}class ek{constructor(e,t,r,i,n){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=n}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){var t;let r=ef(0===(t=e+32+1)?1:(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,(t|=t>>32)+1))-ef(32)-1,i=this.getSlotsInEpoch(r);return[r,e-(i-32)]}{let t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+r,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*32:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+ef(32)):this.slotsPerEpoch}}var ew=globalThis.fetch;class eS extends f.Z{constructor(e,t,r){super(e=>{let r=(0,k.Z)(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in r?this.underlyingSocket=r.socket:this.underlyingSocket=r,r},e,t,r),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return 1===t?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){let t=this.underlyingSocket?.readyState;return 1===t?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}class e_{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){let t=function(e,t){let r;try{r=e.layout.decode(t)}catch(e){throw Error("invalid instruction; "+e)}if(r.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${r.typeIndex} != ${e.index}`);return r}(eI,e),r=e.length-56;M(r>
8=0,"lookup table is invalid"),M(r%32==0,"lookup table is invalid");let{addresses:i}=g.n_([g.A9(z(),r/32,"addresses")]).decode(e.slice(56));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:0!==t.authority.length?new C(t.authority[0]):void 0,addresses:i.map(e=>new C(e))}}}let eI={index:1,layout:g.n_([g.Jq("typeIndex"),ed("deactivationSlot"),g._O("lastExtendedSlot"),g.u8("lastExtendedStartIndex"),g.u8(),g.A9(z(),g.cv(g.u8(),-1),"authority")])},eA=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i,ev=(0,b.coerce)((0,b.instance)(C),(0,b.string)(),e=>new C(e)),eB=(0,b.tuple)([(0,b.string)(),(0,b.literal)("base64")]),ex=(0,b.coerce)((0,b.instance)(s.Buffer),eB,e=>s.Buffer.from(e[0],"base64"));function eP(e){let t,r;if("string"==typeof e)t=e;else if(e){let{commitment:i,...n}=e;t=i,r=n}return{commitment:t,config:r}}function eE(e){return(0,b.union)([(0,b.type)({jsonrpc:(0,b.literal)("2.0"),id:(0,b.string)(),result:e}),(0,b.type)({jsonrpc:(0,b.literal)("2.0"),id:(0,b.string)(),error:(0,b.type)({code:(0,b.unknown)(),message:(0,b.string)(),data:(0,b.optional)((0,b.any)())})})])}let eT=eE((0,b.unknown)());function eC(e){return(0,b.coerce)(eE(e),eT,t=>"error"in t?t:{...t,result:(0,b.create)(t.result,e)})}function eW(e){return eC((0,b.type)({context:(0,b.type)({slot:(0,b.number)()}),value:e}))}function eq(e){return(0,b.type)({context:(0,b.type)({slot:(0,b.number)()}),value:e})}function eL(e,t){return 0===e?new D({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new C(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:u().decode(e.data)})),addressTableLookups:t.addressTableLookups}):new F(t)}let eR=(0,b.type)({foundation:(0,b.number)(),foundationTerm:(0,b.number)(),initial:(0,b.number)(),taper:(0,b.number)(),terminal:(0,b.number)()}),ez=eC((0,b.array)((0,b.nullable)((0,b.type)({epoch:(0,b.number)(),effectiveSlot:(0,b.number)(),amount:(0,b.number)(),postBalance:(0,b.number)(),commission:(0,b.optional)((0,b.nullable)((0,b.number)()))})))),eO=(0,b.array)((0,b.type)({slot:(0,b.number)(),prioritizationFee:(0,b.number)()})),eK=(0,b.type)({total:(0,b.number)(),validator:(0,b.number)(),foundation:(0,b.number)(),epoch:(0,b.number)()}),eN=(0,b.type)({epoch:(0,b.number)(),slotIndex:(0,b.number)(),slotsInEpoch:(0,b.number)(),absoluteSlot:(0,b.number)(),blockHeight:(0,b.optional)((0,b.number)()),transactionCount:(0,b.optional)((0,b.number)())}),eM=(0,b.type)({slotsPerEpoch:(0,b.number)(),leaderScheduleSlotOffset:(0,b.number)(),warmup:(0,b.boolean)(),firstNormalEpoch:(0,b.number)(),firstNormalSlot:(0,b.number)()}),eJ=(0,b.record)((0,b.string)(),(0,b.array)((0,b.number)())),eU=(0,b.nullable)((0,b.union)([(0,b.type)({}),(0,b.string)()])),e$=(0,b.type)({err:eU}),eH=(0,b.literal)("receivedSignature"),eF=(0,b.type)({"solana-core":(0,b.string)(),"feature-set":(0,b.optional)((0,b.number)())}),eD=eW((0,b.type)({err:(0,b.nullable)((0,b.union)([(0,b.type)({}),(0,b.string)()])),logs:(0,b.nullable)((0,b.array)((0,b.string)())),accounts:(0,b.optional)((0,b.nullable)((0,b.array)((0,b.nullable)((0,b.type)({executable:(0,b.boolean)(),owner:(0,b.string)(),lamports:(0,b.number)(),data:(0,b.array)((0,b.string)()),rentEpoch:(0,b.optional)((0,b.number)())}))))),unitsConsumed:(0,b.optional)((0,b.number)()),returnData:(0,b.optional)((0,b.nullable)((0,b.type)({programId:(0,b.string)(),data:(0,b.tuple)([(0,b.string)(),(0,b.literal)("base64")])})))})),ej=eW((0,b.type)({byIdentity:(0,b.record)((0,b.string)(),(0,b.array)((0,b.number)())),range:(0,b.type)({firstSlot:(0,b.number)(),lastSlot:(0,b.number)()})})),eV=eC(eR),eG=eC(eK),eX=eC(eO),eZ=eC(eN),eY=eC(eM),eQ=eC(eJ),e0=eC((0,b.number)()),e1=eW((0,b.type)({total:(0,b.number)(),circulating:(0,b.number)(),nonCirculating:(0,b.number)(),nonCirculatingAccounts:(0,b.array)(ev)})),e8=(0,b.type)({amount:(0,b.string)(),uiAmount:(0,b.nullable)((0,b.number)()),decimals:(0,b.number)(),uiAmountString:(0,b.optional)((0,b.string)())}),e2=eW((0,b.array)((0,b.type)({address:ev,amount:(0,b.string)(),uiAmount:(0,b.nullable)((0,b.number)()),decimals:(0,b.number)(),uiAmountString:(0,b.optional)((0,b.string)())}))),e5=eW((0,b.array)((0,b.type)({pubkey:ev,account:(0,b.type)({executable:(0,b.boolean)(),owner:ev,lamports:(0,b.number)(),data:ex,rentEpoch:(0,b.number)()})}))),e3=(0,b.type)({program:(0,b.string)(),parsed:(0,b.unknown)(),space:(0,b.number)()}),e6=eW((0,b.array)((0,b.type)({pubkey:ev,account:(0,b.type)({executable:(0,b.boolean)(),owner:ev,lamports:(0,b.number)(),data:e3,rentEpoch:(0,b.number)()})}))),e4=eW((0,b.array)((0,b.type)({lamports:(0,b.number)(),address:ev}))),e9=(0,b.type)({executable:(0,b.boolean)(),owner:ev,lamports:(0,b.number)(),data:ex,rentEpoch:(0,b.number)()}),e7=(0,b.type)({pubkey:ev,account:e9}),te=(0,b.coerce)((0,b.union)([(0,b.instance)(s.Buffer),e3]),(0,b.union)([eB,e3]),e=>Array.isArray(e)?(0,b.create)(e,ex):e),tt=(0,b.type)({executable:(0,b.boolean)(),owner:ev,lamports:(0,b.number)(),data:te,rentEpoch:(0,b.number)()}),tr=(0,b.type)({pubkey:ev,account:tt}),ti=(0,b.type)({state:(0,b.union)([(0,b.literal)("active"),(0,b.literal)("inactive"),(0,b.literal)("activating"),(0,b.literal)("deactivating")]),active:(0,b.number)(),inactive:(0,b.number)()}),tn=eC((0,b.array)((0,b.type)({signature:(0,b.string)(),slot:(0,b.number)(),err:eU,memo:(0,b.nullable)((0,b.string)()),blockTime:(0,b.optional)((0,b.nullable)((0,b.number)()))}))),ts=eC((0,b.array)((0,b.type)({signature:(0,b.string)(),slot:(0,b.number)(),err:eU,memo:(0,b.nullable)((0,b.string)()),blockTime:(0,b.optional)((0,b.nullable)((0,b.number)()))}))),ta=(0,b.type)({subscription:(0,b.number)(),result:eq(e9)}),to=(0,b.type)({pubkey:ev,account:e9}),tc=(0,b.type)({subscription:(0,b.number)(),result:eq(to)}),tl=(0,b.type)({parent:(0,b.number)(),slot:(0,b.number)(),root:(0,b.number)()}),tu=(0,b.type)({subscription:(0,b.number)(),result:tl}),td=(0,b.union)([(0,b.type)({type:(0,b.union)([(0,b.literal)("firstShredReceived"),(0,b.literal)("completed"),(0,b.literal)("optimisticConfirmation"),(0,b.literal)("root")
8]),slot:(0,b.number)(),timestamp:(0,b.number)()}),(0,b.type)({type:(0,b.literal)("createdBank"),parent:(0,b.number)(),slot:(0,b.number)(),timestamp:(0,b.number)()}),(0,b.type)({type:(0,b.literal)("frozen"),slot:(0,b.number)(),timestamp:(0,b.number)(),stats:(0,b.type)({numTransactionEntries:(0,b.number)(),numSuccessfulTransactions:(0,b.number)(),numFailedTransactions:(0,b.number)(),maxTransactionsPerEntry:(0,b.number)()})}),(0,b.type)({type:(0,b.literal)("dead"),slot:(0,b.number)(),timestamp:(0,b.number)(),err:(0,b.string)()})]),th=(0,b.type)({subscription:(0,b.number)(),result:td}),tg=(0,b.type)({subscription:(0,b.number)(),result:eq((0,b.union)([e$,eH]))}),tp=(0,b.type)({subscription:(0,b.number)(),result:(0,b.number)()}),tb=(0,b.type)({pubkey:(0,b.string)(),gossip:(0,b.nullable)((0,b.string)()),tpu:(0,b.nullable)((0,b.string)()),rpc:(0,b.nullable)((0,b.string)()),version:(0,b.nullable)((0,b.string)())}),tm=(0,b.type)({votePubkey:(0,b.string)(),nodePubkey:(0,b.string)(),activatedStake:(0,b.number)(),epochVoteAccount:(0,b.boolean)(),epochCredits:(0,b.array)((0,b.tuple)([(0,b.number)(),(0,b.number)(),(0,b.number)()])),commission:(0,b.number)(),lastVote:(0,b.number)(),rootSlot:(0,b.nullable)((0,b.number)())}),ty=eC((0,b.type)({current:(0,b.array)(tm),delinquent:(0,b.array)(tm)})),tf=(0,b.union)([(0,b.literal)("processed"),(0,b.literal)("confirmed"),(0,b.literal)("finalized")]),tk=(0,b.type)({slot:(0,b.number)(),confirmations:(0,b.nullable)((0,b.number)()),err:eU,confirmationStatus:(0,b.optional)(tf)}),tw=eW((0,b.array)((0,b.nullable)(tk))),tS=eC((0,b.number)()),t_=(0,b.type)({accountKey:ev,writableIndexes:(0,b.array)((0,b.number)()),readonlyIndexes:(0,b.array)((0,b.number)())}),tI=(0,b.type)({signatures:(0,b.array)((0,b.string)()),message:(0,b.type)({accountKeys:(0,b.array)((0,b.string)()),header:(0,b.type)({numRequiredSignatures:(0,b.number)(),numReadonlySignedAccounts:(0,b.number)(),numReadonlyUnsignedAccounts:(0,b.number)()}),instructions:(0,b.array)((0,b.type)({accounts:(0,b.array)((0,b.number)()),data:(0,b.string)(),programIdIndex:(0,b.number)()})),recentBlockhash:(0,b.string)(),addressTableLookups:(0,b.optional)((0,b.array)(t_))})}),tA=(0,b.type)({pubkey:ev,signer:(0,b.boolean)(),writable:(0,b.boolean)(),source:(0,b.optional)((0,b.union)([(0,b.literal)("transaction"),(0,b.literal)("lookupTable")]))}),tv=(0,b.type)({accountKeys:(0,b.array)(tA),signatures:(0,b.array)((0,b.string)())}),tB=(0,b.type)({parsed:(0,b.unknown)(),program:(0,b.string)(),programId:ev}),tx=(0,b.type)({accounts:(0,b.array)(ev),data:(0,b.string)(),programId:ev}),tP=(0,b.union)([tx,tB]),tE=(0,b.union)([(0,b.type)({parsed:(0,b.unknown)(),program:(0,b.string)(),programId:(0,b.string)()}),(0,b.type)({accounts:(0,b.array)((0,b.string)()),data:(0,b.string)(),programId:(0,b.string)()})]),tT=(0,b.coerce)(tP,tE,e=>"accounts"in e?(0,b.create)(e,tx):(0,b.create)(e,tB)),tC=(0,b.type)({signatures:(0,b.array)((0,b.string)()),message:(0,b.type)({accountKeys:(0,b.array)(tA),instructions:(0,b.array)(tT),recentBlockhash:(0,b.string)(),addressTableLookups:(0,b.optional)((0,b.nullable)((0,b.array)(t_)))})}),tW=(0,b.type)({accountIndex:(0,b.number)(),mint:(0,b.string)(),owner:(0,b.optional)((0,b.string)()),uiTokenAmount:e8}),tq=(0,b.type)({writable:(0,b.array)(ev),readonly:(0,b.array)(ev)}),tL=(0,b.type)({err:eU,fee:(0,b.number)(),innerInstructions:(0,b.optional)((0,b.nullable)((0,b.array)((0,b.type)({index:(0,b.number)(),instructions:(0,b.array)((0,b.type)({accounts:(0,b.array)((0,b.number)()),data:(0,b.string)(),programIdIndex:(0,b.number)()}))})))),preBalances:(0,b.array)((0,b.number)()),postBalances:(0,b.array)((0,b.number)()),logMessages:(0,b.optional)((0,b.nullable)((0,b.array)((0,b.string)()))),preTokenBalances:(0,b.optional)((0,b.nullable)((0,b.array)(tW))),postTokenBalances:(0,b.optional)((0,b.nullable)((0,b.array)(tW))),loadedAddresses:(0,b.optional)(tq),computeUnitsConsumed:(0,b.optional)((0,b.number)())}),tR=(0,b.type)({err:eU,fee:(0,b.number)(),innerInstructions:(0,b.optional)((0,b.nullable)((0,b.array)((0,b.type)({index:(0,b.number)(),instructions:(0,b.array)(tT)})))),preBalances:(0,b.array)((0,b.number)()),postBalances:(0,b.array)((0,b.number)()),logMessages:(0,b.optional)((0,b.nullable)((0,b.array)((0,b.string)()))),preTokenBalances:(0,b.optional)((0,b.nullable)((0,b.array)(tW))),postTokenBalances:(0,b.optional)((0,b.nullable)((0,b.array)(tW))),loadedAddresses:(0,b.optional)(tq),computeUnitsConsumed:(0,b.optional)((0,b.number)())}),tz=(0,b.union)([(0,b.literal)(0),(0,b.literal)("legacy")]),tO=(0,b.type)({pubkey:(0,b.string)(),lamports:(0,b.number)(),postBalance:(0,b.nullable)((0,b.number)()),rewardType:(0,b.nullable)((0,b.string)()),commission:(0,b.optional)((0,b.nullable)((0,b.number)()))}),tK=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),transactions:(0,b.array)((0,b.type)({transaction:tI,meta:(0,b.nullable)(tL),version:(0,b.optional)(tz)})),rewards:(0,b.optional)((0,b.array)(tO)),blockTime:(0,b.nullable)((0,b.number)()),blockHeight:(0,b.nullable)((0,b.number)())}))),tN=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),rewards:(0,b.optional)((0,b.array)(tO)),blockTime:(0,b.nullable)((0,b.number)()),blockHeight:(0,b.nullable)((0,b.number)())}))),tM=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),transactions:(0,b.array)((0,b.type)({transaction:tv,meta:(0,b.nullable)(tL),version:(0,b.optional)(tz)})),rewards:(0,b.optional)((0,b.array)(tO)),blockTime:(0,b.nullable)((0,b.number)()),blockHeight:(0,b.nullable)((0,b.number)())}))),tJ=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),transactions:(0,b.array)((0,b.type)({transaction:tC,meta:(0,b.nullable)(tR),version:(0,b.optional)(tz)})),rewards:(0,b.optional)((0,b.array)(tO)),blockTime:(0,b.nullable)((0,b.number)()),blockHeight:(0,b.nullable)((0,b.number)())}))),tU=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),transactions:(0,b.array)((0,b.type)({transaction:tv,meta:(0,b.nullable)(tR),version:(0,b.optional)(tz)})),rewards:(0,b.optional)((0,b.array)(tO)),blockTime:(0,b.nullable)((0,b.number)()),blockHeight:(0,b.nullable)((0,b.number)())}))),t$=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),rewards:(0,b.optional)((0,b.array)(tO)),blockTime:(0,b.nullable)((0,b.number)()),blockHeight:(0,b.nullable)((0,b.number)())}))),tH=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),transactions:(0,b.array)((0,b.type)({transaction:tI,meta:(0,b.nullable)(tL)})),rewards:(0,b.optional)((0,b.array)(tO)),blockTime:(0,b.nullable)((0,b.number)())}))),tF=eC((0,b.nullable)((0,b.type)({blockhash:(0,b.string)(),previousBlockhash:(0,b.string)(),parentSlot:(0,b.number)(),signatures:(0,b.array)((0,b.string)()),blockTime:(0,b.nullable)((0,b.number)())}))),tD=eC((0,b.nullable)((0,b.type)({slot:(0,b.number)(),meta:(0,b.nullable)(tL),blockTime:(0,b.optional)((0,b.nullable)((0,b.number)())),transaction:tI,version:(0,b.optional)(tz)}))),tj=eC((0,b.nullable)((0,b.type)({slot:(0,b.number)(),transaction:tC,meta:(0,b.nullable)(tR),blockTime:(0,b.optional)((0,b.nullable)((0,b.number)())),version:(0,b.optional)(tz)}))),tV=eW((0,b.type)({blockhash:(0,b.string)(),feeCalculator:(0,b.type)({lamportsPerSignature:(0,b.number)()})}
8)),tG=eW((0,b.type)({blockhash:(0,b.string)(),lastValidBlockHeight:(0,b.number)()})),tX=eW((0,b.boolean)()),tZ=(0,b.type)({slot:(0,b.number)(),numTransactions:(0,b.number)(),numSlots:(0,b.number)(),samplePeriodSecs:(0,b.number)()}),tY=eC((0,b.array)(tZ)),tQ=eW((0,b.nullable)((0,b.type)({feeCalculator:(0,b.type)({lamportsPerSignature:(0,b.number)()})}))),t0=eC((0,b.string)()),t1=eC((0,b.string)()),t8=(0,b.type)({err:eU,logs:(0,b.array)((0,b.string)()),signature:(0,b.string)()}),t2=(0,b.type)({result:eq(t8),subscription:(0,b.number)()}),t5={"solana-client":"js/0.0.0-development"};class t3{constructor(e,t){var r,i;let n,s,a,o,c,l;this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:r,config:i}=eP(t),n=this._buildArgs([],r,void 0,i),s=ey(n);return e[s]=e[s]??(async()=>{try{let e=await this._rpcRequest("getBlockHeight",n),t=(0,b.create)(e,eC((0,b.number)()));if("error"in t)throw new er(t.error,"failed to get block height information");return t.result}finally{delete e[s]}})(),await e[s]}})(),t&&"string"==typeof t?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,s=t.httpHeaders,a=t.fetch,o=t.fetchMiddleware,c=t.disableRetryOnRateLimit,l=t.httpAgent),this._rpcEndpoint=function(e){if(!1===/^https?:/.test(e))throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}(e),this._rpcWsEndpoint=n||function(e){let t=e.match(eA);if(null==t)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[r,i,n,s]=t,a=e.startsWith("https:")?"wss:":"ws:",o=null==n?null:parseInt(n.slice(1),10),c=null==o?"":`:${o+1}`;return`${a}//${i}${c}${s}`}(e),this._rpcClient=function(e,t,r,i,n,s){let a,o;let c=r||ew;return null!=s&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments."),i&&(o=async(e,t)=>{let r=await new Promise((r,n)=>{try{i(e,t,(e,t)=>r([e,t]))}catch(e){n(e)}});return await c(...r)}),new(y())(async(r,i)=>{let s={method:"POST",body:r,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},t5)};try{let t,r=5,a=500;for(;t=o?await o(e,s):await c(e,s),429===t.status&&!0!==n&&(r-=1,0!==r);)console.error(`Server responded with ${t.status} ${t.statusText}.  Retrying after ${a}ms delay...`),await en(a),a*=2;let l=await t.text();t.ok?i(null,l):i(Error(`${t.status} ${t.statusText}: ${l}`))}catch(e){e instanceof Error&&i(e)}},{})}(e,s,a,o,c,l),this._rpcRequest=(r=this._rpcClient,(e,t)=>new Promise((i,n)=>{r.request(e,t,(e,t)=>{if(e){n(e);return}i(t)})})),this._rpcBatchRequest=(i=this._rpcClient,e=>new Promise((t,r)=>{0===e.length&&t([]);let n=e.map(e=>i.request(e.methodName,e.args));i.request(n,(e,i)=>{if(e){r(e);return}t(i)})})),this._rpcWebSocket=new eS(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}
8async getBalanceAndContext(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgs([e.toBase58()],r,void 0,i),s=await this._rpcRequest("getBalance",n),a=(0,b.create)(s,eW((0,b.number)()));if("error"in a)throw new er(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error("failed to get balance of account "+e.toBase58()+": "+t)})}async getBlockTime(e){let t=await this._rpcRequest("getBlockTime",[e]),r=(0,b.create)(t,eC((0,b.nullable)((0,b.number)())));if("error"in r)throw new er(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){let e=await this._rpcRequest("minimumLedgerSlot",[]),t=(0,b.create)(e,eC((0,b.number)()));if("error"in t)throw new er(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){let e=await this._rpcRequest("getFirstAvailableBlock",[]),t=(0,b.create)(e,e0);if("error"in t)throw new er(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};t="string"==typeof e?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let r=await this._rpcRequest("getSupply",[t]),i=(0,b.create)(r,e1);if("error"in i)throw new er(i.error,"failed to get supply");return i.result}async getTokenSupply(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenSupply",r),n=(0,b.create)(i,eW(e8));if("error"in n)throw new er(n.error,"failed to get token supply");return n.result}async getTokenAccountBalance(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",r),n=(0,b.create)(i,eW(e8));if("error"in n)throw new er(n.error,"failed to get token account balance");return n.result}async getTokenAccountsByOwner(e,t,r){let{commitment:i,config:n}=eP(r),s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});let a=this._buildArgs(s,i,"base64",n),o=await this._rpcRequest("getTokenAccountsByOwner",a),c=(0,b.create)(o,e5);if("error"in c)throw new er(c.error,`failed to get token accounts owned by account ${e.toBase58()}`);return c.result}async getParsedTokenAccountsByOwner(e,t,r){let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});let n=this._buildArgs(i,r,"jsonParsed"),s=await this._rpcRequest("getTokenAccountsByOwner",n),a=(0,b.create)(s,e6);if("error"in a)throw new er(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],i=await this._rpcRequest("getLargestAccounts",r),n=(0,b.create)(i,e4);if("error"in n)throw new er(n.error,"failed to get largest accounts");return n.result}async getTokenLargestAccounts(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",r),n=(0,b.create)(i,e2);if("error"in n)throw new er(n.error,"failed to get token largest accounts");return n.result}async getAccountInfoAndContext(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgs([e.toBase58()],r,"base64",i),s=await this._rpcRequest("getAccountInfo",n),a=(0,b.create)(s,eW((0,b.nullable)(e9)));if("error"in a)throw new er(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgs([e.toBase58()],r,"jsonParsed",i),s=await this._rpcRequest("getAccountInfo",n),a=(0,b.create)(s,eW((0,b.nullable)(tt)));if("error"in a)throw new er(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error("failed to get info about account "+e.toBase58()+": "+t)}}async getMultipleParsedAccounts(e,t){let{commitment:r,config:i}=eP(t),n=e.map(e=>e.toBase58()),s=this._buildArgs([n],r,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",s),o=(0,b.create)(a,eW((0,b.array)((0,b.nullable)(tt))));if("error"in o)throw new er(o.error,`failed to get info for accounts ${n}`);return o.result}
8async getMultipleAccountsInfoAndContext(e,t){let{commitment:r,config:i}=eP(t),n=e.map(e=>e.toBase58()),s=this._buildArgs([n],r,"base64",i),a=await this._rpcRequest("getMultipleAccounts",s),o=(0,b.create)(a,eW((0,b.array)((0,b.nullable)(e9))));if("error"in o)throw new er(o.error,`failed to get info for accounts ${n}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){let{commitment:i,config:n}=eP(t),s=this._buildArgs([e.toBase58()],i,void 0,{...n,epoch:null!=r?r:n?.epoch}),a=await this._rpcRequest("getStakeActivation",s),o=(0,b.create)(a,eC(ti));if("error"in o)throw new er(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:r,config:i}=eP(t),{encoding:n,...s}=i||{},a=this._buildArgs([e.toBase58()],r,n||"base64",s),o=await this._rpcRequest("getProgramAccounts",a),c=(0,b.array)(e7),l=!0===s.withContext?(0,b.create)(o,eW(c)):(0,b.create)(o,eC(c));if("error"in l)throw new er(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgs([e.toBase58()],r,"jsonParsed",i),s=await this._rpcRequest("getProgramAccounts",n),a=(0,b.create)(s,eC((0,b.array)(tr)));if("error"in a)throw new er(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let r,i;if("string"==typeof e)r=e;else{if(e.abortSignal?.aborted)return Promise.reject(e.abortSignal.reason);r=e.signature}try{i=u().decode(r)}catch(e){throw Error("signature must be base58 encoded: "+r)}return(M(64===i.length,"signature has invalid length"),"string"==typeof e)?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,r)=>{null!=e&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,i;let n=!1;return{abortConfirmation:()=>{i&&(i(),i=void 0),null!=r&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:new Promise((s,a)=>{try{r=this.onSignature(t,(e,t)=>{r=void 0,s({__type:j.PROCESSED,response:{context:t,value:e}})},e);let o=new Promise(e=>{null==r?e():i=this._onSubscriptionStateChange(r,t=>{"subscribed"===t&&e()})});(async()=>{if(await o,n)return;
8let r=await this.getSignatureStatus(t);if(n||null==r)return;let{context:i,value:c}=r;if(null!=c){if(c?.err)a(c.err);else{switch(e){case"confirmed":case"single":case"singleGossip":if("processed"===c.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===c.confirmationStatus||"confirmed"===c.confirmationStatus)return}n=!0,s({__type:j.PROCESSED,response:{context:i,value:c}})}}})()}catch(e){a(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:i}}){let n,s=!1,a=new Promise(t=>{let i=async()=>{try{return await this.getBlockHeight(e)}catch(e){return -1}};(async()=>{let e=await i();if(!s){for(;e<=r;)if(await en(1e3),s||(e=await i(),s))return;t({__type:j.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:c}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),l=this.getCancellationPromise(t);try{let e=await Promise.race([l,c,a]);if(e.__type===j.PROCESSED)n=e.response;else throw new W(i)}finally{s=!0,o()}return n}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:i,nonceValue:n,signature:s}}){let a,o=!1,c=new Promise(t=>{let s=n,a=null,c=async()=>{try{let{context:t,value:n}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:r});return a=t.slot,n?.nonce}catch(e){return s}};(async()=>{if(s=await c(),!o)for(;;){if(n!==s){t({__type:j.NONCE_INVALID,slotInWhichNonceDidAdvance:a});return}if(await en(2e3),o||(s=await c(),o))return}})()}),{abortConfirmation:l,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),d=this.getCancellationPromise(t);try{let t=await Promise.race([d,u,c]);if(t.__type===j.PROCESSED)a=t.response;else{let i;for(;;
8){let e=await this.getSignatureStatus(s);if(null==e)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??r)){await en(400);continue}i=e;break}if(i?.value){let t=e||"finalized",{confirmationStatus:r}=i.value;switch(t){case"processed":case"recent":if("processed"!==r&&"confirmed"!==r&&"finalized"!==r)throw new L(s);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==r&&"finalized"!==r)throw new L(s);break;case"finalized":case"max":case"root":if("finalized"!==r)throw new L(s)}a={context:i.context,value:{err:i.value.err}}}else throw new L(s)}}finally{o=!0,l()}return a}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r,i;let n=new Promise(t=>{let i=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":i=this._confirmTransactionInitialTimeout||3e4}r=setTimeout(()=>t({__type:j.TIMED_OUT,timeoutMs:i}),i)}),{abortConfirmation:s,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t});try{let e=await Promise.race([a,n]);if(e.__type===j.PROCESSED)i=e.response;else throw new q(t,e.timeoutMs/1e3)}finally{clearTimeout(r),s()}return i}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=(0,b.create)(e,eC((0,b.array)(tb)));if("error"in t)throw new er(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",t),i=(0,b.create)(r,ty);if("error"in i)throw new er(i.error,"failed to get vote accounts");return i.result}async getSlot(e){let{commitment:t,config:r}=eP(e),i=this._buildArgs([],t,void 0,r),n=await this._rpcRequest("getSlot",i),s=(0,b.create)(n,eC((0,b.number)()));if("error"in s)throw new er(s.error,"failed to get slot");return s.result}async getSlotLeader(e){let{commitment:t,config:r}=eP(e),i=this._buildArgs([],t,void 0,r),n=await this._rpcRequest("getSlotLeader",i),s=(0,b.create)(n,eC((0,b.string)()));if("error"in s)throw new er(s.error,"failed to get slot leader");return s.result}async getSlotLeaders(e,t){let r=await this._rpcRequest("getSlotLeaders",[e,t]),i=(0,b.create)(r,eC((0,b.array)(ev)));if("error"in i)throw new er(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){let{context:r,value:i}
8=await this.getSignatureStatuses([e],t);return M(1===i.length),{context:r,value:i[0]}}async getSignatureStatuses(e,t){let r=[e];t&&r.push(t);let i=await this._rpcRequest("getSignatureStatuses",r),n=(0,b.create)(i,tw);if("error"in n)throw new er(n.error,"failed to get signature status");return n.result}async getTransactionCount(e){let{commitment:t,config:r}=eP(e),i=this._buildArgs([],t,void 0,r),n=await this._rpcRequest("getTransactionCount",i),s=(0,b.create)(n,eC((0,b.number)()));if("error"in s)throw new er(s.error,"failed to get transaction count");return s.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",t),i=(0,b.create)(r,eV);if("error"in i)throw new er(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,r){let{commitment:i,config:n}=eP(r),s=this._buildArgs([e.map(e=>e.toBase58())],i,void 0,{...n,epoch:null!=t?t:n?.epoch}),a=await this._rpcRequest("getInflationReward",s),o=(0,b.create)(a,ez);if("error"in o)throw new er(o.error,"failed to get inflation reward");return o.result}async getInflationRate(){let e=await this._rpcRequest("getInflationRate",[]),t=(0,b.create)(e,eG);if("error"in t)throw new er(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){let{commitment:t,config:r}=eP(e),i=this._buildArgs([],t,void 0,r),n=await this._rpcRequest("getEpochInfo",i),s=(0,b.create)(n,eZ);if("error"in s)throw new er(s.error,"failed to get epoch info");return s.result}async getEpochSchedule(){let e=await this._rpcRequest("getEpochSchedule",[]),t=(0,b.create)(e,eY);if("error"in t)throw new er(t.error,"failed to get epoch schedule");let r=t.result;return new ek(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=(0,b.create)(e,eQ);if("error"in t)throw new er(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){let r=this._buildArgs([e],t),i=await this._rpcRequest("getMinimumBalanceForRentExemption",r),n=(0,b.create)(i,tS);return"error"in n?(console.warn("Unable to fetch minimum balance for rent exemption"),0):n.result}async getRecentBlockhashAndContext(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getRecentBlockhash",t),i=(0,b.create)(r,tV);if("error"in i)throw new er(i.error,"failed to get recent blockhash");return i.result}async getRecentPerformanceSamples(e){let t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=(0,b.create)(t,tY);if("error"in r)throw new er(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,t){let r=this._buildArgs([e],t),i=await this._rpcRequest("getFeeCalculatorForBlockhash",r),n=(0,b.create)(i,tQ);if("error"in n)throw new er(n.error,"failed to get fee calculator");let{context:s,value:a}=n.result;return{context:s,value:null!==a?a.feeCalculator:null}}async getFeeForMessage(e,t){let r=x(e.serialize()).toString("base64"),i=this._buildArgs([r],t),n=await this._rpcRequest("getFeeForMessage",i),s=(0,b.create)(n,eW((0,b.nullable)((0,b.number)())));if("error"in s)throw new er(s.error,"failed to get fee for message");if(null===s.result)throw Error("invalid blockhash");return s.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),r=t?.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),n=(0,b.create)(i,eX);if("error"in n)throw new er(n.error,"failed to get recent prioritization fees");return n.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:r}=eP(e),i=this._buildArgs([],t,void 0,r),n=await this._rpcRequest("getLatestBlockhash",i),s=(0,b.create)(n,tG);if("error"in s)throw new er(s.error,"failed to get latest blockhash");return s.result}
8async isBlockhashValid(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgs([e],r,void 0,i),s=await this._rpcRequest("isBlockhashValid",n),a=(0,b.create)(s,tX);if("error"in a)throw new er(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=await this._rpcRequest("getVersion",[]),t=(0,b.create)(e,eC(eF));if("error"in t)throw new er(t.error,"failed to get version");return t.result}async getGenesisHash(){let e=await this._rpcRequest("getGenesisHash",[]),t=(0,b.create)(e,eC((0,b.string)()));if("error"in t)throw new er(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgsAtLeastConfirmed([e],r,void 0,i),s=await this._rpcRequest("getBlock",n);try{switch(i?.transactionDetails){case"accounts":{let e=(0,b.create)(s,tM);if("error"in e)throw e.error;return e.result}case"none":{let e=(0,b.create)(s,tN);if("error"in e)throw e.error;return e.result}default:{let e=(0,b.create)(s,tK);if("error"in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:r})=>({meta:t,transaction:{...e,message:eL(r,e.message)},version:r}))}:null}}}catch(e){throw new er(e,"failed to get confirmed block")}}async getParsedBlock(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),s=await this._rpcRequest("getBlock",n);try{switch(i?.transactionDetails){case"accounts":{let e=(0,b.create)(s,tU);if("error"in e)throw e.error;return e.result}case"none":{let e=(0,b.create)(s,t$);if("error"in e)throw e.error;return e.result}default:{let e=(0,b.create)(s,tJ);if("error"in e)throw e.error;return e.result}}}catch(e){throw new er(e,"failed to get block")}}async getBlockProduction(e){let t,r;if("string"==typeof e)r=e;
8else if(e){let{commitment:i,...n}=e;r=i,t=n}let i=this._buildArgs([],r,"base64",t),n=await this._rpcRequest("getBlockProduction",i),s=(0,b.create)(n,ej);if("error"in s)throw new er(s.error,"failed to get block production information");return s.result}async getTransaction(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgsAtLeastConfirmed([e],r,void 0,i),s=await this._rpcRequest("getTransaction",n),a=(0,b.create)(s,tD);if("error"in a)throw new er(a.error,"failed to get transaction");let o=a.result;return o?{...o,transaction:{...o.transaction,message:eL(o.version,o.transaction.message)}}:o}async getParsedTransaction(e,t){let{commitment:r,config:i}=eP(t),n=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),s=await this._rpcRequest("getTransaction",n),a=(0,b.create)(s,tj);if("error"in a)throw new er(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){let{commitment:r,config:i}=eP(t),n=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=(0,b.create)(e,tj);if("error"in t)throw new er(t.error,"failed to get transactions");return t.result})}async getTransactions(e,t){let{commitment:r,config:i}=eP(t),n=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,void 0,i)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=(0,b.create)(e,tD);if("error"in t)throw new er(t.error,"failed to get transactions");let r=t.result;return r?{...r,transaction:{...r.transaction,message:eL(r.version,r.transaction.message)}}:r})}async getConfirmedBlock(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getConfirmedBlock",r),n=(0,b.create)(i,tH);if("error"in n)throw new er(n.error,"failed to get confirmed block");let s=n.result;if(!s)throw Error("Confirmed block "+e+" not found");let a={...s,transactions:s.transactions.map(({transaction:e,meta:t})=>{let r=new F(e.message);return{meta:t,transaction:{...e,message:r}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:X.populate(e.message,e.signatures)}))}}async getBlocks(e,t,r){let i=this._buildArgsAtLeastConfirmed(void 0!==t?[e,t]:[e],r),n=await this._rpcRequest("getBlocks",i),s=(0,b.create)(n,eC((0,b.array)((0,b.number)())));if("error"in s)throw new er(s.error,"failed to get blocks");return s.result}async getBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),n=(0,b.create)(i,tF);if("error"in n)throw new er(n.error,"failed to get block");let s=n.result;if(!s)throw Error("Block "+e+" not found");return s}async getConfirmedBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getConfirmedBlock",r),n=(0,b.create)(i,tF);if("error"in n)throw new er(n.error,"failed to get confirmed block");let s=n.result;if(!s)throw Error("Confirmed block "+e+" not found");return s}async getConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getConfirmedTransaction",r),n=(0,b.create)(i,tD);if("error"in n)throw new er(n.error,"failed to get transaction");let s=n.result;if(!s)return s;let a=new F(s.transaction.message),o=s.transaction.signatures;return{...s,transaction:X.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getConfirmedTransaction",r),n=(0,b.create)(i,tj);if("error"in n)throw new er(n.error,"failed to get confirmed transaction");return n.result}async getParsedConfirmedTransactions(e,t){let r=e.map(e=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([e],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(e=>{let t=(0,b.create)(e,tj);if("error"in t)throw new er(t.error,"failed to get confirmed transactions");return t.result})}async getConfirmedSignaturesForAddress(e,t,r){let i={},n=await this.getFirstAvailableBlock();for(;!("until"in i)&&!(--t<=0)&&!(t<n);)try{let e=await this.getConfirmedBlockSignatures(t,"finalized");
vendor: 4,169 bytes, line 8
8e.signatures.length>0&&(i.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}let s=await this.getSlot("finalized");for(;!("before"in i)&&!(++r>s);)try{let e=await this.getConfirmedBlockSignatures(r);e.signatures.length>0&&(i.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,i)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,r){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),n=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),s=(0,b.create)(n,tn);if("error"in s)throw new er(s.error,"failed to get confirmed signatures for address");return s.result}async getSignaturesForAddress(e,t,r){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),n=await this._rpcRequest("getSignaturesForAddress",i),s=(0,b.create)(n,ts);if("error"in s)throw new er(s.error,"failed to get signatures for address");return s.result}async getAddressLookupTable(e,t){let{context:r,value:i}=await this.getAccountInfoAndContext(e,t),n=null;return null!==i&&(n=new e_({key:e,state:e_.deserialize(i.data)})),{context:r,value:n}}async getNonceAndContext(e,t){let{context:r,value:i}=await this.getAccountInfoAndContext(e,t),n=null;return null!==i&&(n=el.fromAccountData(i.data)),{context:r,value:n}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error("failed to get nonce for account "+e.toBase58()+": "+t)})}async requestAirdrop(e,t){let r=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),i=(0,b.create)(r,t0);if("error"in i)throw new er(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await en(100);let e=Date.now()-this._blockhashInfo.lastFetch;if(null!==this._blockhashInfo.latestBlockhash&&!(e>=3e4))return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash("finalized");if(r!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await en(200)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:r}=eP(e),i=this._buildArgs([],t,"base64",r),n=await this._rpcRequest("getStakeMinimumDelegation",i),s=(0,b.create)(n,eW((0,b.number)()));if("error"in s)throw new er(s.error,"failed to get stake minimum delegation");return s.result}async simulateTransaction(e,t,r){let i;if("message"in e){let i=e.serialize(),n=s.Buffer.from(i).toString("base64");if(Array.isArray(t)||void 0!==r)throw Error("Invalid arguments");let a=t||{};a.encoding="base64","commitment"in a||(a.commitment=this.commitment);let o=await this._rpcRequest("simulateTransaction",[n,a]),c=(0,b.create)(o,eD);if("error"in c)throw Error("failed to simulate transaction: "+c.error.message);return c.result}if(e instanceof X?((i=new X).feePayer=e.feePayer,i.instructions=e.instructions,i.nonceInfo=e.nonceInfo,i.signatures=e.signatures):(i=X.populate(e))._message=i._json=void 0,void 0!==t&&!Array.isArray(t))throw Error("Invalid arguments");if(i.nonceInfo&&t)i.sign(...t);else{let e=this._disableBlockhashCaching;for(;;){let r=await this._blockhashWithExpiryBlockHeight(e);if(i.lastValidBlockHeight=r.lastValidBlockHeight,i.recentBlockhash=r.blockhash,!t)break;if(i.sign(...t),!i.signature)throw Error("!signature");let n=i.signature.toString("base64");if(this._blockhashInfo.simulatedSignatures.includes(n)||this._blockhashInfo.transactionSignatures.includes(n))e=!0;else{this._blockhashInfo.simulatedSignatures.push(n);break}}}let n=i._compile(),a=n.serialize(),o=i._serialize(a).toString("base64"),c={encoding:"base64",commitment:this.commitment};if(r){let e=(Array.isArray(r)?r:n.nonProgramIds()).map(e=>
8e.toBase58());c.accounts={encoding:"base64",addresses:e}}t&&(c.sigVerify=!0);let l=await this._rpcRequest("simulateTransaction",[o,c]),u=(0,b.create)(l,eD);if("error"in u){let e;if("data"in u.error&&(e=u.error.data.logs)&&Array.isArray(e)){let t="\n    ",r=t+e.join(t);console.error(u.error.message,r)}throw new et({action:"simulate",signature:"",transactionMessage:u.error.message,logs:e})}return u.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw Error("Invalid arguments");let r=e.serialize();return await this.sendRawTransaction(r,t)}if(void 0===t||!Array.isArray(t))throw Error("Invalid arguments");if(e.nonceInfo)e.sign(...t);else{let r=this._disableBlockhashCaching;for(;;){let i=await this._blockhashWithExpiryBlockHeight(r);if(e.lastValidBlockHeight=i.lastValidBlockHeight,e.recentBlockhash=i.blockhash,e.sign(...t),!e.signature)throw Error("!signature");let n=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(n))r=!0;else{this._blockhashInfo.transactionSignatures.push(n);break}}}let i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){let r=x(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){let r={encoding:"base64"},i=t&&t.skipPreflight,n=!0===i?"processed":t&&t.preflightCommitment||this.commitment;t&&null!=t.maxRetries&&(r.maxRetries=t.maxRetries),t&&null!=t.minContextSlot&&(r.minContextSlot=t.minContextSlot),i&&(r.skipPreflight=i),n&&(r.preflightCommitment=n);let s=await this._rpcRequest("sendTransaction",[e,r]),a=(0,b.create)(s,t1);if("error"in a){let e;throw"data"in a.error&&(e=a.error.data.logs),new et({action:i?"send":"simulate",signature:"",transactionMessage:a.error.message,logs:e})}return a.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),1e3===e){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:"pending"})})}_setSubscription(e,t){let r=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,r!==t.state){let r=this._subscriptionStateChangeCallbacksByHash[e];r&&r.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let r=this._subscriptionHashByClientSubscriptionId[e];if(null==r)return()=>{};let i=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return i.add(t),()=>{i.delete(t),0===i.size&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(0===Object.keys(this._subscriptionsByHash).length){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}},500));return}if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{let r=this._subscriptionsByHash[e];if(void 0!==r)switch(r.state){case"pending":case"unsubscribed":if(0===r.callbacks.size){delete this._subscriptionsByHash[e],"unsubscribed"===r.state&&delete this._subscriptionCallbacksByServerSubscriptionId[r.serverSubscriptionId],await this._updateSubscriptions();return}await (async()=>{let{args:i,method:n}=r;try{this._setSubscription(e,{...r,state:"subscribing"});let t=await this._rpcWebSocket.call(n,i);this._setSubscription(e,{...r,serverSubscriptionId:t,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[t]=r.callbacks,await this._updateSubscriptions()}catch(s){if(s instanceof Error&&console.error(`${n} error for argument`,i,s.message),!t())return;this._setSubscription(e,{...r,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":0===r.callbacks.size&&await (async()=>{let{serverSubscriptionId:i,unsubscribeMethod:n}=r;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(e,{...r,state:"unsubscribing"}),this._setSubscription(e,{...r,state:"unsubscribing"});try{await this._rpcWebSocket.call(n,[i])}catch(i){if(i instanceof Error&&console.error(`${n} error:`,i.message),!t())return;this._setSubscription(e,{...r,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(e,{...r,state:"unsubscribed"}),await this._updateSubscriptions()})()}}))}_handleServerNotification(e,t){let r=this._subscriptionCallbacksByServerSubscriptionId[e];
vendor: 4,116 bytes, line 8
8void 0!==r&&r.forEach(e=>{try{e(...t)}catch(e){console.error(e)}})}_wsOnAccountNotification(e){let{result:t,subscription:r}=(0,b.create)(e,ta);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){let r=this._nextClientSubscriptionId++,i=ey([e.method,t]),n=this._subscriptionsByHash[i];return void 0===n?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:n.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];let t=this._subscriptionsByHash[i];M(void 0!==t,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){let i=this._buildArgs([e.toBase58()],r||this._commitment||"finalized","base64");return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},i)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){let{result:t,subscription:r}=(0,b.create)(e,tc);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,i){let n=this._buildArgs([e.toBase58()],r||this._commitment||"finalized","base64",i?{filters:i}:void 0);return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},n)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){let i=this._buildArgs(["object"==typeof e?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){let{result:t,subscription:r}=(0,b.create)(e,t2);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:r}=(0,b.create)(e,tu);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:r}=(0,b.create)(e,th);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){let r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,i){let n=t||this._commitment;if(n||r||i){let t={};r&&(t.encoding=r),n&&(t.commitment=n),i&&(t=Object.assign(t,i)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,r,i){let n=t||this._commitment;if(n&&!["confirmed","finalized"].includes(n))throw Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,r,i)}_wsOnSignatureNotification(e){let{result:t,subscription:r}=(0,b.create)(e,tg);"receivedSignature"!==t.value&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,"receivedSignature"===t.value?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){let i=this._buildArgs([e],r||this._commitment||"finalized"),n=this._makeSubscription({callback:(e,r)=>{if("status"===e.type){t(e.result,r);try{this.removeSignatureListener(n)}catch(e){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return n}
8onSignatureWithOptions(e,t,r){let{commitment:i,...n}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},s=this._buildArgs([e],i,void 0,n),a=this._makeSubscription({callback:(e,r)=>{t(e,r);try{this.removeSignatureListener(a)}catch(e){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){let{result:t,subscription:r}=(0,b.create)(e,tp);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class t6{constructor(e){this._keypair=void 0,this._keypair=e??_()}static generate(){return new t6(_())}static fromSecretKey(e,t){if(64!==e.byteLength)throw Error("bad secret key size");let r=e.slice(32,64);if(!t||!t.skipValidation){let t=I(e.slice(0,32));for(let e=0;e<32;e++)if(r[e]!==t[e])throw Error("provided secretKey is invalid")}return new t6({publicKey:r,secretKey:e})}static fromSeed(e){let t=I(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new t6({publicKey:t,secretKey:r})}get publicKey(){return new C(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}let t4=Object.freeze({CreateLookupTable:{index:0,layout:g.n_([g.Jq("instruction"),ed("recentSlot"),g.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:g.n_([g.Jq("instruction")])},ExtendLookupTable:{index:2,layout:g.n_([g.Jq("instruction"),ed(),g.A9(z(),g.cv(g.Jq(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:g.n_([g.Jq("instruction")])},CloseLookupTable:{index:4,layout:g.n_([g.Jq("instruction")])}});class t9{constructor(){}static createLookupTable(e){let[t,r]=C.findProgramAddressSync([e.authority.toBuffer(),(0,p.k$)(BigInt(e.recentSlot),8)],this.programId),i=es(t4.CreateLookupTable,{recentSlot:BigInt(e.recentSlot),bumpSeed:r}),n=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:eg.programId,isSigner:!1,isWritable:!1}];return[new G({programId:this.programId,keys:n,data:i}),t]}static freezeLookupTable(e){let t=es(t4.FreezeLookupTable),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new G({programId:this.programId,keys:r,data:t})}static extendLookupTable(e){let t=es(t4.ExtendLookupTable,{addresses:e.addresses.map(e=>e.toBytes())}),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&r.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:eg.programId,isSigner:!1,isWritable:!1}),new G({programId:this.programId,keys:r,data:t})}static deactivateLookupTable(e){let t=es(t4.DeactivateLookupTable),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new G({programId:this.programId,keys:r,data:t})}static closeLookupTable(e){let t=es(t4.CloseLookupTable),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new G({programId:this.programId,keys:r,data:t})}}t9.programId=new C("AddressLookupTab1e1111111111111111111111111");let t7=Object.freeze({RequestUnits:{index:0,layout:g.n_([g.u8("instruction"),g.Jq("units"),g.Jq("additionalFee")])},RequestHeapFrame:{index:1,layout:g.n_([g.u8("instruction"),g.Jq("bytes")])},SetComputeUnitLimit:{index:2,layout:g.n_([g.u8("instruction"),g.Jq("units")])},SetComputeUnitPrice:{index:3,layout:g.n_([g.u8("instruction"),ed("microLamports")])}});class re{constructor(){}static requestUnits(e){let t=es(t7.RequestUnits,e);return new G({keys:[],programId:this.programId,data:t})}static requestHeapFrame(e){let t=es(t7.RequestHeapFrame,e);return new G({keys:[],programId:this.programId,data:t})}static setComputeUnitLimit(e){let t=es(t7.SetComputeUnitLimit,e);return new G({keys:[],programId:this.programId,data:t})}static setComputeUnitPrice(e){let t=es(t7.SetComputeUnitPrice,{microLamports:BigInt(e.microLamports)});return new G({keys:[],programId:this.programId,data:t})}}re.programId=new C("ComputeBudget111111111111111111111111111111");
8let rt=g.n_([g.u8("numSignatures"),g.u8("padding"),g.KB("signatureOffset"),g.KB("signatureInstructionIndex"),g.KB("publicKeyOffset"),g.KB("publicKeyInstructionIndex"),g.KB("messageDataOffset"),g.KB("messageDataSize"),g.KB("messageInstructionIndex")]);class rr{constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:i,instructionIndex:n}=e;M(32===t.length,`Public Key must be 32 bytes but received ${t.length} bytes`),M(64===i.length,`Signature must be 64 bytes but received ${i.length} bytes`);let a=rt.span,o=a+t.length,c=o+i.length,l=s.Buffer.alloc(c+r.length),u=null==n?65535:n;return rt.encode({numSignatures:1,padding:0,signatureOffset:o,signatureInstructionIndex:u,publicKeyOffset:a,publicKeyInstructionIndex:u,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:u},l),l.fill(t,a),l.fill(i,o),l.fill(r,c),new G({keys:[],programId:rr.programId,data:l})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:i}=e;M(64===t.length,`Private key must be 64 bytes but received ${t.length} bytes`);try{let e=t6.fromSecretKey(t),n=e.publicKey.toBytes(),s=v(r,e.secretKey);return this.createInstructionWithPublicKey({publicKey:n,message:r,signature:s,instructionIndex:i})}catch(e){throw Error(`Error creating instruction; ${e}`)}}}rr.programId=new C("Ed25519SigVerify111111111111111111111111111");let ri=(e,t)=>{let r=S.kA.sign(e,t);return[r.toCompactRawBytes(),r.recovery]};S.kA.utils.isValidPrivateKey;let rn=S.kA.getPublicKey,rs=g.n_([g.u8("numSignatures"),g.KB("signatureOffset"),g.u8("signatureInstructionIndex"),g.KB("ethAddressOffset"),g.u8("ethAddressInstructionIndex"),g.KB("messageDataOffset"),g.KB("messageDataSize"),g.u8("messageInstructionIndex"),g.Ik(20,"ethAddress"),g.Ik(64,"signature"),g.u8("recoveryId")]);class ra{constructor(){}static publicKeyToEthAddress(e){M(64===e.length,`Public key must be 64 bytes but received ${e.length} bytes`);try{return s.Buffer.from((0,w.fr)(x(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:i,recoveryId:n,instructionIndex:s}=e;return ra.createInstructionWithEthAddress({ethAddress:ra.publicKeyToEthAddress(t),message:r,signature:i,recoveryId:n,instructionIndex:s})}static createInstructionWithEthAddress(e){let t;let{ethAddress:r,message:i,signature:n,recoveryId:a,instructionIndex:o=0}=e;M(20===(t="string"==typeof r?r.startsWith("0x")?s.Buffer.from(r.substr(2),"hex"):s.Buffer.from(r,"hex"):r).length,`Address must be 20 bytes but received ${t.length} bytes`);let c=12+t.length,l=c+n.length+1,u=s.Buffer.alloc(rs.span+i.length);return rs.encode({numSignatures:1,signatureOffset:c,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:l,messageDataSize:i.length,messageInstructionIndex:o,signature:x(n),ethAddress:x(t),recoveryId:a},u),u.fill(x(i),rs.span),new G({keys:[],programId:ra.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:i}=e;M(32===t.length,`Private key must be 32 bytes but received ${t.length} bytes`);try{let e=x(t),n=rn(e,!1).slice(1),a=s.Buffer.from((0,w.fr)(x(r))),[o,c]=ri(a,e);return this.createInstructionWithPublicKey({publicKey:n,message:r,signature:o,recoveryId:c,instructionIndex:i})}catch(e){throw Error(`Error creating instruction; ${e}`)}}}ra.programId=new C("KeccakSecp256k11111111111111111111111111111");let ro=new C("StakeConfig11111111111111111111111111111111");class rc{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}rc.default=new rc(0,0,C.default);let rl=Object.freeze({Initialize:{index:0,layout:g.n_([g.Jq("instruction"),((e="authorized")=>g.n_([z("staker"),z("withdrawer")],e))(),((e="lockup")=>g.n_([g.gM("unixTimestamp"),g.gM("epoch"),z("custodian")],e))()])},Authorize:{index:1,layout:g.n_([g.Jq("instruction"),z("newAuthorized"),g.Jq("stakeAuthorizationType")])},Delegate:{index:2,layout:g.n_([g.Jq("instruction")])},Split:{index:3,layout:g.n_([g.Jq("instruction"),g.gM("lamports")])},Withdraw:{index:4,layout:g.n_([g.Jq("instruction"),g.gM("lamports")])},Deactivate:{index:5,layout:g.n_([g.Jq("instruction")])},Merge:{index:7,layout:g.n_([g.Jq("instruction")])},AuthorizeWithSeed:{index:8,layout:g.n_([g.Jq("instruction"),z("newAuthorized"),g.Jq
vendor: 4,803 bytes, line 8
8("stakeAuthorizationType"),O("authoritySeed"),z("authorityOwner")])}});Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class ru{constructor(){}static initialize(e){let{stakePubkey:t,authorized:r,lockup:i}=e,n=i||rc.default,s=es(rl.Initialize,{authorized:{staker:x(r.staker.toBuffer()),withdrawer:x(r.withdrawer.toBuffer())},lockup:{unixTimestamp:n.unixTimestamp,epoch:n.epoch,custodian:x(n.custodian.toBuffer())}});return new G({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!1}],programId:this.programId,data:s})}static createAccountWithSeed(e){let t=new X;t.add(eg.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:r,authorized:i,lockup:n}=e;return t.add(this.initialize({stakePubkey:r,authorized:i,lockup:n}))}static createAccount(e){let t=new X;t.add(eg.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:r,authorized:i,lockup:n}=e;return t.add(this.initialize({stakePubkey:r,authorized:i,lockup:n}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:r,votePubkey:i}=e,n=es(rl.Delegate);return new X().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:ee,isSigner:!1,isWritable:!1},{pubkey:ro,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static authorize(e){let{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:i,stakeAuthorizationType:n,custodianPubkey:s}=e,a=es(rl.Authorize,{newAuthorized:x(i.toBuffer()),stakeAuthorizationType:n.index}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return s&&o.push({pubkey:s,isSigner:!0,isWritable:!1}),new X().add({keys:o,programId:this.programId,data:a})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:r,authoritySeed:i,authorityOwner:n,newAuthorizedPubkey:s,stakeAuthorizationType:a,custodianPubkey:o}=e,c=es(rl.AuthorizeWithSeed,{newAuthorized:x(s.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:i,authorityOwner:x(n.toBuffer())}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Z,isSigner:!1,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new X().add({keys:l,programId:this.programId,data:c})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:i,lamports:n}=e,s=es(rl.Split,{lamports:n});return new G({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static split(e,t){let r=new X;return r.add(eg.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:r,authorizedPubkey:i,splitStakePubkey:n,basePubkey:s,seed:a,lamports:o}=e,c=new X;return c.add(eg.allocate({accountPubkey:n,basePubkey:s,seed:a,space:this.space,programId:this.programId})),t&&t>0&&c.add(eg.transfer({fromPubkey:e.authorizedPubkey,toPubkey:n,lamports:t})),c.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:i,splitStakePubkey:n,lamports:o}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:i}=e,n=es(rl.Merge);return new X().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:ee,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:r,toPubkey:i,lamports:n,custodianPubkey:s}=e,a=es(rl.Withdraw,{lamports:n}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:ee,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return s&&o.push({pubkey:s,isSigner:!0,isWritable:!1}),new X().add({keys:o,programId:this.programId,data:a})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:r}=e,i=es(rl.Deactivate);return new X().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}ru.programId=new C("Stake11111111111111111111111111111111111111"),ru.space=200;let rd=Object.freeze({InitializeAccount:{index:0,layout:g.n_([g.Jq("instruction"),((e="voteInit")=>g.n_([z("nodePubkey"),z("authorizedVoter"),z("authorizedWithdrawer"),g.u8("commission")],e))()])},Authorize:{index:1,layout:g.n_([g.Jq("instruction"),z("newAuthorized"),g.Jq
8("voteAuthorizationType")])},Withdraw:{index:3,layout:g.n_([g.Jq("instruction"),g.gM("lamports")])},UpdateValidatorIdentity:{index:4,layout:g.n_([g.Jq("instruction")])},AuthorizeWithSeed:{index:10,layout:g.n_([g.Jq("instruction"),((e="voteAuthorizeWithSeedArgs")=>g.n_([g.Jq("voteAuthorizationType"),z("currentAuthorityDerivedKeyOwnerPubkey"),O("currentAuthorityDerivedKeySeed"),z("newAuthorized")],e))()])}});Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class rh{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:r,voteInit:i}=e,n=es(rd.InitializeAccount,{voteInit:{nodePubkey:x(i.nodePubkey.toBuffer()),authorizedVoter:x(i.authorizedVoter.toBuffer()),authorizedWithdrawer:x(i.authorizedWithdrawer.toBuffer()),commission:i.commission}});return new G({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static createAccount(e){let t=new X;return t.add(eg.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:i,voteAuthorizationType:n}=e,s=es(rd.Authorize,{newAuthorized:x(i.toBuffer()),voteAuthorizationType:n.index});return new X().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:n,voteAuthorizationType:s,votePubkey:a}=e,o=es(rd.AuthorizeWithSeed,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:x(r.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:x(n.toBuffer()),voteAuthorizationType:s.index}});return new X().add({keys:[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:i,toPubkey:n}=e,s=es(rd.Withdraw,{lamports:i});return new X().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw Error("Withdraw will leave vote account with insufficient funds.");return rh.withdraw(e)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:i}=e,n=es(rd.UpdateValidatorIdentity);return new X().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}}async function rg(e,t,r,i){let n,s;r&&Object.prototype.hasOwnProperty.call(r,"lastValidBlockHeight")?(n=r,s=i):r&&Object.prototype.hasOwnProperty.call(r,"nonceValue")?(n=r,s=i):s=r;let a=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},o=await e.sendRawTransaction(t,a),c=s&&s.commitment,l=n?e.confirmTransaction(n,c):e.confirmTransaction(o,c),u=(await l).value;if(u.err){if(null!=o)throw new et({action:a?.skipPreflight?"send":"simulate",signature:o,transactionMessage:`Status: (${JSON.stringify(u)})`});throw Error(`Raw transaction ${o} failed (${JSON.stringify(u)})`)}return o}rh.programId=new C("Vote111111111111111111111111111111111111111"),rh.space=3762,new C("Va1idator1nfo111111111111111111111111111111"),(0,b.type)({name:(0,b.string)(),website:(0,b.optional)((0,b.string)()),details:(0,b.optional)((0,b.string)()),keybaseUsername:(0,b.optional)((0,b.string)())}),new C("Vote111111111111111111111111111111111111111"),g.n_([z("nodePubkey"),z("authorizedWithdrawer"),g.u8("commission"),g._O(),g.A9(g.n_([g._O("slot"),g.Jq("confirmationCount")]),g.cv(g.Jq(),-8),"votes"),g.u8("rootSlotValid"),g._O("rootSlot"),g._O(),g.A9(g.n_([g._O("epoch"),z("authorizedVoter")]),g.cv(g.Jq(),-8),"authorizedVoters"),g.n_([g.A9(g.n_([z("authorizedPubkey"),g._O("epochOfLastAuthorizedSwitch"),g._O("targetEpoch")]),32,"buf"),g._O("idx"),g.u8("isEmpty")],"priorVoters"),g._O(),g.A9(g.n_([g._O("epoch"),g._O("credits"),g._O("prevCredits")]),g.cv(g.Jq(),-8),"epochCredits"),g.n_([g._O("slot"),g._O("timestamp")],"lastTimestamp")]);let rp=1e9}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.