1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1469],{95431:(e,t,r)=>{r.r(t),r.d(t,{Account:()=>x,AddressLookupTableAccount:()=>ej,AddressLookupTableInstruction:()=>rS,AddressLookupTableProgram:()=>rw,Authorized:()=>rN,BLOCKHASH_CACHE_TIMEOUT_MS:()=>e$,BPF_LOADER_DEPRECATED_PROGRAM_ID:()=>L,BPF_LOADER_PROGRAM_ID:()=>eO,BpfLoader:()=>ex,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:()=>r_,ComputeBudgetInstruction:()=>rI,ComputeBudgetProgram:()=>rA,Connection:()=>rb,Ed25519Program:()=>rP,Enum:()=>T,EpochSchedule:()=>ez,FeeCalculatorLayout:()=>eA,Keypair:()=>rf,LAMPORTS_PER_SOL:()=>rQ,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:()=>rk,Loader:()=>eC,Lockup:()=>rR,MAX_SEED_LENGTH:()=>N,Message:()=>Q,MessageAccountKeys:()=>U,MessageV0:()=>ee,NONCE_ACCOUNT_LENGTH:()=>eP,NonceAccount:()=>eE,PACKET_DATA_SIZE:()=>K,PUBLIC_KEY_LENGTH:()=>R,PublicKey:()=>O,SIGNATURE_LENGTH_IN_BYTES:()=>q,SOLANA_SCHEMA:()=>W,STAKE_CONFIG_ID:()=>rW,STAKE_INSTRUCTION_LAYOUTS:()=>rO,SYSTEM_INSTRUCTION_LAYOUTS:()=>eW,SYSVAR_CLOCK_PUBKEY:()=>ec,SYSVAR_EPOCH_SCHEDULE_PUBKEY:()=>eu,SYSVAR_INSTRUCTIONS_PUBKEY:()=>el,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:()=>ed,SYSVAR_RENT_PUBKEY:()=>eh,SYSVAR_REWARDS_PUBKEY:()=>eg,SYSVAR_SLOT_HASHES_PUBKEY:()=>ep,SYSVAR_SLOT_HISTORY_PUBKEY:()=>em,SYSVAR_STAKE_HISTORY_PUBKEY:()=>ey,Secp256k1Program:()=>rT,SendTransactionError:()=>eb,SolanaJSONRPCError:()=>ek,SolanaJSONRPCErrorCode:()=>ef,StakeAuthorizationLayout:()=>rx,StakeInstruction:()=>rC,StakeProgram:()=>rL,Struct:()=>B,SystemInstruction:()=>eT,SystemProgram:()=>eN,Transaction:()=>en,TransactionExpiredBlockheightExceededError:()=>Y,TransactionExpiredNonceInvalidError:()=>M,TransactionExpiredTimeoutError:()=>j,TransactionInstruction:()=>es,TransactionMessage:()=>eo,TransactionStatus:()=>er,VALIDATOR_INFO_KEY:()=>rM,VERSION_PREFIX_MASK:()=>z,VOTE_PROGRAM_ID:()=>rD,ValidatorInfo:()=>rV,VersionedMessage:()=>et,VersionedTransaction:()=>ea,VoteAccount:()=>r$,VoteAuthorizationLayout:()=>rY,VoteInit:()=>rK,VoteInstruction:()=>rz,VoteProgram:()=>rj,clusterApiUrl:()=>rX,sendAndConfirmRawTransaction:()=>rZ,sendAndConfirmTransaction:()=>eS});var i,s,n=r(9832),o=r(25901),a=r(38024),c=r.n(a),u=r(16556),l=r.n(u),d=r(97361),h=r(76496),g=r(46452),p=r(55),m=r(83421),y=r(54128),b=r.n(y),f=r(479),k=r(8137),S=r(89400);let w=o.ev.utils.randomPrivateKey,I=()=>{let e=o.ev.utils.randomPrivateKey(),t=_(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),{publicKey:t,secretKey:r}},_=o.ev.getPublicKey;function A(e){try{return o.ev.ExtendedPoint.fromHex(e),!0}catch{return!1}}let v=(e,t)=>o.ev.sign(e,t.slice(0,32)),P=o.ev.verify,E=e=>n.Buffer.isBuffer(e)?e:e instanceof Uint8Array?n.Buffer.from(e.buffer,e.byteOffset,e.byteLength):n.Buffer.from(e);class B{constructor(e){Object.assign(this,e)}encode(){return n.Buffer.from((0,h.serialize)(W,this))}static decode(e){return(0,h.deserialize)(W,this,e)}static decodeUnchecked(e){return(0,h.deserializeUnchecked)(W,this,e)}}class T extends B{constructor(e){if(super(e),this.enum="",1!==Object.keys(e).length)throw Error("Enum can only take single value");Object.keys(e).map(e=>{this.enum=e})}}let W=new Map,N=32,R=32,C=1;class O extends B{constructor(e){if(super({}),this._bn=void 0,void 0!==e._bn)this._bn=e._bn;else{if("string"==typeof e){let t=l().decode(e);if(t.length!=R)throw Error("Invalid public key input");this._bn=new(c())(t)}else this._bn=new(c())(e);if(this._bn.byteLength()>R)throw Error("Invalid public key input")}}static unique(){let e=new O(C);return C+=1,new O(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return l().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(n.Buffer);if(e.length===R)return e;let t=n.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=n.Buffer.concat([e.toBuffer(),n.Buffer.from(t),r.toBuffer()]);return new O((0,d.sc)(i))}static createProgramAddressSync(e,t){let r=n.Buffer.alloc(0);e.forEach(function(e){if(e.length>N)throw TypeError("Max seed length exceeded");r=n.Buffer.concat([r,E(e)])}),r=n.Buffer.concat([r,t.toBuffer(),n.Buffer.from("ProgramDerivedAddress")]);let i=(0,d.sc)(r);if(A(i))throw Error("Invalid seeds, address must fall off the curve");return new O(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r,i=255;for(;0!=i;){try{let s=e.concat(n.Buffer.from([i]));r=this.createProgramAddressSync(s,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 O(e).toBytes())}}O.default=new O("11111111111111111111111111111111"),W.set(O,{kind:"struct",fields:[["_bn","u256"]]});class x{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){let t=E(e);if(64!==e.length)throw Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=E(w()),this._publicKey=E(_(this._secretKey))}get publicKey(){return new O(this._publicKey)}get secretKey(){return n.Buffer.concat([this._secretKey,this._publicKey],64)}}let L=new O("BPFLoader1111111111111111111111111111111111"),K=1232,z=127,q=64;
vendor: 19,385 bytes, line 1
1class Y extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Y.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class j 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(j.prototype,"name",{value:"TransactionExpiredTimeoutError"});class M extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(M.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class U{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];else 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 V=(e="publicKey")=>g.blob(32,e),D=(e="string")=>{let t=g.struct([g.u32("length"),g.u32("lengthPadding"),g.blob(g.offset(g.u32(),-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:n.Buffer.from(e,"utf8")},t,r),t.alloc=e=>g.u32().span+g.u32().span+n.Buffer.from(e,"utf8").length,t};function H(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 $(e,t){let r=t;for(;;){let t=127&r;if(0==(r>>=7)){e.push(t);break}t|=128,e.push(t)}}function F(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},s=i(t);for(let t of(s.isSigner=!0,s.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()];F(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),s=e.filter(([,e])=>!e.isSigner&&!e.isWritable),n={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{F(t.length>0,"Expected at least one writable signer key");let[e]=t[0];F(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[n,[...t.map(([e])=>new O(e)),...r.map(([e])=>new O(e)),...i.map(([e])=>new O(e)),...s.map(([e])=>new O(e))]]}extractTableLookup(e){let[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[i,s]=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:s}]}drainKeysFoundInLookupTable(e,t){let r=[],i=[];for(let[s,n]of this.keyMetaMap.entries())if(t(n)){let t=new O(s),n=e.findIndex(e=>e.equals(t));n>=0&&(F(n<256,"Max lookup table index exceeded"),r.push(n),i.push(t),this.keyMetaMap.delete(s))}return[r,i]}}let G="Reached end of buffer unexpectedly";function X(e){if(0===e.length)throw Error(G);return e.shift()}function Z(e,...t){let[r]=t;if(2===t.length?r+(t[1]??0)>e.length:r>=e.length)throw Error(G);return e.splice(...t)}class Q{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 O(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:l().decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new U(this.staticAccountKeys)}static compile(e){let[t,r]=J.compile(e.instructions,e.payerKey).getMessageComponents(),i=new U(r).compileInstructions(e.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:l().encode(e.data)}));return new Q({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=[];$(t,e);let r=this.instructions.map(e=>{let{accounts:t,programIdIndex:r}=e,i=Array.from(l().decode(e.data)),s=[];$(s,t.length);let o=[];return $(o,i.length),{programIdIndex:r,keyIndicesCount:n.Buffer.from(s),keyIndices:t,dataLength:n.Buffer.from(o),data:i}}),i=[];$(i,r.length);let s=n.Buffer.alloc(K);n.Buffer.from(i).copy(s);let o=i.length;r.forEach(e=>{let t=g.struct([g.u8("programIdIndex"),g.blob(e.keyIndicesCount.length,"keyIndicesCount"),g.seq(g.u8("keyIndex"),e.keyIndices.length,"keyIndices"),g.blob(e.dataLength.length,"dataLength"),g.seq(g.u8("userdatum"),e.data.length,"data")]).encode(e,s,o);o+=t}),s=s.slice(0,o);let a=g.struct([g.blob(1,"numRequiredSignatures"),g.blob(1,"numReadonlySignedAccounts"),g.blob(1,"numReadonlyUnsignedAccounts"),g.blob(t.length,"keyCount"),g.seq(V("key"),e,"keys"),V("recentBlockhash")]),c={numRequiredSignatures:n.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:n.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:n.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:n.Buffer.from(t),keys:this.accountKeys.map(e=>E(e.toBytes())),recentBlockhash:l().decode(this.recentBlockhash)},u=n.Buffer.alloc(2048),d=a.encode(c,u);return s.copy(u,d),u.slice(0,d+s.length)}static from(e){let t=[...e],r=X(t);if(r!==(r&z))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let i=X(t),s=X(t),o=H(t),a=[];for(let e=0;e<o;e++){let e=Z(t,0,R);a.push(new O(n.Buffer.from(e)))}let c=Z(t,0,R),u=H(t),d=[];for(let e=0;e<u;e++){let e=X(t),r=H(t),i=Z(t,0,r),s=H(t),o=Z(t,0,s),a=l().encode(n.Buffer.from(o));d.push({programIdIndex:e,accounts:i,data:a})}return new Q({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:l().encode(n.Buffer.from(c)),accountKeys:a,instructions:d})}}class ee{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 U(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 s of e.addressLookupTableAccounts||[]){let e=t.extractTableLookup(s);if(void 0!==e){let[t,{writable:s,readonly:n}]=e;r.push(t),i.writable.push(...s),i.readonly.push(...n)}}let[s,n]=t.getMessageComponents(),o=new U(n,i).compileInstructions(e.instructions);return new ee({header:s,staticAccountKeys:n,recentBlockhash:e.recentBlockhash,compiledInstructions:o,addressTableLookups:r})}serialize(){let e=[];$(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),r=[];$(r,this.compiledInstructions.length);let i=this.serializeAddressTableLookups(),s=[];$(s,this.addressTableLookups.length);let n=g.struct([g.u8("prefix"),g.struct([g.u8("numRequiredSignatures"),g.u8("numReadonlySignedAccounts"),g.u8("numReadonlyUnsignedAccounts")],"header"),g.blob(e.length,"staticAccountKeysLength"),g.seq(V(),this.staticAccountKeys.length,"staticAccountKeys"),V("recentBlockhash"),g.blob(r.length,"instructionsLength"),g.blob(t.length,"serializedInstructions"),g.blob(s.length,"addressTableLookupsLength"),g.blob(i.length,"serializedAddressTableLookups")]),o=new Uint8Array(K),a=n.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:l().decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},o);return o.slice(0,a)}serializeInstructions(){let e=0,t=new Uint8Array(K);for(let r of this.compiledInstructions){let i=[];$(i,r.accountKeyIndexes.length);let s=[];$(s,r.data.length);let n=g.struct([g.u8("programIdIndex"),g.blob(i.length,"encodedAccountKeyIndexesLength"),g.seq(g.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),g.blob(s.length,"encodedDataLength"),g.blob(r.data.length,"data")]);e+=n.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(K);for(let r of this.addressTableLookups){let i=[];$(i,r.writableIndexes.length);let s=[];$(s,r.readonlyIndexes.length);let n=g.struct([V("accountKey"),g.blob(i.length,"encodedWritableIndexesLength"),g.seq(g.u8(),r.writableIndexes.length,"writableIndexes"),g.blob(s.length,"encodedReadonlyIndexesLength"),g.seq(g.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=n.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],r=X(t),i=r&z;F(r!==i,"Expected versioned message but received legacy message"),F(0===i,`Expected versioned message with version 0 but found version ${i}`);let s={numRequiredSignatures:X(t),numReadonlySignedAccounts:X(t),numReadonlyUnsignedAccounts:X(t)},n=[],o=H(t);for(let e=0;e<o;e++)n.push(new O(Z(t,0,R)));let a=l().encode(Z(t,0,R)),c=H(t),u=[];for(let e=0;e<c;e++){let e=X(t),r=H(t),i=Z(t,0,r),s=H(t),n=new Uint8Array(Z(t,0,s));u.push({programIdIndex:e,accountKeyIndexes:i,data:n})}let d=H(t),h=[];for(let e=0;e<d;e++){let e=new O(Z(t,0,R)),r=H(t),i=Z(t,0,r),s=H(t),n=Z(t,0,s);h.push({accountKey:e,writableIndexes:i,readonlyIndexes:n})}return new ee({header:s,staticAccountKeys:n,recentBlockhash:a,compiledInstructions:u,addressTableLookups:h})}}let et={deserializeMessageVersion(e){let t=e[0],r=t&z;return r===t?"legacy":r},deserialize:e=>{let t=et.deserializeMessageVersion(e);if("legacy"===t)return Q.from(e);if(0===t)return ee.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},er=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",e[e.PROCESSED=1]="PROCESSED",e[e.TIMED_OUT=2]="TIMED_OUT",e[e.NONCE_INVALID=3]="NONCE_INVALID",e}({}),ei=n.Buffer.alloc(q).fill(0);class es{constructor(e){this.keys=void 0,this.programId=void 0,this.data=n.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 en{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 es(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=[],s=[];t.forEach(e=>{e.keys.forEach(e=>{s.push({...e})});let t=e.programId.toString();i.includes(t)||i.push(t)}),i.forEach(e=>{s.push({pubkey:new O(e),isSigner:!1,isWritable:!1})});let n=[];s.forEach(e=>{let t=e.pubkey.toString(),r=n.findIndex(e=>e.pubkey.toString()===t);r>-1?(n[r].isWritable=n[r].isWritable||e.isWritable,n[r].isSigner=n[r].isSigner||e.isSigner):n.push(e)}),n.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 o=n.findIndex(e=>e.pubkey.equals(r));if(o>-1){let[e]=n.splice(o,1);e.isSigner=!0,e.isWritable=!0,n.unshift(e)}else n.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=n.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)n[t].isSigner||(n[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 a=0,c=0,u=0,d=[],h=[];n.forEach(({pubkey:e,isSigner:t,isWritable:r})=>{t?(d.push(e.toString()),a+=1,r||(c+=1)):(h.push(e.toString()),r||(u+=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:l().encode(t)}});return p.forEach(e=>{F(e.programIdIndex>=0),e.accounts.forEach(e=>F(e>=0))}),new Q({header:{numRequiredSignatures:a,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u},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))?e:(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();
1t.forEach(e=>{let t=v(r,e.secretKey);this._addSignature(e.publicKey,E(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){F(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=n.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let r={};for(let{signature:i,publicKey:s}of this.signatures)null===i?t&&(r.missing||=[]).push(s):P(i,e,s.toBytes())||(r.invalid||=[]).push(s);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=[];$(r,t.length);let i=r.length+64*t.length+e.length,s=n.Buffer.alloc(i);return F(t.length<256),n.Buffer.from(r).copy(s,0),t.forEach(({signature:e},t)=>{null!==e&&(F(64===e.length,"signature has invalid length"),n.Buffer.from(e).copy(s,r.length+64*t))}),e.copy(s,r.length+64*t.length),F(s.length<=K,`Transaction too large: ${s.length} > ${K}`),s}get keys(){return F(1===this.instructions.length),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return F(1===this.instructions.length),this.instructions[0].programId}get data(){return F(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e],r=H(t),i=[];for(let e=0;e<r;e++){let e=Z(t,0,q);i.push(l().encode(n.Buffer.from(e)))}return en.populate(Q.from(t),i)}static populate(e,t=[]){let r=new en;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((t,i)=>{let s={signature:t==l().encode(ei)?null:l().decode(t),publicKey:e.accountKeys[i]};r.signatures.push(s)}),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 es({keys:i,programId:e.accountKeys[t.programIdIndex],data:l().decode(t.data)}))}),r._message=e,r._json=r.toJSON(),r}}class eo{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){let{header:r,compiledInstructions:i,recentBlockhash:s}=e,{numRequiredSignatures:n,numReadonlySignedAccounts:o,numReadonlyUnsignedAccounts:a}=r,c=n-o;F(c>0,"Message header is invalid");let u=e.staticAccountKeys.length-n-a;F(u>=0,"Message header is invalid");let l=e.getAccountKeys(t),d=l.get(0);if(void 0===d)throw Error("Failed to decompile message because no account keys were found");let h=[];for(let e of i){let t=[];for(let i of e.accountKeyIndexes){let e,s=l.get(i);if(void 0===s)throw Error(`Failed to find key for account key index ${i}`);e=i<n?i<c:i<l.staticAccountKeys.length?i-n<u:i-l.staticAccountKeys.length<l.accountKeysFromLookups.writable.length,t.push({pubkey:s,isSigner:i<r.numRequiredSignatures,isWritable:e})}let i=l.get(e.programIdIndex);if(void 0===i)throw Error(`Failed to find program id for program id index ${e.programIdIndex}`);h.push(new es({programId:i,data:E(e.data),keys:t}))}return new eo({payerKey:d,instructions:h,recentBlockhash:s})}compileToLegacyMessage(){return Q.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return ee.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class ea{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,void 0!==t)F(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{let t=[];for(let r=0;r<e.header.numRequiredSignatures;r++)t.push(new Uint8Array(q));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];$(t,this.signatures.length);let r=g.struct([g.blob(t.length,"encodedSignaturesLength"),g.seq(((e="signature")=>g.blob(64,e))(),this.signatures.length,"signatures"),g.blob(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=r.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let t=[...e],r=[],i=H(t);for(let e=0;e<i;e++)r.push(new Uint8Array(Z(t,0,q)));return new ea(et.deserialize(new Uint8Array(t)),r)}sign(e){let t=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let i of e){let e=r.findIndex(e=>e.equals(i.publicKey));F(e>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[e]=v(t,i.secretKey)}}addSignature(e,t){F(64===t.byteLength,"Signature must be 64 bytes long");let r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));F(r>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[r]=t}}let ec=new O("SysvarC1ock11111111111111111111111111111111"),eu=new O("SysvarEpochSchedu1e111111111111111111111111"),el=new O("Sysvar1nstructions1111111111111111111111111"),ed=new O("SysvarRecentB1ockHashes11111111111111111111"),eh=new O("SysvarRent111111111111111111111111111111111"),eg=new O("SysvarRewards111111111111111111111111111111"),ep=new O("SysvarS1otHashes111111111111111111111111111"),em=new O("SysvarS1otHistory11111111111111111111111111"),ey=new O("SysvarStakeHistory1111111111111111111111111");
3class eb extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:i}){let s,n=i?`Logs: 4${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";switch(e){case"send":s=`Transaction ${t} resulted in an error. 5${r}. `+n+o;break;case"simulate":s=`Simulation failed. 6Message: ${r}. 7`+n+o;break;default:s=`Unknown action '${e}'`}super(s),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=r,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(null==e||"object"!=typeof e||!("then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,r)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let r=e.meta.logMessages;this.transactionLogs=r,t(r)}else r(Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}let ef={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class ek 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 eS(e,t,r,i){let s,n=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,maxRetries:i.maxRetries,minContextSlot:i.minContextSlot},o=await e.sendTransaction(t,r,n);if(null!=t.recentBlockhash&&null!=t.lastValidBlockHeight)s=(await e.confirmTransaction({abortSignal:i?.abortSignal,signature:o,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},i&&i.commitment)).value;else if(null!=t.minNonceContextSlot&&null!=t.nonceInfo){let{nonceInstruction:r}=t.nonceInfo,n=r.keys[0].pubkey;s=(await e.confirmTransaction({abortSignal:i?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:n,nonceValue:t.nonceInfo.nonce,signature:o},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."),s=(await e.confirmTransaction(o,i&&i.commitment)).value;if(s.err){if(null!=o)throw new eb({action:"send",signature:o,transactionMessage:`Status: (${JSON.stringify(s)})`});throw Error(`Transaction ${o} failed (${JSON.stringify(s)})`)}return o}function ew(e){return new Promise(t=>setTimeout(t,e))}function eI(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},s=0;return t.layout.fields.forEach(e=>{s+=i(e)}),s}(e,t),i=n.Buffer.alloc(r),s=Object.assign({instruction:e.index},t);return e.layout.encode(s,i),i}function e_(e,t){let r;try{r=e.layout.decode(t)}catch(e){throw Error("invalid instruction; "+e)}if(r.instruction!==e.index)throw Error(`invalid instruction; instruction index mismatch ${r.instruction} != ${e.index}`);return r}let eA=g.nu64("lamportsPerSignature"),ev=g.struct([g.u32("version"),g.u32("state"),V("authorizedPubkey"),V("nonce"),g.struct([eA],"feeCalculator")]),eP=ev.span;class eE{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=ev.decode(E(e),0);return new eE({authorizedPubkey:new O(t.authorizedPubkey),nonce:new O(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function eB(e){let t=(0,g.blob)(8,e),r=t.decode.bind(t),i=t.encode.bind(t),s=(0,p.g2)();return t.decode=(e,t)=>{let i=r(e,t);return s.decode(i)},t.encode=(e,t,r)=>i(s.encode(e),t,r),t}class eT{constructor(){}static decodeInstructionType(e){let t;this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data);for(let[e,i]of Object.entries(eW))if(i.index==r){t=e;break}if(!t)throw Error("Instruction type incorrect; not a SystemInstruction");return t}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);
7let{lamports:t,space:r,programId:i}=e_(eW.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:r,programId:new O(i)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t}=e_(eW.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t,seed:r,programId:i}=e_(eW.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:r,programId:new O(i)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{space:t}=e_(eW.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:r,space:i,programId:s}=e_(eW.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new O(t),seed:r,space:i,programId:new O(s)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{programId:t}=e_(eW.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new O(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:r,programId:i}=e_(eW.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new O(t),seed:r,programId:new O(i)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{base:t,seed:r,lamports:i,space:s,programId:n}=e_(eW.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new O(t),seed:r,lamports:i,space:s,programId:new O(n)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{authorized:t}=e_(eW.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new O(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),e_(eW.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=e_(eW.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t}=e_(eW.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new O(t)}}static checkProgramId(e){if(!e.equals(eN.programId))throw Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}let eW=Object.freeze({Create:{index:0,layout:g.struct([g.u32("instruction"),g.ns64("lamports"),g.ns64("space"),V("programId")])},Assign:{index:1,layout:g.struct([g.u32("instruction"),V("programId")])},Transfer:{index:2,layout:g.struct([g.u32("instruction"),eB("lamports")])},CreateWithSeed:{index:3,layout:g.struct([g.u32("instruction"),V("base"),D("seed"),g.ns64("lamports"),g.ns64("space"),V("programId")])},AdvanceNonceAccount:{index:4,layout:g.struct([g.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:g.struct([g.u32("instruction"),V("authorized")])},AuthorizeNonceAccount:{index:7,layout:g.struct([g.u32("instruction"),V("authorized")])},Allocate:{index:8,layout:g.struct([g.u32("instruction"),g.ns64("space")])},AllocateWithSeed:{index:9,layout:g.struct([g.u32("instruction"),V("base"),D("seed"),g.ns64("space"),V("programId")])},AssignWithSeed:{index:10,layout:g.struct([g.u32("instruction"),V("base"),D("seed"),V("programId")])},TransferWithSeed:{index:11,layout:g.struct([g.u32("instruction"),eB("lamports"),D("seed"),V("programId")])},UpgradeNonceAccount:{index:12,layout:g.struct([g.u32("instruction")])}});class eN{constructor(){}static createAccount(e){let t=eI(eW.Create,{lamports:e.lamports,space:e.space,programId:E(e.programId.toBuffer())});return new es({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=eI(eW.TransferWithSeed,{lamports:BigInt(e.lamports),seed:e.seed,programId:E(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=eI(eW.Transfer,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]),new es({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;return"basePubkey"in e?(t=eI(eW.AssignWithSeed,{base:E(e.basePubkey.toBuffer()),seed:e.seed,programId:E(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]):(t=eI(eW.Assign,{programId:E(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]),new es({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=eI(eW.CreateWithSeed,{base:E(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:E(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new es({keys:r,programId:this.programId,data:t})}static createNonceAccount(e){let t=new en;"basePubkey"in e&&"seed"in e?t.add(eN.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:eP,programId:this.programId})):t.add(eN.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:eP,programId:this.programId}));let r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){let t=eI(eW.InitializeNonceAccount,{authorized:E(e.authorizedPubkey.toBuffer())});return new es({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ed,isSigner:!1,isWritable:!1},{pubkey:eh,isSigner:!1,isWritable:!1}],programId:this.programId,data:t})}static nonceAdvance(e){let t=eI(eW.AdvanceNonceAccount);return new es({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ed,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static nonceWithdraw(e){let t=eI(eW.WithdrawNonceAccount,{lamports:e.lamports});return new es({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ed,isSigner:!1,isWritable:!1},{pubkey:eh,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static nonceAuthorize(e){let t=eI(eW.AuthorizeNonceAccount,{authorized:E(e.newAuthorizedPubkey.toBuffer())});return new es({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=eI(eW.AllocateWithSeed,{base:E(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:E(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]):(t=eI(eW.Allocate,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]),new es({keys:r,programId:this.programId,data:t})}}eN.programId=new O("11111111111111111111111111111111");let eR=K-300;class eC{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/eC.chunkSize)+1+1)}static async load(e,t,r,i,s){{let n=await e.getMinimumBalanceForRentExemption(s.length),o=await e.getAccountInfo(r.publicKey,"confirmed"),a=null;if(null!==o){if(o.executable)return console.error("Program load failed, account is already executable"),!1;o.data.length!==s.length&&(a=a||new en).add(eN.allocate({accountPubkey:r.publicKey,space:s.length})),o.owner.equals(i)||(a=a||new en).add(eN.assign({accountPubkey:r.publicKey,programId:i})),o.lamports<n&&(a=a||new en).add(eN.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:n-o.lamports}))}else a=new en().add(eN.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:n>0?n:1,space:s.length,programId:i}));null!==a&&await eS(e,a,[t,r],{commitment:"confirmed"})}let o=g.struct([g.u32("instruction"),g.u32("offset"),g.u32("bytesLength"),g.u32("bytesLengthPadding"),g.seq(g.u8("byte"),g.offset(g.u32(),-8),"bytes")]),a=eC.chunkSize,c=0,u=s,l=[];for(;u.length>0;){let s=u.slice(0,a),d=n.Buffer.alloc(a+16);o.encode({instruction:0,offset:c,bytes:s,bytesLength:0,bytesLengthPadding:0},d);let h=new en().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:d});l.push(eS(e,h,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await ew(250),c+=a,u=u.slice(a)}await Promise.all(l);{let s=g.struct([g.u32("instruction")]),o=n.Buffer.alloc(s.span);s.encode({instruction:1},o);let a=new en().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:eh,isSigner:!1,isWritable:!1}],programId:i,data:o}),c="processed",u=await e.sendTransaction(a,[t,r],{preflightCommitment:c}),{context:l,value:d}=await e.confirmTransaction({signature:u,lastValidBlockHeight:a.lastV
7alidBlockHeight,blockhash:a.recentBlockhash},c);if(d.err)throw Error(`Transaction ${u} failed (${JSON.stringify(d)})`);for(;;){try{if(await e.getSlot({commitment:c})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(200)))}}return!0}}eC.chunkSize=eR;let eO=new O("BPFLoader2111111111111111111111111111111111");class ex{static getMinNumSignatures(e){return eC.getMinNumSignatures(e)}static load(e,t,r,i,s){return eC.load(e,t,r,s,i)}}var eL=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(function(){if(s)return i;s=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};return i=function(r){var i=function r(i,s){var n,o,a,c,u,l,d;if(!0===i)return"true";if(!1===i)return"false";switch(typeof i){case"object":if(null===i)return null;if(i.toJSON&&"function"==typeof i.toJSON)return r(i.toJSON(),s);if("[object Array]"===(d=e.call(i))){for(n=0,a="[",o=i.length-1;n<o;n++)a+=r(i[n],!0)+",";return o>-1&&(a+=r(i[n],!0)),a+"]"}if("[object Object]"!==d)return JSON.stringify(i);for(o=(c=t(i).sort()).length,a="",n=0;n<o;)void 0!==(l=r(i[u=c[n]],!1))&&(a&&(a+=","),a+=JSON.stringify(u)+":"+l),n++;return"{"+a+"}";case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(i);default:return isFinite(i)?i:null}}(r,!1);if(void 0!==i)return""+i}}());function eK(e){let t=0;for(;e>1;)e/=2,t++;return t}class ez{constructor(e,t,r,i,s){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=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){var t;let r=eK(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))-eK(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+eK(32)):this.slotsPerEpoch}}var eq=globalThis.fetch;class eY extends f.vE{constructor(e,t,r){super(e=>{let r=(0,f.kb)(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 ej{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}(eM,e),r=e.length-56;F(r>=0,"lookup table is invalid"),F(r%32==0,"lookup table is invalid");let{addresses:i}=g.struct([g.seq(V(),r/32,"addresses")]).decode(e.slice(56));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:0!==t.authority.length?new O(t.authority[0]):void 0,addresses:i.map(e=>new O(e))}}}let eM={index:1,layout:g.struct([g.u32("typeIndex"),eB("deactivationSlot"),g.nu64("lastExtendedSlot"),g.u8("lastExtendedStartIndex"),g.u8(),g.seq(V(),g.offset(g.u8(),-1),"authority")])},eU=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i,eV=(0,m.au)((0,m.KJ)(O),(0,m.Yj)(),e=>new O(e)),eD=(0,m.PV)([(0,m.Yj)(),(0,m.eu)("base64")]),eH=(0,m.au)((0,m.KJ)(n.Buffer),eD,e=>n.Buffer.from(e[0],"base64")),e$=3e4;function eF(e){let t,r;if("string"==typeof e)t=e;
7else if(e){let{commitment:i,...s}=e;t=i,r=s}return{commitment:t,config:r}}function eJ(e){return e.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function eG(e){return(0,m.KC)([(0,m.NW)({jsonrpc:(0,m.eu)("2.0"),id:(0,m.Yj)(),result:e}),(0,m.NW)({jsonrpc:(0,m.eu)("2.0"),id:(0,m.Yj)(),error:(0,m.NW)({code:(0,m.L5)(),message:(0,m.Yj)(),data:(0,m.lq)((0,m.bz)())})})])}let eX=eG((0,m.L5)());function eZ(e){return(0,m.au)(eG(e),eX,t=>"error"in t?t:{...t,result:(0,m.vt)(t.result,e)})}function eQ(e){return eZ((0,m.NW)({context:(0,m.NW)({slot:(0,m.ai)()}),value:e}))}function e0(e){return(0,m.NW)({context:(0,m.NW)({slot:(0,m.ai)()}),value:e})}function e1(e,t){return 0===e?new ee({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new O(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:l().decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Q(t)}let e2=(0,m.NW)({foundation:(0,m.ai)(),foundationTerm:(0,m.ai)(),initial:(0,m.ai)(),taper:(0,m.ai)(),terminal:(0,m.ai)()}),e3=eZ((0,m.YO)((0,m.me)((0,m.NW)({epoch:(0,m.ai)(),effectiveSlot:(0,m.ai)(),amount:(0,m.ai)(),postBalance:(0,m.ai)(),commission:(0,m.lq)((0,m.me)((0,m.ai)()))})))),e8=(0,m.YO)((0,m.NW)({slot:(0,m.ai)(),prioritizationFee:(0,m.ai)()})),e6=(0,m.NW)({total:(0,m.ai)(),validator:(0,m.ai)(),foundation:(0,m.ai)(),epoch:(0,m.ai)()}),e4=(0,m.NW)({epoch:(0,m.ai)(),slotIndex:(0,m.ai)(),slotsInEpoch:(0,m.ai)(),absoluteSlot:(0,m.ai)(),blockHeight:(0,m.lq)((0,m.ai)()),transactionCount:(0,m.lq)((0,m.ai)())}),e5=(0,m.NW)({slotsPerEpoch:(0,m.ai)(),leaderScheduleSlotOffset:(0,m.ai)(),warmup:(0,m.zM)(),firstNormalEpoch:(0,m.ai)(),firstNormalSlot:(0,m.ai)()}),e9=(0,m.g1)((0,m.Yj)(),(0,m.YO)((0,m.ai)())),e7=(0,m.me)((0,m.KC)([(0,m.NW)({}),(0,m.Yj)()])),te=(0,m.NW)({err:e7}),tt=(0,m.eu)("receivedSignature"),tr=(0,m.NW)({"solana-core":(0,m.Yj)(),"feature-set":(0,m.lq)((0,m.ai)())}),ti=(0,m.NW)({program:(0,m.Yj)(),programId:eV,parsed:(0,m.L5)()}),ts=(0,m.NW)({programId:eV,accounts:(0,m.YO)(eV),data:(0,m.Yj)()}),tn=eQ((0,m.NW)({err:(0,m.me)((0,m.KC)([(0,m.NW)({}),(0,m.Yj)()])),logs:(0,m.me)((0,m.YO)((0,m.Yj)())),accounts:(0,m.lq)((0,m.me)((0,m.YO)((0,m.me)((0,m.NW)({executable:(0,m.zM)(),owner:(0,m.Yj)(),lamports:(0,m.ai)(),data:(0,m.YO)((0,m.Yj)()),rentEpoch:(0,m.lq)((0,m.ai)())}))))),unitsConsumed:(0,m.lq)((0,m.ai)()),returnData:(0,m.lq)((0,m.me)((0,m.NW)({programId:(0,m.Yj)(),data:(0,m.PV)([(0,m.Yj)(),(0,m.eu)("base64")])}))),innerInstructions:(0,m.lq)((0,m.me)((0,m.YO)((0,m.NW)({index:(0,m.ai)(),instructions:(0,m.YO)((0,m.KC)([ti,ts]))}))))})),to=eQ((0,m.NW)({byIdentity:(0,m.g1)((0,m.Yj)(),(0,m.YO)((0,m.ai)())),range:(0,m.NW)({firstSlot:(0,m.ai)(),lastSlot:(0,m.ai)()})})),ta=eZ(e2),tc=eZ(e6),tu=eZ(e8),tl=eZ(e4),td=eZ(e5),th=eZ(e9),tg=eZ((0,m.ai)()),tp=eQ((0,m.NW)({total:(0,m.ai)(),circulating:(0,m.ai)(),nonCirculating:(0,m.ai)(),nonCirculatingAccounts:(0,m.YO)(eV)})),tm=(0,m.NW)({amount:(0,m.Yj)(),uiAmount:(0,m.me)((0,m.ai)()),decimals:(0,m.ai)(),uiAmountString:(0,m.lq)((0,m.Yj)())}),ty=eQ((0,m.YO)((0,m.NW)({address:eV,amount:(0,m.Yj)(),uiAmount:(0,m.me)((0,m.ai)()),decimals:(0,m.ai)(),uiAmountString:(0,m.lq)((0,m.Yj)())}))),tb=eQ((0,m.YO)((0,m.NW)({pubkey:eV,account:(0,m.NW)({executable:(0,m.zM)(),owner:eV,lamports:(0,m.ai)(),data:eH,rentEpoch:(0,m.ai)()})}))),tf=(0,m.NW)({program:(0,m.Yj)(),parsed:(0,m.L5)(),space:(0,m.ai)()}),tk=eQ((0,m.YO)((0,m.NW)({pubkey:eV,account:(0,m.NW)({executable:(0,m.zM)(),owner:eV,lamports:(0,m.ai)(),data:tf,rentEpoch:(0,m.ai)()})}))),tS=eQ((0,m.YO)((0,m.NW)({lamports:(0,m.ai)(),address:eV}))),tw=(0,m.NW)({executable:(0,m.zM)(),owner:eV,lamports:(0,m.ai)(),data:eH,rentEpoch:(0,m.ai)()}),tI=(0,m.NW)({pubkey:eV,account:tw}),t_=(0,m.au)((0,m.KC)([(0,m.KJ)(n.Buffer),tf]),(0,m.KC)([eD,tf]),e=>Array.isArray(e)?(0,m.vt)(e,eH):e),tA=(0,m.NW)({executable:(0,m.zM)(),owner:eV,lamports:(0,m.ai)(),data:t_,rentEpoch:(0,m.ai)()}),tv=(0,m.NW)({pubkey:eV,account:tA}),tP=(0,m.NW)({state:(0,m.KC)([(0,m.eu)("active"),(0,m.eu)("inactive"),(0,m.eu)("activating"),(0,m.eu)("deactivating")]),active:(0,m.ai)(),inactive:(0,m.ai)()}),tE=eZ((0,m.YO)((0,m.NW)({signature:(0,m.Yj)(),slot:(0,m.ai)(),err:e7,memo:(0,m.me)((0,m.Yj)()),blockTime:(0,m.lq)((0,m.me)((0,m.ai)()))}))),tB=eZ((0,m.YO)((0,m.NW)({signature:(0,m.Yj)(),slot:(0,m.ai)(),err:e7,memo:(0,m.me)((0,m.Yj)()),blockTime:(0,m.lq)((0,m.me)((0,m.ai)()))}))),tT=(0,m.NW)({subscription:(0,m.ai)(),result:e0(tw)}),tW=(0,m.NW)({pubkey:eV,account:tw}),tN=(0,m.NW)({subscription:(0,m.ai)(),result:e0(tW)}),tR=(0,m.NW)({parent:(0,m.ai)(),slot:(0,m.ai)(),root:(0,m.ai)()}),tC=(0,m.NW)({subscription:(0,m.ai)(),result:tR}),tO=(0,m.KC)([(0,m.NW)({type:(0,m.KC)([(0,m.eu)("firstShredReceived"),(0,m.eu)("completed"),(0,m.eu)("optimisticConfirmation"),(0,m.eu)("root")
7]),slot:(0,m.ai)(),timestamp:(0,m.ai)()}),(0,m.NW)({type:(0,m.eu)("createdBank"),parent:(0,m.ai)(),slot:(0,m.ai)(),timestamp:(0,m.ai)()}),(0,m.NW)({type:(0,m.eu)("frozen"),slot:(0,m.ai)(),timestamp:(0,m.ai)(),stats:(0,m.NW)({numTransactionEntries:(0,m.ai)(),numSuccessfulTransactions:(0,m.ai)(),numFailedTransactions:(0,m.ai)(),maxTransactionsPerEntry:(0,m.ai)()})}),(0,m.NW)({type:(0,m.eu)("dead"),slot:(0,m.ai)(),timestamp:(0,m.ai)(),err:(0,m.Yj)()})]),tx=(0,m.NW)({subscription:(0,m.ai)(),result:tO}),tL=(0,m.NW)({subscription:(0,m.ai)(),result:e0((0,m.KC)([te,tt]))}),tK=(0,m.NW)({subscription:(0,m.ai)(),result:(0,m.ai)()}),tz=(0,m.NW)({pubkey:(0,m.Yj)(),gossip:(0,m.me)((0,m.Yj)()),tpu:(0,m.me)((0,m.Yj)()),rpc:(0,m.me)((0,m.Yj)()),version:(0,m.me)((0,m.Yj)())}),tq=(0,m.NW)({votePubkey:(0,m.Yj)(),nodePubkey:(0,m.Yj)(),activatedStake:(0,m.ai)(),epochVoteAccount:(0,m.zM)(),epochCredits:(0,m.YO)((0,m.PV)([(0,m.ai)(),(0,m.ai)(),(0,m.ai)()])),commission:(0,m.ai)(),lastVote:(0,m.ai)(),rootSlot:(0,m.me)((0,m.ai)())}),tY=eZ((0,m.NW)({current:(0,m.YO)(tq),delinquent:(0,m.YO)(tq)})),tj=(0,m.KC)([(0,m.eu)("processed"),(0,m.eu)("confirmed"),(0,m.eu)("finalized")]),tM=(0,m.NW)({slot:(0,m.ai)(),confirmations:(0,m.me)((0,m.ai)()),err:e7,confirmationStatus:(0,m.lq)(tj)}),tU=eQ((0,m.YO)((0,m.me)(tM))),tV=eZ((0,m.ai)()),tD=(0,m.NW)({accountKey:eV,writableIndexes:(0,m.YO)((0,m.ai)()),readonlyIndexes:(0,m.YO)((0,m.ai)())}),tH=(0,m.NW)({signatures:(0,m.YO)((0,m.Yj)()),message:(0,m.NW)({accountKeys:(0,m.YO)((0,m.Yj)()),header:(0,m.NW)({numRequiredSignatures:(0,m.ai)(),numReadonlySignedAccounts:(0,m.ai)(),numReadonlyUnsignedAccounts:(0,m.ai)()}),instructions:(0,m.YO)((0,m.NW)({accounts:(0,m.YO)((0,m.ai)()),data:(0,m.Yj)(),programIdIndex:(0,m.ai)()})),recentBlockhash:(0,m.Yj)(),addressTableLookups:(0,m.lq)((0,m.YO)(tD))})}),t$=(0,m.NW)({pubkey:eV,signer:(0,m.zM)(),writable:(0,m.zM)(),source:(0,m.lq)((0,m.KC)([(0,m.eu)("transaction"),(0,m.eu)("lookupTable")]))}),tF=(0,m.NW)({accountKeys:(0,m.YO)(t$),signatures:(0,m.YO)((0,m.Yj)())}),tJ=(0,m.NW)({parsed:(0,m.L5)(),program:(0,m.Yj)(),programId:eV}),tG=(0,m.NW)({accounts:(0,m.YO)(eV),data:(0,m.Yj)(),programId:eV}),tX=(0,m.KC)([tG,tJ]),tZ=(0,m.KC)([(0,m.NW)({parsed:(0,m.L5)(),program:(0,m.Yj)(),programId:(0,m.Yj)()}),(0,m.NW)({accounts:(0,m.YO)((0,m.Yj)()),data:(0,m.Yj)(),programId:(0,m.Yj)()})]),tQ=(0,m.au)(tX,tZ,e=>"accounts"in e?(0,m.vt)(e,tG):(0,m.vt)(e,tJ)),t0=(0,m.NW)({signatures:(0,m.YO)((0,m.Yj)()),message:(0,m.NW)({accountKeys:(0,m.YO)(t$),instructions:(0,m.YO)(tQ),recentBlockhash:(0,m.Yj)(),addressTableLookups:(0,m.lq)((0,m.me)((0,m.YO)(tD)))})}),t1=(0,m.NW)({accountIndex:(0,m.ai)(),mint:(0,m.Yj)(),owner:(0,m.lq)((0,m.Yj)()),programId:(0,m.lq)((0,m.Yj)()),uiTokenAmount:tm}),t2=(0,m.NW)({writable:(0,m.YO)(eV),readonly:(0,m.YO)(eV)}),t3=(0,m.NW)({err:e7,fee:(0,m.ai)(),innerInstructions:(0,m.lq)((0,m.me)((0,m.YO)((0,m.NW)({index:(0,m.ai)(),instructions:(0,m.YO)((0,m.NW)({accounts:(0,m.YO)((0,m.ai)()),data:(0,m.Yj)(),programIdIndex:(0,m.ai)()}))})))),preBalances:(0,m.YO)((0,m.ai)()),postBalances:(0,m.YO)((0,m.ai)()),logMessages:(0,m.lq)((0,m.me)((0,m.YO)((0,m.Yj)()))),preTokenBalances:(0,m.lq)((0,m.me)((0,m.YO)(t1))),postTokenBalances:(0,m.lq)((0,m.me)((0,m.YO)(t1))),loadedAddresses:(0,m.lq)(t2),computeUnitsConsumed:(0,m.lq)((0,m.ai)())}),t8=(0,m.NW)({err:e7,fee:(0,m.ai)(),innerInstructions:(0,m.lq)((0,m.me)((0,m.YO)((0,m.NW)({index:(0,m.ai)(),instructions:(0,m.YO)(tQ)})))),preBalances:(0,m.YO)((0,m.ai)()),postBalances:(0,m.YO)((0,m.ai)()),logMessages:(0,m.lq)((0,m.me)((0,m.YO)((0,m.Yj)()))),preTokenBalances:(0,m.lq)((0,m.me)((0,m.YO)(t1))),postTokenBalances:(0,m.lq)((0,m.me)((0,m.YO)(t1))),loadedAddresses:(0,m.lq)(t2),computeUnitsConsumed:(0,m.lq)((0,m.ai)())}),t6=(0,m.KC)([(0,m.eu)(0),(0,m.eu)("legacy")]),t4=(0,m.NW)({pubkey:(0,m.Yj)(),lamports:(0,m.ai)(),postBalance:(0,m.me)((0,m.ai)()),rewardType:(0,m.me)((0,m.Yj)()),commission:(0,m.lq)((0,m.me)((0,m.ai)()))}),t5=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),transactions:(0,m.YO)((0,m.NW)({transaction:tH,meta:(0,m.me)(t3),version:(0,m.lq)(t6)})),rewards:(0,m.lq)((0,m.YO)(t4)),blockTime:(0,m.me)((0,m.ai)()),blockHeight:(0,m.me)((0,m.ai)())}))),t9=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),rewards:(0,m.lq)((0,m.YO)(t4)),blockTime:(0,m.me)((0,m.ai)()),blockHeight:(0,m.me)((0,m.ai)())}))),t7=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),transactions:(0,m.YO)((0,m.NW)({transaction:tF,meta:(0,m.me)(t3),version:(0,m.lq)(t6)})),rewards:(0,m.lq)((0,m.YO)(t4)),blockTime:(0,m.me)((0,m.ai)()),blockHeight:(0,m.me)((0,m.ai)())}))),re=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),transactions:(0,m.YO)((0,m.NW)({transaction:t0,meta:(0,m.me)(t8),version:(0,m.lq)(t6)})),rewards:(0,m.lq)((0,m.YO)(t4)),blockTime:(0,m.me)((0,m.ai)()),blockHeight:(0,m.me)((0,m.ai)())}))),rt=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),transactions:(0,m.YO)((0,m.NW)({transaction:tF,meta:(0,m.me)(t8),version:(0,m.lq)(t6)})),rewards:(0,m.lq)((0,m.YO)(t4)),blockTime:(0,m.me)((0,m.ai)()),blockHeight:(0,m.me)((0,m.ai)())}))),rr=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),rewards:(0,m.lq)((0,m.YO)(t4)),blockTime:(0,m.me)((0,m.ai)()),blockHeight:(0,m.me)((0,m.ai)())}))),ri=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),transactions:(0,m.YO)((0,m.NW)({transaction:tH,meta:(0,m.me)(t3)})),rewards:(0,m.lq)((0,m.YO)(t4)),blockTime:(0,m.me)((0,m.ai)())}))),rs=eZ((0,m.me)((0,m.NW)({blockhash:(0,m.Yj)(),previousBlockhash:(0,m.Yj)(),parentSlot:(0,m.ai)(),signatures:(0,m.YO)((0,m.Yj)()),blockTime:(0,m.me)((0,m.ai)())}))),rn=eZ((0,m.me)((0,m.NW)({slot:(0,m.ai)(),meta:(0,m.me)(t3),blockTime:(0,m.lq)((0,m.me)((0,m.ai)())),transaction:tH,version:(0,m.lq)(t6)}))),ro=eZ((0,m.me)((0,m.NW)({slot:(0,m.ai)(),transaction:t0,meta:(0,m.me)(t8),blockTime:(0,m.lq)((0,m.me)((0,m.ai)())),version:(0,m.lq)(t6)}
7))),ra=eQ((0,m.NW)({blockhash:(0,m.Yj)(),lastValidBlockHeight:(0,m.ai)()})),rc=eQ((0,m.zM)()),ru=(0,m.NW)({slot:(0,m.ai)(),numTransactions:(0,m.ai)(),numSlots:(0,m.ai)(),samplePeriodSecs:(0,m.ai)()}),rl=eZ((0,m.YO)(ru)),rd=eQ((0,m.me)((0,m.NW)({feeCalculator:(0,m.NW)({lamportsPerSignature:(0,m.ai)()})}))),rh=eZ((0,m.Yj)()),rg=eZ((0,m.Yj)()),rp=(0,m.NW)({err:e7,logs:(0,m.YO)((0,m.Yj)()),signature:(0,m.Yj)()}),rm=(0,m.NW)({result:e0(rp),subscription:(0,m.ai)()}),ry={"solana-client":"js/1.0.0-maintenance"};class rb{constructor(e,t){var r;let i,s,n,o,a,c;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}=eF(t),s=this._buildArgs([],r,void 0,i),n=eL(s);return e[n]=e[n]??(async()=>{try{let e=await this._rpcRequest("getBlockHeight",s),t=(0,m.vt)(e,eZ((0,m.ai)()));if("error"in t)throw new ek(t.error,"failed to get block height information");return t.result}finally{delete e[n]}})(),await e[n]}})(),t&&"string"==typeof t?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,i=t.wsEndpoint,s=t.httpHeaders,n=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,c=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=i||function(e){let t=e.match(eU);if(null==t)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[r,i,s,n]=t,o=e.startsWith("https:")?"wss:":"ws:",a=null==s?null:parseInt(s.slice(1),10),c=null==a?"":`:${a+1}`;return`${o}//${i}${c}${n}`}(e),this._rpcClient=function(e,t,r,i,s,n){let o,a,c=r||eq;return null!=n&&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&&(a=async(e,t)=>{let r=await new Promise((r,s)=>{try{i(e,t,(e,t)=>r([e,t]))}catch(e){s(e)}});return await c(...r)}),new(b())(async(r,i)=>{let n={method:"POST",body:r,agent:o,headers:Object.assign({"Content-Type":"application/json"},t||{},ry)};try{let t,r=5,o=500;for(;(t=a?await a(e,n):await c(e,n),429===t.status&&!0!==s)&&(r-=1,0!==r);){;console.error(`Server responded with ${t.status} ${t.statusText}. Retrying after ${o}ms delay...`),await ew(o),o*=2}let u=await t.text();t.ok?i(null,u):i(Error(`${t.status} ${t.statusText}: ${u}`))}catch(e){e instanceof Error&&i(e)}},{})}(e,s,n,o,a,c),this._rpcRequest=(r=this._rpcClient,(e,t)=>new Promise((i,s)=>{r.request(e,t,(e,t)=>{if(e)return void s(e);i(t)})})),this._rpcBatchRequest=function(e){return t=>new Promise((r,i)=>{0===t.length&&r([]);let s=t.map(t=>e.request(t.methodName,t.args));e.request(s,(e,t)=>{if(e)return void i(e);r(t)})})}(this._rpcClient),this._rpcWebSocket=new eY(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}
7async getBalanceAndContext(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgs([e.toBase58()],r,void 0,i),n=await this._rpcRequest("getBalance",s),o=(0,m.vt)(n,eQ((0,m.ai)()));if("error"in o)throw new ek(o.error,`failed to get balance for ${e.toBase58()}`);return o.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,m.vt)(t,eZ((0,m.me)((0,m.ai)())));if("error"in r)throw new ek(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){let e=await this._rpcRequest("minimumLedgerSlot",[]),t=(0,m.vt)(e,eZ((0,m.ai)()));if("error"in t)throw new ek(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){let e=await this._rpcRequest("getFirstAvailableBlock",[]),t=(0,m.vt)(e,tg);if("error"in t)throw new ek(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,m.vt)(r,tp);if("error"in i)throw new ek(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),s=(0,m.vt)(i,eQ(tm));if("error"in s)throw new ek(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",r),s=(0,m.vt)(i,eQ(tm));if("error"in s)throw new ek(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,r){let{commitment:i,config:s}=eF(r),n=[e.toBase58()];"mint"in t?n.push({mint:t.mint.toBase58()}):n.push({programId:t.programId.toBase58()});let o=this._buildArgs(n,i,"base64",s),a=await this._rpcRequest("getTokenAccountsByOwner",o),c=(0,m.vt)(a,tb);if("error"in c)throw new ek(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 s=this._buildArgs(i,r,"jsonParsed"),n=await this._rpcRequest("getTokenAccountsByOwner",s),o=(0,m.vt)(n,tk);if("error"in o)throw new ek(o.error,`failed to get token accounts owned by account ${e.toBase58()}`);return o.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),s=(0,m.vt)(i,tS);if("error"in s)throw new ek(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",r),s=(0,m.vt)(i,ty);if("error"in s)throw new ek(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgs([e.toBase58()],r,"base64",i),n=await this._rpcRequest("getAccountInfo",s),o=(0,m.vt)(n,eQ((0,m.me)(tw)));if("error"in o)throw new ek(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getParsedAccountInfo(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgs([e.toBase58()],r,"jsonParsed",i),n=await this._rpcRequest("getAccountInfo",s),o=(0,m.vt)(n,eQ((0,m.me)(tA)));if("error"in o)throw new ek(o.error,`failed to get info about account ${e.toBase58()}`);return o.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}=eF(t),s=e.map(e=>e.toBase58()),n=this._buildArgs([s],r,"jsonParsed",i),o=await this._rpcRequest("getMultipleAccounts",n),a=(0,m.vt)(o,eQ((0,m.YO)((0,m.me)(tA))));if("error"in a)throw new ek(a.error,`failed to get info for accounts ${s}`);return a.result}
7async getMultipleAccountsInfoAndContext(e,t){let{commitment:r,config:i}=eF(t),s=e.map(e=>e.toBase58()),n=this._buildArgs([s],r,"base64",i),o=await this._rpcRequest("getMultipleAccounts",n),a=(0,m.vt)(o,eQ((0,m.YO)((0,m.me)(tw))));if("error"in a)throw new ek(a.error,`failed to get info for accounts ${s}`);return a.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){let{commitment:i,config:s}=eF(t),n=this._buildArgs([e.toBase58()],i,void 0,{...s,epoch:null!=r?r:s?.epoch}),o=await this._rpcRequest("getStakeActivation",n),a=(0,m.vt)(o,eZ(tP));if("error"in a)throw new ek(a.error,`failed to get Stake Activation ${e.toBase58()}`);return a.result}async getProgramAccounts(e,t){let{commitment:r,config:i}=eF(t),{encoding:s,...n}=i||{},o=this._buildArgs([e.toBase58()],r,s||"base64",{...n,...n.filters?{filters:eJ(n.filters)}:null}),a=await this._rpcRequest("getProgramAccounts",o),c=(0,m.YO)(tI),u=!0===n.withContext?(0,m.vt)(a,eQ(c)):(0,m.vt)(a,eZ(c));if("error"in u)throw new ek(u.error,`failed to get accounts owned by program ${e.toBase58()}`);return u.result}async getParsedProgramAccounts(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgs([e.toBase58()],r,"jsonParsed",i),n=await this._rpcRequest("getProgramAccounts",s),o=(0,m.vt)(n,eZ((0,m.YO)(tv)));if("error"in o)throw new ek(o.error,`failed to get accounts owned by program ${e.toBase58()}`);return o.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=l().decode(r)}catch(e){throw Error("signature must be base58 encoded: "+r)}return(F(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,s=!1;return{abortConfirmation:()=>{i&&(i(),i=void 0),null!=r&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:new Promise((n,o)=>{try{r=this.onSignature(t,(e,t)=>{r=void 0,n({__type:er.PROCESSED,response:{context:t,value:e}})},e);let a=new Promise(e=>{null==r?e():i=this._onSubscriptionStateChange(r,t=>{"subscribed"===t&&e()})});(async()=>{if(await a,s)return;
vendor: 1,821 bytes, line 7
7let r=await this.getSignatureStatus(t);if(s||null==r)return;let{context:i,value:c}=r;if(null!=c)if(c?.err)o(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}s=!0,n({__type:er.PROCESSED,response:{context:i,value:c}})}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:i}}){let s,n=!1,o=new Promise(t=>{let i=async()=>{try{return await this.getBlockHeight(e)}catch(e){return -1}};(async()=>{let e=await i();if(!n){for(;e<=r;)if(await ew(1e3),n||(e=await i(),n))return;t({__type:er.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:c}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),u=this.getCancellationPromise(t);try{let e=await Promise.race([u,c,o]);if(e.__type===er.PROCESSED)s=e.response;else throw new Y(i)}finally{n=!0,a()}return s}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:i,nonceValue:s,signature:n}}){let o,a=!1,c=new Promise(t=>{let n=s,o=null,c=async()=>{try{let{context:t,value:s}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:r});return o=t.slot,s?.nonce}catch(e){return n}};(async()=>{if(n=await c(),!a)for(;;){if(s!==n)return void t({__type:er.NONCE_INVALID,slotInWhichNonceDidAdvance:o});if(await ew(2e3),a||(n=await c(),a))return}})()}),{abortConfirmation:u,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:n}),d=this.getCancellationPromise(t);try{let t=await Promise.race([d,l,c]);if(t.__type===er.PROCESSED)o=t.response;else{let i;for(;;
7){let e=await this.getSignatureStatus(n);if(null==e)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??r)){await ew(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 M(n);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==r&&"finalized"!==r)throw new M(n);break;case"finalized":case"max":case"root":if("finalized"!==r)throw new M(n)}o={context:i.context,value:{err:i.value.err}}}else throw new M(n)}}finally{a=!0,u()}return o}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r,i,s=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:er.TIMED_OUT,timeoutMs:i}),i)}),{abortConfirmation:n,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});try{let e=await Promise.race([o,s]);if(e.__type===er.PROCESSED)i=e.response;else throw new j(t,e.timeoutMs/1e3)}finally{clearTimeout(r),n()}return i}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=(0,m.vt)(e,eZ((0,m.YO)(tz)));if("error"in t)throw new ek(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,m.vt)(r,tY);if("error"in i)throw new ek(i.error,"failed to get vote accounts");return i.result}async getSlot(e){let{commitment:t,config:r}=eF(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getSlot",i),n=(0,m.vt)(s,eZ((0,m.ai)()));if("error"in n)throw new ek(n.error,"failed to get slot");return n.result}async getSlotLeader(e){let{commitment:t,config:r}=eF(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getSlotLeader",i),n=(0,m.vt)(s,eZ((0,m.Yj)()));if("error"in n)throw new ek(n.error,"failed to get slot leader");return n.result}async getSlotLeaders(e,t){let r=await this._rpcRequest("getSlotLeaders",[e,t]),i=(0,m.vt)(r,eZ((0,m.YO)(eV)));if("error"in i)throw new ek(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){let{context:r,value:i}
7=await this.getSignatureStatuses([e],t);return F(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),s=(0,m.vt)(i,tU);if("error"in s)throw new ek(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){let{commitment:t,config:r}=eF(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getTransactionCount",i),n=(0,m.vt)(s,eZ((0,m.ai)()));if("error"in n)throw new ek(n.error,"failed to get transaction count");return n.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,m.vt)(r,ta);if("error"in i)throw new ek(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,r){let{commitment:i,config:s}=eF(r),n=this._buildArgs([e.map(e=>e.toBase58())],i,void 0,{...s,epoch:null!=t?t:s?.epoch}),o=await this._rpcRequest("getInflationReward",n),a=(0,m.vt)(o,e3);if("error"in a)throw new ek(a.error,"failed to get inflation reward");return a.result}async getInflationRate(){let e=await this._rpcRequest("getInflationRate",[]),t=(0,m.vt)(e,tc);if("error"in t)throw new ek(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){let{commitment:t,config:r}=eF(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getEpochInfo",i),n=(0,m.vt)(s,tl);if("error"in n)throw new ek(n.error,"failed to get epoch info");return n.result}async getEpochSchedule(){let e=await this._rpcRequest("getEpochSchedule",[]),t=(0,m.vt)(e,td);if("error"in t)throw new ek(t.error,"failed to get epoch schedule");let r=t.result;return new ez(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=(0,m.vt)(e,th);if("error"in t)throw new ek(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),s=(0,m.vt)(i,tV);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON:()=>({})}}}}async getRecentPerformanceSamples(e){let t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=(0,m.vt)(t,rl);if("error"in r)throw new ek(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),s=(0,m.vt)(i,rd);if("error"in s)throw new ek(s.error,"failed to get fee calculator");let{context:n,value:o}=s.result;return{context:n,value:null!==o?o.feeCalculator:null}}async getFeeForMessage(e,t){let r=E(e.serialize()).toString("base64"),i=this._buildArgs([r],t),s=await this._rpcRequest("getFeeForMessage",i),n=(0,m.vt)(s,eQ((0,m.me)((0,m.ai)())));if("error"in n)throw new ek(n.error,"failed to get fee for message");if(null===n.result)throw Error("invalid blockhash");return n.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),r=t?.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),s=(0,m.vt)(i,tu);if("error"in s)throw new ek(s.error,"failed to get recent prioritization fees");return s.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)}}
7async getLatestBlockhashAndContext(e){let{commitment:t,config:r}=eF(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getLatestBlockhash",i),n=(0,m.vt)(s,ra);if("error"in n)throw new ek(n.error,"failed to get latest blockhash");return n.result}async isBlockhashValid(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgs([e],r,void 0,i),n=await this._rpcRequest("isBlockhashValid",s),o=(0,m.vt)(n,rc);if("error"in o)throw new ek(o.error,"failed to determine if the blockhash `"+e+"`is valid");return o.result}async getVersion(){let e=await this._rpcRequest("getVersion",[]),t=(0,m.vt)(e,eZ(tr));if("error"in t)throw new ek(t.error,"failed to get version");return t.result}async getGenesisHash(){let e=await this._rpcRequest("getGenesisHash",[]),t=(0,m.vt)(e,eZ((0,m.Yj)()));if("error"in t)throw new ek(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgsAtLeastConfirmed([e],r,void 0,i),n=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let e=(0,m.vt)(n,t7);if("error"in e)throw e.error;return e.result}case"none":{let e=(0,m.vt)(n,t9);if("error"in e)throw e.error;return e.result}default:{let e=(0,m.vt)(n,t5);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:e1(r,e.message)},version:r}))}:null}}}catch(e){throw new ek(e,"failed to get confirmed block")}}async getParsedBlock(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),n=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let e=(0,m.vt)(n,rt);if("error"in e)throw e.error;return e.result}case"none":{let e=(0,m.vt)(n,rr);if("error"in e)throw e.error;return e.result}default:{let e=(0,m.vt)(n,re);if("error"in e)throw e.error;return e.result}}}catch(e){throw new ek(e,"failed to get block")}}async getBlockProduction(e){let t,r;if("string"==typeof e)r=e;
7else if(e){let{commitment:i,...s}=e;r=i,t=s}let i=this._buildArgs([],r,"base64",t),s=await this._rpcRequest("getBlockProduction",i),n=(0,m.vt)(s,to);if("error"in n)throw new ek(n.error,"failed to get block production information");return n.result}async getTransaction(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgsAtLeastConfirmed([e],r,void 0,i),n=await this._rpcRequest("getTransaction",s),o=(0,m.vt)(n,rn);if("error"in o)throw new ek(o.error,"failed to get transaction");let a=o.result;return a?{...a,transaction:{...a.transaction,message:e1(a.version,a.transaction.message)}}:a}async getParsedTransaction(e,t){let{commitment:r,config:i}=eF(t),s=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),n=await this._rpcRequest("getTransaction",s),o=(0,m.vt)(n,ro);if("error"in o)throw new ek(o.error,"failed to get transaction");return o.result}async getParsedTransactions(e,t){let{commitment:r,config:i}=eF(t),s=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(e=>{let t=(0,m.vt)(e,ro);if("error"in t)throw new ek(t.error,"failed to get transactions");return t.result})}async getTransactions(e,t){let{commitment:r,config:i}=eF(t),s=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,void 0,i)}));return(await this._rpcBatchRequest(s)).map(e=>{let t=(0,m.vt)(e,rn);if("error"in t)throw new ek(t.error,"failed to get transactions");let r=t.result;return r?{...r,transaction:{...r.transaction,message:e1(r.version,r.transaction.message)}}:r})}async getConfirmedBlock(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",r),s=(0,m.vt)(i,ri);if("error"in s)throw new ek(s.error,"failed to get confirmed block");let n=s.result;if(!n)throw Error("Confirmed block "+e+" not found");let o={...n,transactions:n.transactions.map(({transaction:e,meta:t})=>{let r=new Q(e.message);return{meta:t,transaction:{...e,message:r}}})};return{...o,transactions:o.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:en.populate(e.message,e.signatures)}))}}async getBlocks(e,t,r){let i=this._buildArgsAtLeastConfirmed(void 0!==t?[e,t]:[e],r),s=await this._rpcRequest("getBlocks",i),n=(0,m.vt)(s,eZ((0,m.YO)((0,m.ai)())));if("error"in n)throw new ek(n.error,"failed to get blocks");return n.result}async getBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=(0,m.vt)(i,rs);if("error"in s)throw new ek(s.error,"failed to get block");let n=s.result;if(!n)throw Error("Block "+e+" not found");return n}async getConfirmedBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=(0,m.vt)(i,rs);if("error"in s)throw new ek(s.error,"failed to get confirmed block");let n=s.result;if(!n)throw Error("Confirmed block "+e+" not found");return n}async getConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getTransaction",r),s=(0,m.vt)(i,rn);if("error"in s)throw new ek(s.error,"failed to get transaction");let n=s.result;if(!n)return n;let o=new Q(n.transaction.message),a=n.transaction.signatures;return{...n,transaction:en.populate(o,a)}}async getParsedConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getTransaction",r),s=(0,m.vt)(i,ro);if("error"in s)throw new ek(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){let r=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(e=>{let t=(0,m.vt)(e,ro);if("error"in t)throw new ek(t.error,"failed to get confirmed transactions");return t.result})}async getConfirmedSignaturesForAddress(e,t,r){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&!(--t<=0)&&!(t<s);)try{let e=await this.getConfirmedBlockSignatures(t,"finalized");
vendor: 13,874 bytes, line 7
7e.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 n=await this.getSlot("finalized");for(;!("before"in i)&&!(++r>n);)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),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),n=(0,m.vt)(s,tE);if("error"in n)throw new ek(n.error,"failed to get confirmed signatures for address");return n.result}async getSignaturesForAddress(e,t,r){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",i),n=(0,m.vt)(s,tB);if("error"in n)throw new ek(n.error,"failed to get signatures for address");return n.result}async getAddressLookupTable(e,t){let{context:r,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return null!==i&&(s=new ej({key:e,state:ej.deserialize(i.data)})),{context:r,value:s}}async getNonceAndContext(e,t){let{context:r,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return null!==i&&(s=eE.fromAccountData(i.data)),{context:r,value:s}}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,m.vt)(r,rh);if("error"in i)throw new ek(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await ew(100);let e=Date.now()-this._blockhashInfo.lastFetch;if(null!==this._blockhashInfo.latestBlockhash&&!(e>=e$))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 ew(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}=eF(e),i=this._buildArgs([],t,"base64",r),s=await this._rpcRequest("getStakeMinimumDelegation",i),n=(0,m.vt)(s,eQ((0,m.ai)()));if("error"in n)throw new ek(n.error,"failed to get stake minimum delegation");return n.result}async simulateTransaction(e,t,r){let i;if("message"in e){let i=e.serialize(),s=n.Buffer.from(i).toString("base64");if(Array.isArray(t)||void 0!==r)throw Error("Invalid arguments");let o=t||{};o.encoding="base64","commitment"in o||(o.commitment=this.commitment),t&&"object"==typeof t&&"innerInstructions"in t&&(o.innerInstructions=t.innerInstructions);let a=[s,o],c=await this._rpcRequest("simulateTransaction",a),u=(0,m.vt)(c,tn);if("error"in u)throw Error("failed to simulate transaction: "+u.error.message);return u.result}if(e instanceof en?((i=new en).feePayer=e.feePayer,i.instructions=e.instructions,i.nonceInfo=e.nonceInfo,i.signatures=e.signatures):(i=en.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 s=i.signature.toString("base64");if(this._blockhashInfo.simulatedSignatures.includes(s)||this._blockhashInfo.transactionSignatures.includes(s))e=!0;else{this._blockhashInfo.simulatedSignatures.push(s);break}}}let s=i._compile(),o=s.serialize(),a=i._serialize(o).toString("base64"),c={encoding:"base64",commitment:this.commitment};r&&(c.accounts={encoding:"base64",addresses:(Array.isArray(r)?r:s.nonProgramIds()).map(e=>e.toBase58())}),t&&(c.sigVerify=!0),t&&"object"==typeof t&&"innerInstructions"in t&&(c.innerInstructions=t.innerInstructions);let u=[a,c],l=await this._rpcRequest("simulateTransaction",u),d=(0,m.vt)(l,tn);if("error"in d){let e;if("data"in d.error&&(e=d.error.data.logs)&&Array.isArray(e)){let t="\n ",r=t+e.join(t);console.error(d.error.message,r)}throw new eb({action:"simulate",signature:"",transactionMessage:d.error.message,logs:e})}return d.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 s=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(s))r=!0;else{this._blockhashInfo.transactionSignatures.push(s);break}}}let i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){let r=E(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){let r={encoding:"base64"},i=t&&t.skipPreflight,s=!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),s&&(r.preflightCommitment=s);let n=[e,r],o=await this._rpcRequest("sendTransaction",n),a=(0,m.vt)(o,rg);if("error"in a){let e;throw"data"in a.error&&(e=a.error.data.logs),new eb({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)return void this._updateSubscriptions();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)return void this._rpcWebSocket.connect();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:s}=r;try{this._setSubscription(e,{...r,state:"subscribing"});let t=await this._rpcWebSocket.call(s,i);this._setSubscription(e,{...r,serverSubscriptionId:t,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[t]=r.callbacks,await this._updateSubscriptions()}catch(n){if(console.error(`Received ${n instanceof Error?"":"JSON-RPC "}error calling \`${s}\``,{args:i,error:n}),!t())return;this._setSubscription(e,{...r,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":0===r.callbacks.size&&await (async()=>{let{serverSubscriptionId:i,unsubscribeMethod:s}=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(s,[i])}catch(i){if(i instanceof Error&&console.error(`${s} 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];void 0!==r&&r.forEach(e=>{try{e(...t)}catch(e){console.error(e)}})}_wsOnAccountNotification(e){let{result:t,subscription:r}=(0,m.vt)(e,tT);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){let r=this._nextClientSubscriptionId++,i=eL([e.method,t]),s=this._subscriptionsByHash[i];return void 0===s?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.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];F(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{commitment:i,config:s}=eF(r),n=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},n)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){let{result:t,subscription:r}=(0,m.vt)(e,tN);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,i){let{commitment:s,config:n}=eF(r),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",n||(i?{filters:eJ(i)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},o)}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,m.vt)(e,rm);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:r}=(0,m.vt)(e,tC);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,m.vt)(e,tx);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 s=t||this._commitment;if(s||r||i){let t={};r&&(t.encoding=r),s&&(t.commitment=s),i&&(t=Object.assign(t,i)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,r,i){let s=t||this._commitment;if(s&&!["confirmed","finalized"].includes(s))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,m.vt)(e,tL);"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"),s=this._makeSubscription({callback:(e,r)=>{if("status"===e.type){t(e.result,r);try{this.removeSignatureListener(s)}catch(e){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}
7onSignatureWithOptions(e,t,r){let{commitment:i,...s}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},n=this._buildArgs([e],i,void 0,s),o=this._makeSubscription({callback:(e,r)=>{t(e,r);try{this.removeSignatureListener(o)}catch(e){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},n);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){let{result:t,subscription:r}=(0,m.vt)(e,tK);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 rf{constructor(e){this._keypair=void 0,this._keypair=e??I()}static generate(){return new rf(I())}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=_(e.slice(0,32));for(let e=0;e<32;e++)if(r[e]!==t[e])throw Error("provided secretKey is invalid")}return new rf({publicKey:r,secretKey:e})}static fromSeed(e){let t=_(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new rf({publicKey:t,secretKey:r})}get publicKey(){return new O(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}let rk=Object.freeze({CreateLookupTable:{index:0,layout:g.struct([g.u32("instruction"),eB("recentSlot"),g.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:g.struct([g.u32("instruction")])},ExtendLookupTable:{index:2,layout:g.struct([g.u32("instruction"),eB(),g.seq(V(),g.offset(g.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:g.struct([g.u32("instruction")])},CloseLookupTable:{index:4,layout:g.struct([g.u32("instruction")])}});class rS{constructor(){}static decodeInstructionType(e){let t;this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data);for(let[e,i]of Object.entries(rk))if(i.index==r){t=e;break}if(!t)throw Error("Invalid Instruction. Should be a LookupTable Instruction");return t}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);let{recentSlot:t}=e_(rk.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);let{addresses:t}=e_(rk.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(e=>new O(e))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(rw.programId))throw Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class rw{constructor(){}static createLookupTable(e){let[t,r]=O.findProgramAddressSync([e.authority.toBuffer(),(0,p.eC)().encode(e.recentSlot)],this.programId),i=eI(rk.CreateLookupTable,{recentSlot:BigInt(e.recentSlot),bumpSeed:r}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:eN.programId,isSigner:!1,isWritable:!1}];return[new es({programId:this.programId,keys:s,data:i}),t]}static freezeLookupTable(e){let t=eI(rk.FreezeLookupTable),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new es({programId:this.programId,keys:r,data:t})}static extendLookupTable(e){let t=eI(rk.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:eN.programId,isSigner:!1,isWritable:!1}),new es({programId:this.programId,keys:r,data:t})}static deactivateLookupTable(e){let t=eI(rk.DeactivateLookupTable),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new es({programId:this.programId,keys:r,data:t})}static closeLookupTable(e){let t=eI(rk.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 es({programId:this.programId,keys:r,data:t})}}rw.programId=new O("AddressLookupTab1e1111111111111111111111111");class rI{constructor(){}static decodeInstructionType(e){let t;this.checkProgramId(e.programId);let r=g.u8("instruction").decode(e.data);for(let[e,i]of Object.entries(r_))if(i.index==r){t=e;break}if(!t)throw Error("Instruction type incorrect; not a ComputeBudgetInstruction");return t}static decodeRequestUnits(e){this.checkProgramId(e.programId);let{units:t,additionalFee:r}=e_(r_.RequestUnits,e.data);return{units:t,additionalFee:r}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);let{bytes:t}=e_(r_.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);let{units:t}=e_(r_.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);let{microLamports:t}=e_(r_.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(rA.programId))throw Error("invalid instruction; programId is not ComputeBudgetProgram")}}let r_=Object.freeze({RequestUnits:{index:0,layout:g.struct([g.u8("instruction"),g.u32("units"),g.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:g.struct([g.u8("instruction"),g.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:g.struct([g.u8("instruction"),g.u32("units")])},SetComputeUnitPrice:{index:3,layout:g.struct([g.u8("instruction"),eB("microLamports")])}});class rA{constructor(){}static requestUnits(e){let t=eI(r_.RequestUnits,e);return new es({keys:[],programId:this.programId,data:t})}static requestHeapFrame(e){let t=eI(r_.RequestHeapFrame,e);return new es({keys:[],programId:this.programId,data:t})}static setComputeUnitLimit(e){let t=eI(r_.SetComputeUnitLimit,e);return new es({keys:[],programId:this.programId,data:t})}static setComputeUnitPrice(e){let t=eI(r_.SetComputeUnitPrice,{microLamports:BigInt(e.microLamports)});return new es({keys:[],programId:this.programId,data:t})}}rA.programId=new O("ComputeBudget111111111111111111111111111111");let rv=g.struct([g.u8("numSignatures"),g.u8("padding"),g.u16("signatureOffset"),g.u16("signatureInstructionIndex"),g.u16("publicKeyOffset"),g.u16("publicKeyInstructionIndex"),g.u16("messageDataOffset"),g.u16("messageDataSize"),g.u16("messageInstructionIndex")]
7);class rP{constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:i,instructionIndex:s}=e;F(32===t.length,`Public Key must be 32 bytes but received ${t.length} bytes`),F(64===i.length,`Signature must be 64 bytes but received ${i.length} bytes`);let o=rv.span,a=o+t.length,c=a+i.length,u=n.Buffer.alloc(c+r.length),l=null==s?65535:s;return rv.encode({numSignatures:1,padding:0,signatureOffset:a,signatureInstructionIndex:l,publicKeyOffset:o,publicKeyInstructionIndex:l,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:l},u),u.fill(t,o),u.fill(i,a),u.fill(r,c),new es({keys:[],programId:rP.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:i}=e;F(64===t.length,`Private key must be 64 bytes but received ${t.length} bytes`);try{let e=rf.fromSecretKey(t),s=e.publicKey.toBytes(),n=v(r,e.secretKey);return this.createInstructionWithPublicKey({publicKey:s,message:r,signature:n,instructionIndex:i})}catch(e){throw Error(`Error creating instruction; ${e}`)}}}rP.programId=new O("Ed25519SigVerify111111111111111111111111111"),S.bI.utils.isValidPrivateKey;let rE=S.bI.getPublicKey,rB=g.struct([g.u8("numSignatures"),g.u16("signatureOffset"),g.u8("signatureInstructionIndex"),g.u16("ethAddressOffset"),g.u8("ethAddressInstructionIndex"),g.u16("messageDataOffset"),g.u16("messageDataSize"),g.u8("messageInstructionIndex"),g.blob(20,"ethAddress"),g.blob(64,"signature"),g.u8("recoveryId")]);class rT{constructor(){}static publicKeyToEthAddress(e){F(64===e.length,`Public key must be 64 bytes but received ${e.length} bytes`);try{return n.Buffer.from((0,k.lY)(E(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:i,recoveryId:s,instructionIndex:n}=e;return rT.createInstructionWithEthAddress({ethAddress:rT.publicKeyToEthAddress(t),message:r,signature:i,recoveryId:s,instructionIndex:n})}static createInstructionWithEthAddress(e){let t,{ethAddress:r,message:i,signature:s,recoveryId:o,instructionIndex:a=0}=e;F(20===(t="string"==typeof r?r.startsWith("0x")?n.Buffer.from(r.substr(2),"hex"):n.Buffer.from(r,"hex"):r).length,`Address must be 20 bytes but received ${t.length} bytes`);let c=12+t.length,u=c+s.length+1,l=n.Buffer.alloc(rB.span+i.length);return rB.encode({numSignatures:1,signatureOffset:c,signatureInstructionIndex:a,ethAddressOffset:12,ethAddressInstructionIndex:a,messageDataOffset:u,messageDataSize:i.length,messageInstructionIndex:a,signature:E(s),ethAddress:E(t),recoveryId:o},l),l.fill(E(i),rB.span),new es({keys:[],programId:rT.programId,data:l})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:i}=e;F(32===t.length,`Private key must be 32 bytes but received ${t.length} bytes`);try{let e=E(t),s=rE(e,!1).slice(1),o=n.Buffer.from((0,k.lY)(E(r))),[a,c]=((e,t)=>{let r=S.bI.sign(e,t);return[r.toCompactRawBytes(),r.recovery]})(o,e);return this.createInstructionWithPublicKey({publicKey:s,message:r,signature:a,recoveryId:c,instructionIndex:i})}catch(e){throw Error(`Error creating instruction; ${e}`)}}}rT.programId=new O("KeccakSecp256k11111111111111111111111111111");let rW=new O("StakeConfig11111111111111111111111111111111");class rN{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class rR{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}}rR.default=new rR(0,0,O.default);class rC{constructor(){}static decodeInstructionType(e){let t;this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data);for(let[e,i]of Object.entries(rO))if(i.index==r){t=e;break}if(!t)throw Error("Instruction type incorrect; not a StakeInstruction");return t}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t,lockup:r}=e_(rO.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new rN(new O(t.staker),new O(t.withdrawer)),lockup:new rR(r.unixTimestamp,r.epoch,new O(r.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),e_(rO.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,stakeAuthorizationType:r}=e_(rO.Authorize,e.data),i={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new O(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(i.custodianPubkey=e.keys[3].pubkey),i}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{newAuthorized:t,stakeAuthorizationType:r,authoritySeed:i,authorityOwner:s}=e_(rO.AuthorizeWithSeed,e.data),n={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:i,authorityOwner:new O(s),newAuthorizedPubkey:new O(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(n.custodianPubkey=e.keys[3].pubkey),n}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=e_(rO.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),e_(rO.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=e_(rO.Withdraw,e.data),r={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(r.custodianPubkey=e.keys[5].pubkey),r}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),e_(rO.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(rL.programId))throw Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}let rO=Object.freeze({Initialize:{index:0,layout:g.struct([g.u32("instruction"),((e="authorized")=>g.struct([V("staker"),V("withdrawer")],e))(),((e="lockup")=>g.struct([g.ns64("unixTimestamp"),g.ns64("epoch"),V("custodian")],e))()])},Authorize:{index:1,layout:g.struct([g.u32("instruction"),V("newAuthorized"),g.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:g.struct([g.u32("instruction")])},Split:{index:3,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},Withdraw:{index:4,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},Deactivate:{index:5,layout:g.struct([g.u32("instruction")])},Merge:{index:7,layout:g.struct([g.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:g.struct([g.u32("instruction"),V("newAuthorized"),g.u32("stakeAuthorizationType"),D("authoritySeed"),V("authorityOwner")])}}),rx=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class rL{constructor(){}static initialize(e){let{stakePubkey:t,authorized:r,lockup:i}=e,s=i||rR.default,n=eI(rO.Initialize,{authorized:{staker:E(r.staker.toBuffer()),withdrawer:E(r.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:E(s.custodian.toBuffer())}});return new es({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:eh,isSigner:!1,isWritable:!1}],programId:this.programId,data:n})}static createAccountWithSeed(e){let t=new en;t.add(eN.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:s}=e;return t.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static createAccount(e){let t=new en;t.add(eN.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:r,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:r,votePubkey:i}=e,s=eI(rO.Delegate);return new en().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:ec,isSigner:!1,isWritable:!1},{pubkey:ey,isSigner:!1,isWritable:!1},{pubkey:rW,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static authorize(e){let{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:n}=e,o=eI(rO.Authorize,{newAuthorized:E(i.toBuffer()),stakeAuthorizationType:s.index}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ec,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return n&&a.push({pubkey:n,isSigner:!0,isWritable:!1}),new en().add({keys:a,programId:this.programId,data:o})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:r,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:n,stakeAuthorizationType:o,custodianPubkey:a}=e,c=eI(rO.AuthorizeWithSeed,{newAuthorized:E(n.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:i,authorityOwner:E(s.toBuffer())}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:ec,isSigner:!1,isWritable:!1}];return a&&u.push({pubkey:a,isSigner:!0,isWritable:!1}),new en().add({keys:u,programId:this.programId,data:c})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:i,lamports:s}=e,n=eI(rO.Split,{lamports:s});return new es({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static split(e,t){let r=new en;return r.add(eN.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space
vendor: 1,587 bytes, line 7
7:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,basePubkey:n,seed:o,lamports:a}=e,c=new en;return c.add(eN.allocate({accountPubkey:s,basePubkey:n,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(eN.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),c.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,lamports:a}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:i}=e,s=eI(rO.Merge);return new en().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:ec,isSigner:!1,isWritable:!1},{pubkey:ey,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:r,toPubkey:i,lamports:s,custodianPubkey:n}=e,o=eI(rO.Withdraw,{lamports:s}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:ec,isSigner:!1,isWritable:!1},{pubkey:ey,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return n&&a.push({pubkey:n,isSigner:!0,isWritable:!1}),new en().add({keys:a,programId:this.programId,data:o})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:r}=e,i=eI(rO.Deactivate);return new en().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ec,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}rL.programId=new O("Stake11111111111111111111111111111111111111"),rL.space=200;
7class rK{constructor(e,t,r,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=r,this.commission=i}}class rz{constructor(){}static decodeInstructionType(e){let t;this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data);for(let[e,i]of Object.entries(rq))if(i.index==r){t=e;break}if(!t)throw Error("Instruction type incorrect; not a VoteInstruction");return t}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);let{voteInit:t}=e_(rq.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new rK(new O(t.nodePubkey),new O(t.authorizedVoter),new O(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,voteAuthorizationType:r}=e_(rq.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new O(t),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:r,newAuthorized:i,voteAuthorizationType:s}}=e_(rq.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new O(t),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new O(i),voteAuthorizationType:{index:s},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=e_(rq.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(rj.programId))throw Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}let rq=Object.freeze({InitializeAccount:{index:0,layout:g.struct([g.u32("instruction"),((e="voteInit")=>g.struct([V("nodePubkey"),V("authorizedVoter"),V("authorizedWithdrawer"),g.u8("commission")],e))()])},Authorize:{index:1,layout:g.struct([g.u32("instruction"),V("newAuthorized"),g.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:g.struct([g.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:g.struct([g.u32("instruction"),((e="voteAuthorizeWithSeedArgs")=>g.struct([g.u32("voteAuthorizationType"),V("currentAuthorityDerivedKeyOwnerPubkey"),D("currentAuthorityDerivedKeySeed"),V("newAuthorized")],e))()])}}),rY=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class rj{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:r,voteInit:i}=e,s=eI(rq.InitializeAccount,{voteInit:{nodePubkey:E(i.nodePubkey.toBuffer()),authorizedVoter:E(i.authorizedVoter.toBuffer()),authorizedWithdrawer:E(i.authorizedWithdrawer.toBuffer()),commission:i.commission}});return new es({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:eh,isSigner:!1,isWritable:!1},{pubkey:ec,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static createAccount(e){let t=new en;return t.add(eN.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:s}=e,n=eI(rq.Authorize,{newAuthorized:E(i.toBuffer()),voteAuthorizationType:s.index});return new en().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ec,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:n,votePubkey:o}=e,a=eI(rq.AuthorizeWithSeed,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:E(r.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:E(s.toBuffer()),voteAuthorizationType:n.index}});return new en().add({keys:[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:ec,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:i,toPubkey:s}=e,n=eI(rq.Withdraw,{lamports:i});return new en().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw Error("Withdraw will leave vote account with insufficient funds.");return rj.withdraw(e)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:i}=e,s=eI(rq.UpdateValidatorIdentity);return new en().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}rj.programId=new O("Vote111111111111111111111111111111111111111"),rj.space=3762;let rM=new O("Va1idator1nfo111111111111111111111111111111"),rU=(0,m.NW)({name:(0,m.Yj)(),website:(0,m.lq)((0,m.Yj)()),details:(0,m.lq)((0,m.Yj)()),iconUrl:(0,m.lq)((0,m.Yj)()),keybaseUsername:(0,m.lq)((0,m.Yj)())});class rV{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(2!==H(t))return null;let r=[];for(let e=0;e<2;e++){let e=new O(Z(t,0,R)),i=1===X(t);r.push({publicKey:e,isSigner:i})}if(r[0].publicKey.equals(rM)&&r[1].isSigner){let e=JSON.parse(D().decode(n.Buffer.from(t)));return(0,m.vA)(e,rU),new rV(r[1].publicKey,e)}return null}}let rD=new O("Vote111111111111111111111111111111111111111"),rH=g.struct([V("nodePubkey"),V("authorizedWithdrawer"),g.u8("commission"),g.nu64(),g.seq(g.struct([g.nu64("slot"),g.u32("confirmationCount")]),g.offset(g.u32(),-8),"votes"),g.u8("rootSlotValid"),g.nu64("rootSlot"),g.nu64(),g.seq(g.struct([g.nu64("epoch"),V("authorizedVoter")]),g.offset(g.u32(),-8),"authorizedVoters"),g.struct([g.seq(g.struct([V("authorizedPubkey"),g.nu64("epochOfLastAuthorizedSwitch"),g.nu64("targetEpoch")]),32,"buf"),g.nu64("idx"),g.u8("isEmpty")],"priorVoters"),g.nu64(),g.seq(g.struct([g.nu64("epoch"),g.nu64("credits"),g.nu64("prevCredits")]),g.offset(g.u32(),-8),"epochCredits"),g.struct([g.nu64("slot"),g.nu64("timestamp")],"lastTimestamp")]);class r${constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){let t=rH.decode(E(e),4),r=t.rootSlot;return t.rootSlotValid||(r=null),new r$({nodePubkey:new O(t.nodePubkey),authorizedWithdrawer:new O(t.authorizedWithdrawer),commission:t.commission,votes:t.votes,rootSlot:r,authorizedVoters:t.authorizedVoters.map(rF),priorVoters:function({buf:e,idx:t,isEmpty:r}){return r?[]:[...e.slice(t+1).map(rJ),...e.slice(0,t).map(rJ)]}(t.priorVoters),epochCredits:t.epochCredits,lastTimestamp:t.lastTimestamp})}}function rF({authorizedVoter:e,epoch:t}){return{epoch:t,authorizedVoter:new O(e)}}function rJ({authorizedPubkey:e,epochOfLastAuthorizedSwitch:t,targetEpoch:r}){return{authorizedPubkey:new O(e),epochOfLastAuthorizedSwitch:t,targetEpoch:r}}let rG={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function rX(e,t){let r=!1===t?"http":"https";if(!e)return rG[r].devnet;let i=rG[r][e];if(!i)throw Error(`Unknown ${r} cluster: ${e}`);return i}async function rZ(e,t,r,i){let s,n;r&&Object.prototype.hasOwnProperty.call(r,"lastValidBlockHeight")||r&&Object.prototype.hasOwnProperty.call(r,"nonceValue")?(s=r,n=i):n=r;let o=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,minContextSlot:n.minContextSlot},a=await e.sendRawTransaction(t,o),c=n&&n.commitment,u=s?e.confirmTransaction(s,c):e.confirmTransaction(a,c),l=(await u).value;if(l.err){if(null!=a)throw new eb({action:o?.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(l)})`});throw Error(`Raw transaction ${a} failed (${JSON.stringify(l)})`)}return a}let rQ=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.