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