"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9308],{57011:function(e,t,r){r.d(t,{GS:function(){return VersionedTransaction},YW:function(){return Transaction},nh:function(){return PublicKey}});var n=r(67133),i=r(50652),s=r(56662),a=r.n(s),o=r(68870),u=r.n(o),c=r(50552),l=r(84453),d=r(32452),h=r(40265),g=r(27958);r(152),r(28450);var p=r(85875),y=r(32177);i.UN.utils.randomPrivateKey;let generateKeypair=()=>{let e=i.UN.utils.randomPrivateKey(),t=f(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),{publicKey:t,secretKey:r}},f=i.UN.getPublicKey;function isOnCurve(e){try{return i.UN.ExtendedPoint.fromHex(e),!0}catch{return!1}}let sign=(e,t)=>i.UN.sign(e,t.slice(0,32)),b=i.UN.verify,toBuffer=e=>n.Buffer.isBuffer(e)?e:e instanceof Uint8Array?n.Buffer.from(e.buffer,e.byteOffset,e.byteLength):n.Buffer.from(e);let Struct=class Struct{constructor(e){Object.assign(this,e)}encode(){return n.Buffer.from((0,l.serialize)(m,this))}static decode(e){return(0,l.deserialize)(m,this,e)}static decodeUnchecked(e){return(0,l.deserializeUnchecked)(m,this,e)}};let m=new Map,k=1;let PublicKey=class PublicKey extends Struct{constructor(e){if(super({}),this._bn=void 0,void 0!==e._bn)this._bn=e._bn;else{if("string"==typeof e){let t=u().decode(e);if(32!=t.length)throw Error("Invalid public key input");this._bn=new(a())(t)}else this._bn=new(a())(e);if(this._bn.byteLength()>32)throw Error("Invalid public key input")}}static unique(){let e=new PublicKey(k);return k+=1,new PublicKey(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return u().encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(n.Buffer);if(32===e.length)return e;let t=n.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){let i=n.Buffer.concat([e.toBuffer(),n.Buffer.from(t),r.toBuffer()]),s=(0,c.J)(i);return new PublicKey(s)}static createProgramAddressSync(e,t){let r=n.Buffer.alloc(0);e.forEach(function(e){if(e.length>32)throw TypeError("Max seed length exceeded");r=n.Buffer.concat([r,toBuffer(e)])}),r=n.Buffer.concat([r,t.toBuffer(),n.Buffer.from("ProgramDerivedAddress")]);let i=(0,c.J)(r);if(isOnCurve(i))throw Error("Invalid seeds, address must fall off the curve");return new PublicKey(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r,i=255;for(;0!=i;){try{let s=e.concat(n.Buffer.from([i]));r=this.createProgramAddressSync(s,t)}catch(e){if(e instanceof TypeError)throw e;i--;continue}return[r,i]}throw Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){let t=new PublicKey(e);return isOnCurve(t.toBytes())}};PublicKey.default=new PublicKey("11111111111111111111111111111111"),m.set(PublicKey,{kind:"struct",fields:[["_bn","u256"]]}),new PublicKey("BPFLoader1111111111111111111111111111111111"),Object.defineProperty((class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}).prototype,"name",{value:"TransactionExpiredBlockheightExceededError"}),Object.defineProperty((class 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}}).prototype,"name",{value:"TransactionExpiredTimeoutError"}),Object.defineProperty((class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}).prototype,"name",{value:"TransactionExpiredNonceInvalidError"});let MessageAccountKeys=class MessageAccountKeys{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 findKeyIndex=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:findKeyIndex(e.programId),accountKeyIndexes:e.keys.map(e=>findKeyIndex(e.pubkey)),data:e.data}))}};let publicKey=(e="publicKey")=>d.Ik(32,e),signature=(e="signature")=>d.Ik(64,e),rustString=(e="string")=>{let t=d.n_([d.Jq("length"),d.Jq("lengthPadding"),d.Ik(d.cv(d.Jq(),-8),"chars")],e),r=t.decode.bind(t),i=t.encode.bind(t);return t.decode=(e,t)=>{let n=r(e,t);return n.chars.toString()},t.encode=(e,t,r)=>{let s={chars:n.Buffer.from(e,"utf8")};return i(s,t,r)},t.alloc=e=>d.Jq().span+d.Jq().span+n.Buffer.from(e,"utf8").length,t};function decodeLength(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 encodeLength(e,t){let r=t;for(;;){let t=127&r;if(0==(r>>=7)){e.push(t);break}t|=128,e.push(t)}}function assert(e,t){if(!e)throw Error(t||"Assertion failed")}let CompiledKeys=class CompiledKeys{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,getOrInsertDefault=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},n=getOrInsertDefault(t);for(let t of(n.isSigner=!0,n.isWritable=!0,e))for(let e of(getOrInsertDefault(t.programId).isInvoked=!0,t.keys)){let t=getOrInsertDefault(e.pubkey);t.isSigner||=e.isSigner,t.isWritable||=e.isWritable}return new CompiledKeys(t,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];assert(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};{assert(t.length>0,"Expected at least one writable signer key");let[e]=t[0];assert(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let a=[...t.map(([e])=>new PublicKey(e)),...r.map(([e])=>new PublicKey(e)),...n.map(([e])=>new PublicKey(e)),...i.map(([e])=>new PublicKey(e))];return[s,a]}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 PublicKey(i),s=e.findIndex(e=>e.equals(t));s>=0&&(assert(s<256,"Max lookup table index exceeded"),r.push(s),n.push(t),this.keyMetaMap.delete(i))}return[r,n]}};let I="Reached end of buffer unexpectedly";function guardedShift(e){if(0===e.length)throw Error(I);return e.shift()}function guardedSplice(e,...t){let[r]=t;if(2===t.length?r+(t[1]??0)>e.length:r>=e.length)throw Error(I);return e.splice(...t)}let Message=class Message{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 PublicKey(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:u().decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new MessageAccountKeys(this.staticAccountKeys)}static compile(e){let t=CompiledKeys.compile(e.instructions,e.payerKey),[r,n]=t.getMessageComponents(),i=new MessageAccountKeys(n),s=i.compileInstructions(e.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:u().encode(e.data)}));return new Message({header:r,accountKeys:n,recentBlockhash:e.recentBlockhash,instructions:s})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){let r=this.accountKeys.length-t,n=r-this.header.numReadonlyUnsignedAccounts;return e-t<n}{let r=t-this.header.numReadonlySignedAccounts;return e<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=[];encodeLength(t,e);let r=this.instructions.map(e=>{let{accounts:t,programIdIndex:r}=e,i=Array.from(u().decode(e.data)),s=[];encodeLength(s,t.length);let a=[];return encodeLength(a,i.length),{programIdIndex:r,keyIndicesCount:n.Buffer.from(s),keyIndices:t,dataLength:n.Buffer.from(a),data:i}}),i=[];encodeLength(i,r.length);let s=n.Buffer.alloc(1232);n.Buffer.from(i).copy(s);let a=i.length;r.forEach(e=>{let t=d.n_([d.u8("programIdIndex"),d.Ik(e.keyIndicesCount.length,"keyIndicesCount"),d.A9(d.u8("keyIndex"),e.keyIndices.length,"keyIndices"),d.Ik(e.dataLength.length,"dataLength"),d.A9(d.u8("userdatum"),e.data.length,"data")]),r=t.encode(e,s,a);a+=r}),s=s.slice(0,a);let o=d.n_([d.Ik(1,"numRequiredSignatures"),d.Ik(1,"numReadonlySignedAccounts"),d.Ik(1,"numReadonlyUnsignedAccounts"),d.Ik(t.length,"keyCount"),d.A9(publicKey("key"),e,"keys"),publicKey("recentBlockhash")]),c={numRequiredSignatures:n.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:n.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:n.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:n.Buffer.from(t),keys:this.accountKeys.map(e=>toBuffer(e.toBytes())),recentBlockhash:u().decode(this.recentBlockhash)},l=n.Buffer.alloc(2048),h=o.encode(c,l);return s.copy(l,h),l.slice(0,h+s.length)}static from(e){let t=[...e],r=guardedShift(t);if(r!==(127&r))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let i=guardedShift(t),s=guardedShift(t),a=decodeLength(t),o=[];for(let e=0;e<a;e++){let e=guardedSplice(t,0,32);o.push(new PublicKey(n.Buffer.from(e)))}let c=guardedSplice(t,0,32),l=decodeLength(t),d=[];for(let e=0;e<l;e++){let e=guardedShift(t),r=decodeLength(t),i=guardedSplice(t,0,r),s=decodeLength(t),a=guardedSplice(t,0,s),o=u().encode(n.Buffer.from(a));d.push({programIdIndex:e,accounts:i,data:o})}let h={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:u().encode(n.Buffer.from(c)),accountKeys:o,instructions:d};return new Message(h)}};let MessageV0=class MessageV0{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 MessageAccountKeys(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){let t=this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0);return e-r<t}if(e>=this.header.numRequiredSignatures){let n=r-t-this.header.numReadonlyUnsignedAccounts;return e-t<n}{let r=t-this.header.numReadonlySignedAccounts;return e<r}}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=CompiledKeys.compile(e.instructions,e.payerKey),r=[],n={writable:[],readonly:[]},i=e.addressLookupTableAccounts||[];for(let e of i){let i=t.extractTableLookup(e);if(void 0!==i){let[e,{writable:t,readonly:s}]=i;r.push(e),n.writable.push(...t),n.readonly.push(...s)}}let[s,a]=t.getMessageComponents(),o=new MessageAccountKeys(a,n),u=o.compileInstructions(e.instructions);return new MessageV0({header:s,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:u,addressTableLookups:r})}serialize(){let e=[];encodeLength(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),r=[];encodeLength(r,this.compiledInstructions.length);let n=this.serializeAddressTableLookups(),i=[];encodeLength(i,this.addressTableLookups.length);let s=d.n_([d.u8("prefix"),d.n_([d.u8("numRequiredSignatures"),d.u8("numReadonlySignedAccounts"),d.u8("numReadonlyUnsignedAccounts")],"header"),d.Ik(e.length,"staticAccountKeysLength"),d.A9(publicKey(),this.staticAccountKeys.length,"staticAccountKeys"),publicKey("recentBlockhash"),d.Ik(r.length,"instructionsLength"),d.Ik(t.length,"serializedInstructions"),d.Ik(i.length,"addressTableLookupsLength"),d.Ik(n.length,"serializedAddressTableLookups")]),a=new Uint8Array(1232),o=s.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:u().decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:n},a);return a.slice(0,o)}serializeInstructions(){let e=0,t=new Uint8Array(1232);for(let r of this.compiledInstructions){let n=[];encodeLength(n,r.accountKeyIndexes.length);let i=[];encodeLength(i,r.data.length);let s=d.n_([d.u8("programIdIndex"),d.Ik(n.length,"encodedAccountKeyIndexesLength"),d.A9(d.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),d.Ik(i.length,"encodedDataLength"),d.Ik(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(1232);for(let r of this.addressTableLookups){let n=[];encodeLength(n,r.writableIndexes.length);let i=[];encodeLength(i,r.readonlyIndexes.length);let s=d.n_([publicKey("accountKey"),d.Ik(n.length,"encodedWritableIndexesLength"),d.A9(d.u8(),r.writableIndexes.length,"writableIndexes"),d.Ik(i.length,"encodedReadonlyIndexesLength"),d.A9(d.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=guardedShift(t),n=127&r;assert(r!==n,"Expected versioned message but received legacy message"),assert(0===n,`Expected versioned message with version 0 but found version ${n}`);let i={numRequiredSignatures:guardedShift(t),numReadonlySignedAccounts:guardedShift(t),numReadonlyUnsignedAccounts:guardedShift(t)},s=[],a=decodeLength(t);for(let e=0;e<a;e++)s.push(new PublicKey(guardedSplice(t,0,32)));let o=u().encode(guardedSplice(t,0,32)),c=decodeLength(t),l=[];for(let e=0;e<c;e++){let e=guardedShift(t),r=decodeLength(t),n=guardedSplice(t,0,r),i=decodeLength(t),s=new Uint8Array(guardedSplice(t,0,i));l.push({programIdIndex:e,accountKeyIndexes:n,data:s})}let d=decodeLength(t),h=[];for(let e=0;e<d;e++){let e=new PublicKey(guardedSplice(t,0,32)),r=decodeLength(t),n=guardedSplice(t,0,r),i=decodeLength(t),s=guardedSplice(t,0,i);h.push({accountKey:e,writableIndexes:n,readonlyIndexes:s})}return new MessageV0({header:i,staticAccountKeys:s,recentBlockhash:o,compiledInstructions:l,addressTableLookups:h})}};let S={deserializeMessageVersion(e){let t=e[0],r=127&t;return r===t?"legacy":r},deserialize:e=>{let t=S.deserializeMessageVersion(e);if("legacy"===t)return Message.from(e);if(0===t)return MessageV0.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},x=n.Buffer.alloc(64).fill(0);let TransactionInstruction=class TransactionInstruction{constructor(e){this.keys=void 0,this.programId=void 0,this.data=n.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}};let Transaction=class Transaction{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 TransactionInstruction(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 PublicKey(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 a=s.findIndex(e=>e.pubkey.equals(r));if(a>-1){let[e]=s.splice(a,1);e.isSigner=!0,e.isWritable=!0,s.unshift(e)}else s.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=s.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)s[t].isSigner||(s[t].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let o=0,c=0,l=0,d=[],h=[];s.forEach(({pubkey:e,isSigner:t,isWritable:r})=>{t?(d.push(e.toString()),o+=1,r||(c+=1)):(h.push(e.toString()),r||(l+=1))});let g=d.concat(h),p=t.map(e=>{let{data:t,programId:r}=e;return{programIdIndex:g.indexOf(r.toString()),accounts:e.keys.map(e=>g.indexOf(e.pubkey.toString())),data:u().encode(t)}});return p.forEach(e=>{assert(e.programIdIndex>=0),e.accounts.forEach(e=>assert(e>=0))}),new Message({header:{numRequiredSignatures:o,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:g,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);if(this.signatures.length===t.length){let r=this.signatures.every((e,r)=>t[r].equals(e.publicKey));if(r)return e}return 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();t.forEach(e=>{let t=sign(r,e.secretKey);this._addSignature(e.publicKey,toBuffer(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){assert(64===t.length);let r=this.signatures.findIndex(t=>e.equals(t.publicKey));if(r<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=n.Buffer.from(t)}verifySignatures(e=!0){let t=this._getMessageSignednessErrors(this.serializeMessage(),e);return!t}_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+=`
Invalid signature for public key${1===e.invalid.length?"":"(s)"} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`
Missing 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=[];encodeLength(r,t.length);let i=r.length+64*t.length+e.length,s=n.Buffer.alloc(i);return assert(t.length<256),n.Buffer.from(r).copy(s,0),t.forEach(({signature:e},t)=>{null!==e&&(assert(64===e.length,"signature has invalid length"),n.Buffer.from(e).copy(s,r.length+64*t))}),e.copy(s,r.length+64*t.length),assert(s.length<=1232,`Transaction too large: ${s.length} > 1232`),s}get keys(){return assert(1===this.instructions.length),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return assert(1===this.instructions.length),this.instructions[0].programId}get data(){return assert(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e],r=decodeLength(t),i=[];for(let e=0;e<r;e++){let e=guardedSplice(t,0,64);i.push(u().encode(n.Buffer.from(e)))}return Transaction.populate(Message.from(t),i)}static populate(e,t=[]){let r=new Transaction;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((t,n)=>{let i={signature:t==u().encode(x)?null:u().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 TransactionInstruction({keys:n,programId:e.accountKeys[t.programIdIndex],data:u().decode(t.data)}))}),r._message=e,r._json=r.toJSON(),r}};let VersionedTransaction=class VersionedTransaction{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,void 0!==t)assert(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(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];encodeLength(t,this.signatures.length);let r=d.n_([d.Ik(t.length,"encodedSignaturesLength"),d.A9(signature(),this.signatures.length,"signatures"),d.Ik(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=decodeLength(t);for(let e=0;e<n;e++)r.push(new Uint8Array(guardedSplice(t,0,64)));let i=S.deserialize(new Uint8Array(t));return new VersionedTransaction(i,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));assert(e>=0,`Cannot sign with non signer key ${n.publicKey.toBase58()}`),this.signatures[e]=sign(t,n.secretKey)}}addSignature(e,t){assert(64===t.byteLength,"Signature must be 64 bytes long");let r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures),n=r.findIndex(t=>t.equals(e));assert(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}};let A=new PublicKey("SysvarC1ock11111111111111111111111111111111");new PublicKey("SysvarEpochSchedu1e111111111111111111111111"),new PublicKey("Sysvar1nstructions1111111111111111111111111");let w=new PublicKey("SysvarRecentB1ockHashes11111111111111111111"),R=new PublicKey("SysvarRent111111111111111111111111111111111");new PublicKey("SysvarRewards111111111111111111111111111111"),new PublicKey("SysvarS1otHashes111111111111111111111111111"),new PublicKey("SysvarS1otHistory11111111111111111111111111");let K=new PublicKey("SysvarStakeHistory1111111111111111111111111");let SendTransactionError=class SendTransactionError extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:n}){let i;let s=n?`Logs: 
${JSON.stringify(n.slice(-10),null,2)}. `:"",a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";switch(e){case"send":i=`Transaction ${t} resulted in an error. 
${r}. `+s+a;break;case"simulate":i=`Simulation failed. 
Message: ${r}. 
`+s+a;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}};async function sendAndConfirmTransaction(e,t,r,n){let i;let s=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},a=await e.sendTransaction(t,r,s);if(null!=t.recentBlockhash&&null!=t.lastValidBlockHeight)i=(await e.confirmTransaction({abortSignal:n?.abortSignal,signature:a,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:a},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(a,n&&n.commitment)).value;if(i.err){if(null!=a)throw new SendTransactionError({action:"send",signature:a,transactionMessage:`Status: (${JSON.stringify(i)})`});throw Error(`Transaction ${a} failed (${JSON.stringify(i)})`)}return a}function encodeData(e,t){let r=e.layout.span>=0?e.layout.span:function getAlloc(e,t){let getItemAlloc=e=>{if(e.span>=0)return e.span;if("function"==typeof e.alloc)return e.alloc(t[e.property]);if("count"in e&&"elementLayout"in e){let r=t[e.property];if(Array.isArray(r))return r.length*getItemAlloc(e.elementLayout)}else if("fields"in e)return getAlloc({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=getItemAlloc(e)}),r}(e,t),i=n.Buffer.alloc(r),s=Object.assign({instruction:e.index},t);return e.layout.encode(s,i),i}let P=d._O("lamportsPerSignature"),B=d.n_([d.Jq("version"),d.Jq("state"),publicKey("authorizedPubkey"),publicKey("nonce"),d.n_([P],"feeCalculator")]),_=B.span,encodeDecode=e=>{let t=e.decode.bind(e),r=e.encode.bind(e);return{decode:t,encode:r}},u64=e=>{let t=(0,d.Ik)(8,e),{encode:r,decode:i}=encodeDecode(t);return t.decode=(e,t)=>{let r=i(e,t);return(0,h.oU)(n.Buffer.from(r))},t.encode=(e,t,n)=>{let i=(0,h.k$)(e,8);return r(i,t,n)},t},v=Object.freeze({Create:{index:0,layout:d.n_([d.Jq("instruction"),d.gM("lamports"),d.gM("space"),publicKey("programId")])},Assign:{index:1,layout:d.n_([d.Jq("instruction"),publicKey("programId")])},Transfer:{index:2,layout:d.n_([d.Jq("instruction"),u64("lamports")])},CreateWithSeed:{index:3,layout:d.n_([d.Jq("instruction"),publicKey("base"),rustString("seed"),d.gM("lamports"),d.gM("space"),publicKey("programId")])},AdvanceNonceAccount:{index:4,layout:d.n_([d.Jq("instruction")])},WithdrawNonceAccount:{index:5,layout:d.n_([d.Jq("instruction"),d.gM("lamports")])},InitializeNonceAccount:{index:6,layout:d.n_([d.Jq("instruction"),publicKey("authorized")])},AuthorizeNonceAccount:{index:7,layout:d.n_([d.Jq("instruction"),publicKey("authorized")])},Allocate:{index:8,layout:d.n_([d.Jq("instruction"),d.gM("space")])},AllocateWithSeed:{index:9,layout:d.n_([d.Jq("instruction"),publicKey("base"),rustString("seed"),d.gM("space"),publicKey("programId")])},AssignWithSeed:{index:10,layout:d.n_([d.Jq("instruction"),publicKey("base"),rustString("seed"),publicKey("programId")])},TransferWithSeed:{index:11,layout:d.n_([d.Jq("instruction"),u64("lamports"),rustString("seed"),publicKey("programId")])},UpgradeNonceAccount:{index:12,layout:d.n_([d.Jq("instruction")])}});let SystemProgram=class SystemProgram{constructor(){}static createAccount(e){let t=v.Create,r=encodeData(t,{lamports:e.lamports,space:e.space,programId:toBuffer(e.programId.toBuffer())});return new TransactionInstruction({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let t,r;if("basePubkey"in e){let n=v.TransferWithSeed;t=encodeData(n,{lamports:BigInt(e.lamports),seed:e.seed,programId:toBuffer(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}]}else{let n=v.Transfer;t=encodeData(n,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new TransactionInstruction({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;if("basePubkey"in e){let n=v.AssignWithSeed;t=encodeData(n,{base:toBuffer(e.basePubkey.toBuffer()),seed:e.seed,programId:toBuffer(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let n=v.Assign;t=encodeData(n,{programId:toBuffer(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new TransactionInstruction({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=v.CreateWithSeed,r=encodeData(t,{base:toBuffer(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:toBuffer(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||n.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new TransactionInstruction({keys:n,programId:this.programId,data:r})}static createNonceAccount(e){let t=new Transaction;"basePubkey"in e&&"seed"in e?t.add(SystemProgram.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:_,programId:this.programId})):t.add(SystemProgram.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:_,programId:this.programId}));let r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){let t=v.InitializeNonceAccount,r=encodeData(t,{authorized:toBuffer(e.authorizedPubkey.toBuffer())}),n={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:w,isSigner:!1,isWritable:!1},{pubkey:R,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new TransactionInstruction(n)}static nonceAdvance(e){let t=v.AdvanceNonceAccount,r=encodeData(t),n={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:w,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new TransactionInstruction(n)}static nonceWithdraw(e){let t=v.WithdrawNonceAccount,r=encodeData(t,{lamports:e.lamports});return new TransactionInstruction({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:w,isSigner:!1,isWritable:!1},{pubkey:R,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){let t=v.AuthorizeNonceAccount,r=encodeData(t,{authorized:toBuffer(e.newAuthorizedPubkey.toBuffer())});return new TransactionInstruction({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let t,r;if("basePubkey"in e){let n=v.AllocateWithSeed;t=encodeData(n,{base:toBuffer(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:toBuffer(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let n=v.Allocate;t=encodeData(n,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new TransactionInstruction({keys:r,programId:this.programId,data:t})}};SystemProgram.programId=new PublicKey("11111111111111111111111111111111");let Loader=class Loader{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/Loader.chunkSize)+1+1)}static async load(e,t,r,i,s){{let n=await e.getMinimumBalanceForRentExemption(s.length),a=await e.getAccountInfo(r.publicKey,"confirmed"),o=null;if(null!==a){if(a.executable)return console.error("Program load failed, account is already executable"),!1;a.data.length!==s.length&&(o=o||new Transaction).add(SystemProgram.allocate({accountPubkey:r.publicKey,space:s.length})),a.owner.equals(i)||(o=o||new Transaction).add(SystemProgram.assign({accountPubkey:r.publicKey,programId:i})),a.lamports<n&&(o=o||new Transaction).add(SystemProgram.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:n-a.lamports}))}else o=new Transaction().add(SystemProgram.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:n>0?n:1,space:s.length,programId:i}));null!==o&&await sendAndConfirmTransaction(e,o,[t,r],{commitment:"confirmed"})}let a=d.n_([d.Jq("instruction"),d.Jq("offset"),d.Jq("bytesLength"),d.Jq("bytesLengthPadding"),d.A9(d.u8("byte"),d.cv(d.Jq(),-8),"bytes")]),o=Loader.chunkSize,u=0,c=s,l=[];for(;c.length>0;){let s=c.slice(0,o),d=n.Buffer.alloc(o+16);a.encode({instruction:0,offset:u,bytes:s,bytesLength:0,bytesLengthPadding:0},d);let h=new Transaction().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:d});l.push(sendAndConfirmTransaction(e,h,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await new Promise(e=>setTimeout(e,250)),u+=o,c=c.slice(o)}await Promise.all(l);{let s=d.n_([d.Jq("instruction")]),a=n.Buffer.alloc(s.span);s.encode({instruction:1},a);let o=new Transaction().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:R,isSigner:!1,isWritable:!1}],programId:i,data:a}),u="processed",c=await e.sendTransaction(o,[t,r],{preflightCommitment:u}),{context:l,value:h}=await e.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},u);if(h.err)throw Error(`Transaction ${c} failed (${JSON.stringify(h)})`);for(;;){try{let t=await e.getSlot({commitment:u});if(t>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(200)))}}return!0}};Loader.chunkSize=932,new PublicKey("BPFLoader2111111111111111111111111111111111"),d.n_([d.Jq("typeIndex"),u64("deactivationSlot"),d._O("lastExtendedSlot"),d.u8("lastExtendedStartIndex"),d.u8(),d.A9(publicKey(),d.cv(d.u8(),-1),"authority")]);let T=(0,g.oQ)((0,g.eE)(PublicKey),(0,g.Z_)(),e=>new PublicKey(e)),W=(0,g.bc)([(0,g.Z_)(),(0,g.i0)("base64")]),L=(0,g.oQ)((0,g.eE)(n.Buffer),W,e=>n.Buffer.from(e[0],"base64"));function createRpcResult(e){return(0,g.G0)([(0,g.dt)({jsonrpc:(0,g.i0)("2.0"),id:(0,g.Z_)(),result:e}),(0,g.dt)({jsonrpc:(0,g.i0)("2.0"),id:(0,g.Z_)(),error:(0,g.dt)({code:(0,g._4)(),message:(0,g.Z_)(),data:(0,g.jt)((0,g.Yj)())})})])}let z=createRpcResult((0,g._4)());function jsonRpcResult(e){return(0,g.oQ)(createRpcResult(e),z,t=>"error"in t?t:{...t,result:(0,g.Ue)(t.result,e)})}function jsonRpcResultAndContext(e){return jsonRpcResult((0,g.dt)({context:(0,g.dt)({slot:(0,g.Rx)()}),value:e}))}function notificationResultAndContext(e){return(0,g.dt)({context:(0,g.dt)({slot:(0,g.Rx)()}),value:e})}let j=(0,g.dt)({foundation:(0,g.Rx)(),foundationTerm:(0,g.Rx)(),initial:(0,g.Rx)(),taper:(0,g.Rx)(),terminal:(0,g.Rx)()});jsonRpcResult((0,g.IX)((0,g.AG)((0,g.dt)({epoch:(0,g.Rx)(),effectiveSlot:(0,g.Rx)(),amount:(0,g.Rx)(),postBalance:(0,g.Rx)(),commission:(0,g.jt)((0,g.AG)((0,g.Rx)()))}))));let E=(0,g.IX)((0,g.dt)({slot:(0,g.Rx)(),prioritizationFee:(0,g.Rx)()})),q=(0,g.dt)({total:(0,g.Rx)(),validator:(0,g.Rx)(),foundation:(0,g.Rx)(),epoch:(0,g.Rx)()}),O=(0,g.dt)({epoch:(0,g.Rx)(),slotIndex:(0,g.Rx)(),slotsInEpoch:(0,g.Rx)(),absoluteSlot:(0,g.Rx)(),blockHeight:(0,g.jt)((0,g.Rx)()),transactionCount:(0,g.jt)((0,g.Rx)())}),G=(0,g.dt)({slotsPerEpoch:(0,g.Rx)(),leaderScheduleSlotOffset:(0,g.Rx)(),warmup:(0,g.O7)(),firstNormalEpoch:(0,g.Rx)(),firstNormalSlot:(0,g.Rx)()}),Z=(0,g.IM)((0,g.Z_)(),(0,g.IX)((0,g.Rx)())),C=(0,g.AG)((0,g.G0)([(0,g.dt)({}),(0,g.Z_)()])),M=(0,g.dt)({err:C}),J=(0,g.i0)("receivedSignature");(0,g.dt)({"solana-core":(0,g.Z_)(),"feature-set":(0,g.jt)((0,g.Rx)())});let X=(0,g.dt)({program:(0,g.Z_)(),programId:T,parsed:(0,g._4)()}),U=(0,g.dt)({programId:T,accounts:(0,g.IX)(T),data:(0,g.Z_)()});jsonRpcResultAndContext((0,g.dt)({err:(0,g.AG)((0,g.G0)([(0,g.dt)({}),(0,g.Z_)()])),logs:(0,g.AG)((0,g.IX)((0,g.Z_)())),accounts:(0,g.jt)((0,g.AG)((0,g.IX)((0,g.AG)((0,g.dt)({executable:(0,g.O7)(),owner:(0,g.Z_)(),lamports:(0,g.Rx)(),data:(0,g.IX)((0,g.Z_)()),rentEpoch:(0,g.jt)((0,g.Rx)())}))))),unitsConsumed:(0,g.jt)((0,g.Rx)()),returnData:(0,g.jt)((0,g.AG)((0,g.dt)({programId:(0,g.Z_)(),data:(0,g.bc)([(0,g.Z_)(),(0,g.i0)("base64")])}))),innerInstructions:(0,g.jt)((0,g.AG)((0,g.IX)((0,g.dt)({index:(0,g.Rx)(),instructions:(0,g.IX)((0,g.G0)([X,U]))}))))})),jsonRpcResultAndContext((0,g.dt)({byIdentity:(0,g.IM)((0,g.Z_)(),(0,g.IX)((0,g.Rx)())),range:(0,g.dt)({firstSlot:(0,g.Rx)(),lastSlot:(0,g.Rx)()})})),jsonRpcResult(j),jsonRpcResult(q),jsonRpcResult(E),jsonRpcResult(O),jsonRpcResult(G),jsonRpcResult(Z),jsonRpcResult((0,g.Rx)()),jsonRpcResultAndContext((0,g.dt)({total:(0,g.Rx)(),circulating:(0,g.Rx)(),nonCirculating:(0,g.Rx)(),nonCirculatingAccounts:(0,g.IX)(T)}));let D=(0,g.dt)({amount:(0,g.Z_)(),uiAmount:(0,g.AG)((0,g.Rx)()),decimals:(0,g.Rx)(),uiAmountString:(0,g.jt)((0,g.Z_)())});jsonRpcResultAndContext((0,g.IX)((0,g.dt)({address:T,amount:(0,g.Z_)(),uiAmount:(0,g.AG)((0,g.Rx)()),decimals:(0,g.Rx)(),uiAmountString:(0,g.jt)((0,g.Z_)())}))),jsonRpcResultAndContext((0,g.IX)((0,g.dt)({pubkey:T,account:(0,g.dt)({executable:(0,g.O7)(),owner:T,lamports:(0,g.Rx)(),data:L,rentEpoch:(0,g.Rx)()})})));let N=(0,g.dt)({program:(0,g.Z_)(),parsed:(0,g._4)(),space:(0,g.Rx)()});jsonRpcResultAndContext((0,g.IX)((0,g.dt)({pubkey:T,account:(0,g.dt)({executable:(0,g.O7)(),owner:T,lamports:(0,g.Rx)(),data:N,rentEpoch:(0,g.Rx)()})}))),jsonRpcResultAndContext((0,g.IX)((0,g.dt)({lamports:(0,g.Rx)(),address:T})));let V=(0,g.dt)({executable:(0,g.O7)(),owner:T,lamports:(0,g.Rx)(),data:L,rentEpoch:(0,g.Rx)()});(0,g.dt)({pubkey:T,account:V});let $=(0,g.oQ)((0,g.G0)([(0,g.eE)(n.Buffer),N]),(0,g.G0)([W,N]),e=>Array.isArray(e)?(0,g.Ue)(e,L):e),F=(0,g.dt)({executable:(0,g.O7)(),owner:T,lamports:(0,g.Rx)(),data:$,rentEpoch:(0,g.Rx)()});(0,g.dt)({pubkey:T,account:F}),(0,g.dt)({state:(0,g.G0)([(0,g.i0)("active"),(0,g.i0)("inactive"),(0,g.i0)("activating"),(0,g.i0)("deactivating")]),active:(0,g.Rx)(),inactive:(0,g.Rx)()}),jsonRpcResult((0,g.IX)((0,g.dt)({signature:(0,g.Z_)(),slot:(0,g.Rx)(),err:C,memo:(0,g.AG)((0,g.Z_)()),blockTime:(0,g.jt)((0,g.AG)((0,g.Rx)()))}))),jsonRpcResult((0,g.IX)((0,g.dt)({signature:(0,g.Z_)(),slot:(0,g.Rx)(),err:C,memo:(0,g.AG)((0,g.Z_)()),blockTime:(0,g.jt)((0,g.AG)((0,g.Rx)()))}))),(0,g.dt)({subscription:(0,g.Rx)(),result:notificationResultAndContext(V)});let H=(0,g.dt)({pubkey:T,account:V});(0,g.dt)({subscription:(0,g.Rx)(),result:notificationResultAndContext(H)});let Q=(0,g.dt)({parent:(0,g.Rx)(),slot:(0,g.Rx)(),root:(0,g.Rx)()});(0,g.dt)({subscription:(0,g.Rx)(),result:Q});let Y=(0,g.G0)([(0,g.dt)({type:(0,g.G0)([(0,g.i0)("firstShredReceived"),(0,g.i0)("completed"),(0,g.i0)("optimisticConfirmation"),(0,g.i0)("root")]),slot:(0,g.Rx)(),timestamp:(0,g.Rx)()}),(0,g.dt)({type:(0,g.i0)("createdBank"),parent:(0,g.Rx)(),slot:(0,g.Rx)(),timestamp:(0,g.Rx)()}),(0,g.dt)({type:(0,g.i0)("frozen"),slot:(0,g.Rx)(),timestamp:(0,g.Rx)(),stats:(0,g.dt)({numTransactionEntries:(0,g.Rx)(),numSuccessfulTransactions:(0,g.Rx)(),numFailedTransactions:(0,g.Rx)(),maxTransactionsPerEntry:(0,g.Rx)()})}),(0,g.dt)({type:(0,g.i0)("dead"),slot:(0,g.Rx)(),timestamp:(0,g.Rx)(),err:(0,g.Z_)()})]);(0,g.dt)({subscription:(0,g.Rx)(),result:Y}),(0,g.dt)({subscription:(0,g.Rx)(),result:notificationResultAndContext((0,g.G0)([M,J]))}),(0,g.dt)({subscription:(0,g.Rx)(),result:(0,g.Rx)()}),(0,g.dt)({pubkey:(0,g.Z_)(),gossip:(0,g.AG)((0,g.Z_)()),tpu:(0,g.AG)((0,g.Z_)()),rpc:(0,g.AG)((0,g.Z_)()),version:(0,g.AG)((0,g.Z_)())});let ee=(0,g.dt)({votePubkey:(0,g.Z_)(),nodePubkey:(0,g.Z_)(),activatedStake:(0,g.Rx)(),epochVoteAccount:(0,g.O7)(),epochCredits:(0,g.IX)((0,g.bc)([(0,g.Rx)(),(0,g.Rx)(),(0,g.Rx)()])),commission:(0,g.Rx)(),lastVote:(0,g.Rx)(),rootSlot:(0,g.AG)((0,g.Rx)())});jsonRpcResult((0,g.dt)({current:(0,g.IX)(ee),delinquent:(0,g.IX)(ee)}));let et=(0,g.G0)([(0,g.i0)("processed"),(0,g.i0)("confirmed"),(0,g.i0)("finalized")]),er=(0,g.dt)({slot:(0,g.Rx)(),confirmations:(0,g.AG)((0,g.Rx)()),err:C,confirmationStatus:(0,g.jt)(et)});jsonRpcResultAndContext((0,g.IX)((0,g.AG)(er))),jsonRpcResult((0,g.Rx)());let en=(0,g.dt)({accountKey:T,writableIndexes:(0,g.IX)((0,g.Rx)()),readonlyIndexes:(0,g.IX)((0,g.Rx)())}),ei=(0,g.dt)({signatures:(0,g.IX)((0,g.Z_)()),message:(0,g.dt)({accountKeys:(0,g.IX)((0,g.Z_)()),header:(0,g.dt)({numRequiredSignatures:(0,g.Rx)(),numReadonlySignedAccounts:(0,g.Rx)(),numReadonlyUnsignedAccounts:(0,g.Rx)()}),instructions:(0,g.IX)((0,g.dt)({accounts:(0,g.IX)((0,g.Rx)()),data:(0,g.Z_)(),programIdIndex:(0,g.Rx)()})),recentBlockhash:(0,g.Z_)(),addressTableLookups:(0,g.jt)((0,g.IX)(en))})}),es=(0,g.dt)({pubkey:T,signer:(0,g.O7)(),writable:(0,g.O7)(),source:(0,g.jt)((0,g.G0)([(0,g.i0)("transaction"),(0,g.i0)("lookupTable")]))}),ea=(0,g.dt)({accountKeys:(0,g.IX)(es),signatures:(0,g.IX)((0,g.Z_)())}),eo=(0,g.dt)({parsed:(0,g._4)(),program:(0,g.Z_)(),programId:T}),eu=(0,g.dt)({accounts:(0,g.IX)(T),data:(0,g.Z_)(),programId:T}),ec=(0,g.G0)([eu,eo]),el=(0,g.G0)([(0,g.dt)({parsed:(0,g._4)(),program:(0,g.Z_)(),programId:(0,g.Z_)()}),(0,g.dt)({accounts:(0,g.IX)((0,g.Z_)()),data:(0,g.Z_)(),programId:(0,g.Z_)()})]),ed=(0,g.oQ)(ec,el,e=>"accounts"in e?(0,g.Ue)(e,eu):(0,g.Ue)(e,eo)),eh=(0,g.dt)({signatures:(0,g.IX)((0,g.Z_)()),message:(0,g.dt)({accountKeys:(0,g.IX)(es),instructions:(0,g.IX)(ed),recentBlockhash:(0,g.Z_)(),addressTableLookups:(0,g.jt)((0,g.AG)((0,g.IX)(en)))})}),eg=(0,g.dt)({accountIndex:(0,g.Rx)(),mint:(0,g.Z_)(),owner:(0,g.jt)((0,g.Z_)()),programId:(0,g.jt)((0,g.Z_)()),uiTokenAmount:D}),ep=(0,g.dt)({writable:(0,g.IX)(T),readonly:(0,g.IX)(T)}),ey=(0,g.dt)({err:C,fee:(0,g.Rx)(),innerInstructions:(0,g.jt)((0,g.AG)((0,g.IX)((0,g.dt)({index:(0,g.Rx)(),instructions:(0,g.IX)((0,g.dt)({accounts:(0,g.IX)((0,g.Rx)()),data:(0,g.Z_)(),programIdIndex:(0,g.Rx)()}))})))),preBalances:(0,g.IX)((0,g.Rx)()),postBalances:(0,g.IX)((0,g.Rx)()),logMessages:(0,g.jt)((0,g.AG)((0,g.IX)((0,g.Z_)()))),preTokenBalances:(0,g.jt)((0,g.AG)((0,g.IX)(eg))),postTokenBalances:(0,g.jt)((0,g.AG)((0,g.IX)(eg))),loadedAddresses:(0,g.jt)(ep),computeUnitsConsumed:(0,g.jt)((0,g.Rx)())}),ef=(0,g.dt)({err:C,fee:(0,g.Rx)(),innerInstructions:(0,g.jt)((0,g.AG)((0,g.IX)((0,g.dt)({index:(0,g.Rx)(),instructions:(0,g.IX)(ed)})))),preBalances:(0,g.IX)((0,g.Rx)()),postBalances:(0,g.IX)((0,g.Rx)()),logMessages:(0,g.jt)((0,g.AG)((0,g.IX)((0,g.Z_)()))),preTokenBalances:(0,g.jt)((0,g.AG)((0,g.IX)(eg))),postTokenBalances:(0,g.jt)((0,g.AG)((0,g.IX)(eg))),loadedAddresses:(0,g.jt)(ep),computeUnitsConsumed:(0,g.jt)((0,g.Rx)())}),eb=(0,g.G0)([(0,g.i0)(0),(0,g.i0)("legacy")]),em=(0,g.dt)({pubkey:(0,g.Z_)(),lamports:(0,g.Rx)(),postBalance:(0,g.AG)((0,g.Rx)()),rewardType:(0,g.AG)((0,g.Z_)()),commission:(0,g.jt)((0,g.AG)((0,g.Rx)()))});jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),transactions:(0,g.IX)((0,g.dt)({transaction:ei,meta:(0,g.AG)(ey),version:(0,g.jt)(eb)})),rewards:(0,g.jt)((0,g.IX)(em)),blockTime:(0,g.AG)((0,g.Rx)()),blockHeight:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),rewards:(0,g.jt)((0,g.IX)(em)),blockTime:(0,g.AG)((0,g.Rx)()),blockHeight:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),transactions:(0,g.IX)((0,g.dt)({transaction:ea,meta:(0,g.AG)(ey),version:(0,g.jt)(eb)})),rewards:(0,g.jt)((0,g.IX)(em)),blockTime:(0,g.AG)((0,g.Rx)()),blockHeight:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),transactions:(0,g.IX)((0,g.dt)({transaction:eh,meta:(0,g.AG)(ef),version:(0,g.jt)(eb)})),rewards:(0,g.jt)((0,g.IX)(em)),blockTime:(0,g.AG)((0,g.Rx)()),blockHeight:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),transactions:(0,g.IX)((0,g.dt)({transaction:ea,meta:(0,g.AG)(ef),version:(0,g.jt)(eb)})),rewards:(0,g.jt)((0,g.IX)(em)),blockTime:(0,g.AG)((0,g.Rx)()),blockHeight:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),rewards:(0,g.jt)((0,g.IX)(em)),blockTime:(0,g.AG)((0,g.Rx)()),blockHeight:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),transactions:(0,g.IX)((0,g.dt)({transaction:ei,meta:(0,g.AG)(ey)})),rewards:(0,g.jt)((0,g.IX)(em)),blockTime:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({blockhash:(0,g.Z_)(),previousBlockhash:(0,g.Z_)(),parentSlot:(0,g.Rx)(),signatures:(0,g.IX)((0,g.Z_)()),blockTime:(0,g.AG)((0,g.Rx)())}))),jsonRpcResult((0,g.AG)((0,g.dt)({slot:(0,g.Rx)(),meta:(0,g.AG)(ey),blockTime:(0,g.jt)((0,g.AG)((0,g.Rx)())),transaction:ei,version:(0,g.jt)(eb)}))),jsonRpcResult((0,g.AG)((0,g.dt)({slot:(0,g.Rx)(),transaction:eh,meta:(0,g.AG)(ef),blockTime:(0,g.jt)((0,g.AG)((0,g.Rx)())),version:(0,g.jt)(eb)}))),jsonRpcResultAndContext((0,g.dt)({blockhash:(0,g.Z_)(),lastValidBlockHeight:(0,g.Rx)()})),jsonRpcResultAndContext((0,g.O7)());let ek=(0,g.dt)({slot:(0,g.Rx)(),numTransactions:(0,g.Rx)(),numSlots:(0,g.Rx)(),samplePeriodSecs:(0,g.Rx)()});jsonRpcResult((0,g.IX)(ek)),jsonRpcResultAndContext((0,g.AG)((0,g.dt)({feeCalculator:(0,g.dt)({lamportsPerSignature:(0,g.Rx)()})}))),jsonRpcResult((0,g.Z_)()),jsonRpcResult((0,g.Z_)());let eI=(0,g.dt)({err:C,logs:(0,g.IX)((0,g.Z_)()),signature:(0,g.Z_)()});(0,g.dt)({result:notificationResultAndContext(eI),subscription:(0,g.Rx)()});let Keypair=class Keypair{constructor(e){this._keypair=void 0,this._keypair=e??generateKeypair()}static generate(){return new Keypair(generateKeypair())}static fromSecretKey(e,t){if(64!==e.byteLength)throw Error("bad secret key size");let r=e.slice(32,64);if(!t||!t.skipValidation){let t=e.slice(0,32),n=f(t);for(let e=0;e<32;e++)if(r[e]!==n[e])throw Error("provided secretKey is invalid")}return new Keypair({publicKey:r,secretKey:e})}static fromSeed(e){let t=f(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new Keypair({publicKey:t,secretKey:r})}get publicKey(){return new PublicKey(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}};Object.freeze({CreateLookupTable:{index:0,layout:d.n_([d.Jq("instruction"),u64("recentSlot"),d.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:d.n_([d.Jq("instruction")])},ExtendLookupTable:{index:2,layout:d.n_([d.Jq("instruction"),u64(),d.A9(publicKey(),d.cv(d.Jq(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:d.n_([d.Jq("instruction")])},CloseLookupTable:{index:4,layout:d.n_([d.Jq("instruction")])}}),new PublicKey("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:d.n_([d.u8("instruction"),d.Jq("units"),d.Jq("additionalFee")])},RequestHeapFrame:{index:1,layout:d.n_([d.u8("instruction"),d.Jq("bytes")])},SetComputeUnitLimit:{index:2,layout:d.n_([d.u8("instruction"),d.Jq("units")])},SetComputeUnitPrice:{index:3,layout:d.n_([d.u8("instruction"),u64("microLamports")])}}),new PublicKey("ComputeBudget111111111111111111111111111111");let eS=d.n_([d.u8("numSignatures"),d.u8("padding"),d.KB("signatureOffset"),d.KB("signatureInstructionIndex"),d.KB("publicKeyOffset"),d.KB("publicKeyInstructionIndex"),d.KB("messageDataOffset"),d.KB("messageDataSize"),d.KB("messageInstructionIndex")]);let Ed25519Program=class Ed25519Program{constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:i,instructionIndex:s}=e;assert(32===t.length,`Public Key must be 32 bytes but received ${t.length} bytes`),assert(64===i.length,`Signature must be 64 bytes but received ${i.length} bytes`);let a=eS.span,o=a+t.length,u=o+i.length,c=n.Buffer.alloc(u+r.length),l=null==s?65535:s;return eS.encode({numSignatures:1,padding:0,signatureOffset:o,signatureInstructionIndex:l,publicKeyOffset:a,publicKeyInstructionIndex:l,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:l},c),c.fill(t,a),c.fill(i,o),c.fill(r,u),new TransactionInstruction({keys:[],programId:Ed25519Program.programId,data:c})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:n}=e;assert(64===t.length,`Private key must be 64 bytes but received ${t.length} bytes`);try{let e=Keypair.fromSecretKey(t),i=e.publicKey.toBytes(),s=sign(r,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:r,signature:s,instructionIndex:n})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Ed25519Program.programId=new PublicKey("Ed25519SigVerify111111111111111111111111111");let ecdsaSign=(e,t)=>{let r=y.kA.sign(e,t);return[r.toCompactRawBytes(),r.recovery]};y.kA.utils.isValidPrivateKey;let ex=y.kA.getPublicKey,eA=d.n_([d.u8("numSignatures"),d.KB("signatureOffset"),d.u8("signatureInstructionIndex"),d.KB("ethAddressOffset"),d.u8("ethAddressInstructionIndex"),d.KB("messageDataOffset"),d.KB("messageDataSize"),d.u8("messageInstructionIndex"),d.Ik(20,"ethAddress"),d.Ik(64,"signature"),d.u8("recoveryId")]);let Secp256k1Program=class Secp256k1Program{constructor(){}static publicKeyToEthAddress(e){assert(64===e.length,`Public key must be 64 bytes but received ${e.length} bytes`);try{return n.Buffer.from((0,p.fr)(toBuffer(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 Secp256k1Program.createInstructionWithEthAddress({ethAddress:Secp256k1Program.publicKeyToEthAddress(t),message:r,signature:n,recoveryId:i,instructionIndex:s})}static createInstructionWithEthAddress(e){let t;let{ethAddress:r,message:i,signature:s,recoveryId:a,instructionIndex:o=0}=e;assert(20===(t="string"==typeof r?r.startsWith("0x")?n.Buffer.from(r.substr(2),"hex"):n.Buffer.from(r,"hex"):r).length,`Address must be 20 bytes but received ${t.length} bytes`);let u=12+t.length,c=u+s.length+1,l=n.Buffer.alloc(eA.span+i.length);return eA.encode({numSignatures:1,signatureOffset:u,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:c,messageDataSize:i.length,messageInstructionIndex:o,signature:toBuffer(s),ethAddress:toBuffer(t),recoveryId:a},l),l.fill(toBuffer(i),eA.span),new TransactionInstruction({keys:[],programId:Secp256k1Program.programId,data:l})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:i}=e;assert(32===t.length,`Private key must be 32 bytes but received ${t.length} bytes`);try{let e=toBuffer(t),s=ex(e,!1).slice(1),a=n.Buffer.from((0,p.fr)(toBuffer(r))),[o,u]=ecdsaSign(a,e);return this.createInstructionWithPublicKey({publicKey:s,message:r,signature:o,recoveryId:u,instructionIndex:i})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Secp256k1Program.programId=new PublicKey("KeccakSecp256k11111111111111111111111111111");let ew=new PublicKey("StakeConfig11111111111111111111111111111111");let Lockup=class Lockup{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}};Lockup.default=new Lockup(0,0,PublicKey.default);let eR=Object.freeze({Initialize:{index:0,layout:d.n_([d.Jq("instruction"),((e="authorized")=>d.n_([publicKey("staker"),publicKey("withdrawer")],e))(),((e="lockup")=>d.n_([d.gM("unixTimestamp"),d.gM("epoch"),publicKey("custodian")],e))()])},Authorize:{index:1,layout:d.n_([d.Jq("instruction"),publicKey("newAuthorized"),d.Jq("stakeAuthorizationType")])},Delegate:{index:2,layout:d.n_([d.Jq("instruction")])},Split:{index:3,layout:d.n_([d.Jq("instruction"),d.gM("lamports")])},Withdraw:{index:4,layout:d.n_([d.Jq("instruction"),d.gM("lamports")])},Deactivate:{index:5,layout:d.n_([d.Jq("instruction")])},Merge:{index:7,layout:d.n_([d.Jq("instruction")])},AuthorizeWithSeed:{index:8,layout:d.n_([d.Jq("instruction"),publicKey("newAuthorized"),d.Jq("stakeAuthorizationType"),rustString("authoritySeed"),publicKey("authorityOwner")])}});Object.freeze({Staker:{index:0},Withdrawer:{index:1}});let StakeProgram=class StakeProgram{constructor(){}static initialize(e){let{stakePubkey:t,authorized:r,lockup:n}=e,i=n||Lockup.default,s=eR.Initialize,a=encodeData(s,{authorized:{staker:toBuffer(r.staker.toBuffer()),withdrawer:toBuffer(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:toBuffer(i.custodian.toBuffer())}}),o={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:R,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new TransactionInstruction(o)}static createAccountWithSeed(e){let t=new Transaction;t.add(SystemProgram.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 Transaction;t.add(SystemProgram.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=eR.Delegate,s=encodeData(i);return new Transaction().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:A,isSigner:!1,isWritable:!1},{pubkey:K,isSigner:!1,isWritable:!1},{pubkey:ew,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static authorize(e){let{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:n,stakeAuthorizationType:i,custodianPubkey:s}=e,a=eR.Authorize,o=encodeData(a,{newAuthorized:toBuffer(n.toBuffer()),stakeAuthorizationType:i.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return s&&u.push({pubkey:s,isSigner:!0,isWritable:!1}),new Transaction().add({keys:u,programId:this.programId,data:o})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:r,authoritySeed:n,authorityOwner:i,newAuthorizedPubkey:s,stakeAuthorizationType:a,custodianPubkey:o}=e,u=eR.AuthorizeWithSeed,c=encodeData(u,{newAuthorized:toBuffer(s.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:n,authorityOwner:toBuffer(i.toBuffer())}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:A,isSigner:!1,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new Transaction().add({keys:l,programId:this.programId,data:c})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:n,lamports:i}=e,s=eR.Split,a=encodeData(s,{lamports:i});return new TransactionInstruction({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){let r=new Transaction;return r.add(SystemProgram.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:r,authorizedPubkey:n,splitStakePubkey:i,basePubkey:s,seed:a,lamports:o}=e,u=new Transaction;return u.add(SystemProgram.allocate({accountPubkey:i,basePubkey:s,seed:a,space:this.space,programId:this.programId})),t&&t>0&&u.add(SystemProgram.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),u.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:n,splitStakePubkey:i,lamports:o}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:n}=e,i=eR.Merge,s=encodeData(i);return new Transaction().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!1},{pubkey:K,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:r,toPubkey:n,lamports:i,custodianPubkey:s}=e,a=eR.Withdraw,o=encodeData(a,{lamports:i}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!1},{pubkey:K,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return s&&u.push({pubkey:s,isSigner:!0,isWritable:!1}),new Transaction().add({keys:u,programId:this.programId,data:o})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:r}=e,n=eR.Deactivate,i=encodeData(n);return new Transaction().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};StakeProgram.programId=new PublicKey("Stake11111111111111111111111111111111111111"),StakeProgram.space=200;let eK=Object.freeze({InitializeAccount:{index:0,layout:d.n_([d.Jq("instruction"),((e="voteInit")=>d.n_([publicKey("nodePubkey"),publicKey("authorizedVoter"),publicKey("authorizedWithdrawer"),d.u8("commission")],e))()])},Authorize:{index:1,layout:d.n_([d.Jq("instruction"),publicKey("newAuthorized"),d.Jq("voteAuthorizationType")])},Withdraw:{index:3,layout:d.n_([d.Jq("instruction"),d.gM("lamports")])},UpdateValidatorIdentity:{index:4,layout:d.n_([d.Jq("instruction")])},AuthorizeWithSeed:{index:10,layout:d.n_([d.Jq("instruction"),((e="voteAuthorizeWithSeedArgs")=>d.n_([d.Jq("voteAuthorizationType"),publicKey("currentAuthorityDerivedKeyOwnerPubkey"),rustString("currentAuthorityDerivedKeySeed"),publicKey("newAuthorized")],e))()])}});Object.freeze({Voter:{index:0},Withdrawer:{index:1}});let VoteProgram=class VoteProgram{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:r,voteInit:n}=e,i=eK.InitializeAccount,s=encodeData(i,{voteInit:{nodePubkey:toBuffer(n.nodePubkey.toBuffer()),authorizedVoter:toBuffer(n.authorizedVoter.toBuffer()),authorizedWithdrawer:toBuffer(n.authorizedWithdrawer.toBuffer()),commission:n.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:R,isSigner:!1,isWritable:!1},{pubkey:A,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s};return new TransactionInstruction(a)}static createAccount(e){let t=new Transaction;return t.add(SystemProgram.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=eK.Authorize,a=encodeData(s,{newAuthorized:toBuffer(n.toBuffer()),voteAuthorizationType:i.index}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Transaction().add({keys:o,programId:this.programId,data:a})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:i,voteAuthorizationType:s,votePubkey:a}=e,o=eK.AuthorizeWithSeed,u=encodeData(o,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:toBuffer(r.toBuffer()),currentAuthorityDerivedKeySeed:n,newAuthorized:toBuffer(i.toBuffer()),voteAuthorizationType:s.index}}),c=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Transaction().add({keys:c,programId:this.programId,data:u})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:n,toPubkey:i}=e,s=eK.Withdraw,a=encodeData(s,{lamports:n}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Transaction().add({keys:o,programId:this.programId,data:a})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw Error("Withdraw will leave vote account with insufficient funds.");return VoteProgram.withdraw(e)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:n}=e,i=eK.UpdateValidatorIdentity,s=encodeData(i),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Transaction().add({keys:a,programId:this.programId,data:s})}};VoteProgram.programId=new PublicKey("Vote111111111111111111111111111111111111111"),VoteProgram.space=3762,new PublicKey("Va1idator1nfo111111111111111111111111111111"),(0,g.dt)({name:(0,g.Z_)(),website:(0,g.jt)((0,g.Z_)()),details:(0,g.jt)((0,g.Z_)()),iconUrl:(0,g.jt)((0,g.Z_)()),keybaseUsername:(0,g.jt)((0,g.Z_)())}),new PublicKey("Vote111111111111111111111111111111111111111"),d.n_([publicKey("nodePubkey"),publicKey("authorizedWithdrawer"),d.u8("commission"),d._O(),d.A9(d.n_([d._O("slot"),d.Jq("confirmationCount")]),d.cv(d.Jq(),-8),"votes"),d.u8("rootSlotValid"),d._O("rootSlot"),d._O(),d.A9(d.n_([d._O("epoch"),publicKey("authorizedVoter")]),d.cv(d.Jq(),-8),"authorizedVoters"),d.n_([d.A9(d.n_([publicKey("authorizedPubkey"),d._O("epochOfLastAuthorizedSwitch"),d._O("targetEpoch")]),32,"buf"),d._O("idx"),d.u8("isEmpty")],"priorVoters"),d._O(),d.A9(d.n_([d._O("epoch"),d._O("credits"),d._O("prevCredits")]),d.cv(d.Jq(),-8),"epochCredits"),d.n_([d._O("slot"),d._O("timestamp")],"lastTimestamp")])}}]);