@solana/web3.js 2.0.0-experimental.b9c1a94 → 2.0.0-experimental.ba46ce1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +314 -8
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +315 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +763 -29
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +304 -11
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +303 -8
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +304 -11
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +35 -31
- package/dist/types/cached-abortable-iterable.d.ts +11 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/rpc-subscription-coalescer.d.ts +10 -0
- package/dist/types/rpc-websocket-autopinger.d.ts +8 -0
- package/dist/types/rpc-websocket-connection-sharding.d.ts +13 -0
- package/dist/types/rpc-websocket-transport.d.ts +13 -0
- package/dist/types/rpc.d.ts +4 -3
- package/package.json +12 -11
|
@@ -2,41 +2,45 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var xt=Object.create;var me=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var zt=(e,t,r)=>t in e?me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var _t=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ct=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of At(t))!Rt.call(e,o)&&o!==r&&me(e,o,{get:()=>t[o],enumerable:!(n=It(t,o))||n.enumerable});return e};var ve=(e,t,r)=>(r=e!=null?xt(Tt(e)):{},vt(t||!e||!e.__esModule?me(r,"default",{value:e,enumerable:!0}):r,e));var A=(e,t,r)=>(zt(e,typeof t!="symbol"?t+"":t,r),r);var c=_t(()=>{});var Re=Ct((Os,ft)=>{c();var Dr=Object.prototype.toString,$r=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};function Z(e,t){var r,n,o,s,i,a,u;if(e===!0)return "true";if(e===!1)return "false";switch(typeof e){case"object":if(e===null)return null;if(e.toJSON&&typeof e.toJSON=="function")return Z(e.toJSON(),t);if(u=Dr.call(e),u==="[object Array]"){for(o="[",n=e.length-1,r=0;r<n;r++)o+=Z(e[r],!0)+",";return n>-1&&(o+=Z(e[r],!0)),o+"]"}else if(u==="[object Object]"){for(s=$r(e).sort(),n=s.length,o="",r=0;r<n;)i=s[r],a=Z(e[i],!1),a!==void 0&&(o&&(o+=","),o+=JSON.stringify(i)+":"+a),r++;return "{"+o+"}"}else return JSON.stringify(e);case"function":case"undefined":return t?null:void 0;case"string":return JSON.stringify(e);default:return isFinite(e)?e:null}}ft.exports=function(e){var t=Z(e,!1);if(t!==void 0)return ""+t};});c();c();c();c();c();var v=e=>{let t=e.reduce((o,s)=>o+s.length,0),r=new Uint8Array(t),n=0;return e.forEach(o=>{r.set(o,n),n+=o.length;}),r},ke=(e,t)=>{if(e.length>=t)return e;let r=new Uint8Array(t).fill(0);return r.set(e),r},Q=(e,t)=>ke(e.slice(0,t),t);c();var k=class extends Error{constructor(r){super(`Serializer [${r}] cannot deserialize empty buffers.`);A(this,"name","DeserializingEmptyBufferError");}},R=class extends Error{constructor(r,n,o){super(`Serializer [${r}] expected ${n} bytes, got ${o}.`);A(this,"name","NotEnoughBytesError");}},D=class extends Error{constructor(r){r??(r="Expected a fixed-size serializer, got a variable-size one.");super(r);A(this,"name","ExpectedFixedSizeSerializerError");}};c();function j(e,t,r){return {description:r??`fixed(${t}, ${e.description})`,fixedSize:t,maxSize:t,serialize:n=>Q(e.serialize(n),t),deserialize:(n,o=0)=>{if(n=n.slice(o,o+t),n.length<t)throw new R("fixSerializer",t,n.length);e.fixedSize!==null&&(n=Q(n,e.fixedSize));let[s]=e.deserialize(n,0);return [s,o+t]}}}c();function ee(e,t,r){return {description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize,serialize:n=>e.serialize(t(n)),deserialize:(n,o=0)=>{let[s,i]=e.deserialize(n,o);return r?[r(s,n,o),i]:[s,i]}}}c();c();c();var te=class extends Error{constructor(r,n,o){let s=`Expected a string of base ${n}, got [${r}].`;super(s);A(this,"name","InvalidBaseStringError");this.cause=o;}};var Ne=e=>{let t=e.length,r=BigInt(t);return {description:`base${t}`,fixedSize:null,maxSize:null,serialize(n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new te(n,t);if(n==="")return new Uint8Array;let o=[...n],s=o.findIndex(f=>f!==e[0]);s=s===-1?o.length:s;let i=Array(s).fill(0);if(s===o.length)return Uint8Array.from(i);let a=o.slice(s),u=0n,l=1n;for(let f=a.length-1;f>=0;f-=1)u+=l*BigInt(e.indexOf(a[f])),l*=r;let p=[];for(;u>0n;)p.unshift(Number(u%256n)),u/=256n;return Uint8Array.from(i.concat(p))},deserialize(n,o=0){if(n.length===0)return ["",0];let s=n.slice(o),i=s.findIndex(p=>p!==0);i=i===-1?s.length:i;let a=e[0].repeat(i);if(i===s.length)return [a,n.length];let u=s.slice(i).reduce((p,f)=>p*256n+BigInt(f),0n),l=[];for(;u>0n;)l.unshift(e[Number(u%r)]),u/=r;return [a+l.join(""),n.length]}}};c();var B=Ne("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");c();var Oe=e=>e.replace(/\u0000/g,"");c();var ge={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,t=0){let r=new TextDecoder().decode(e.slice(t));return [Oe(r),e.length]}};c();c();var re;(function(e){e.Little="le",e.Big="be";})(re||(re={}));c();var ne=class extends RangeError{constructor(r,n,o,s){super(`Serializer [${r}] expected number to be between ${n} and ${o}, got ${s}.`);A(this,"name","NumberOutOfRangeError");}};c();function oe(e){let t,r=e.name;return e.size>1&&(t=!("endian"in e.options)||e.options.endian===re.Little,r+=t?"(le)":"(be)"),{description:e.options.description??r,fixedSize:e.size,maxSize:e.size,serialize(n){e.range&&be(e.name,e.range[0],e.range[1],n);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),n,t),new Uint8Array(o)},deserialize(n,o=0){let s=n.slice(o,o+e.size);Ot("i8",s,e.size);let i=Nt(s);return [e.get(i,t),o+e.size]}}}var kt=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),Nt=e=>new DataView(kt(e)),be=(e,t,r,n)=>{if(n<t||n>r)throw new ne(e,t,r,n)},Ot=(e,t,r)=>{if(t.length===0)throw new k(e);if(t.length<r)throw new R(e,r,t.length)};c();var N=(e={})=>oe({name:"u8",size:1,range:[0,+"0xff"],set:(t,r)=>t.setUint8(0,Number(r)),get:t=>t.getUint8(0),options:e});c();var H=(e={})=>oe({name:"u32",size:4,range:[0,+"0xffffffff"],set:(t,r,n)=>t.setUint32(0,Number(r),n),get:(t,r)=>t.getUint32(0,r),options:e});c();var _=(e={})=>({description:e.description??"shortU16",fixedSize:null,maxSize:3,serialize:t=>{be("shortU16",0,65535,t);let r=[0];for(let n=0;;n+=1){let o=t>>n*7;if(o===0)break;let s=127&o;r[n]=s,n>0&&(r[n-1]|=128);}return new Uint8Array(r)},deserialize:(t,r=0)=>{let n=0,o=0;for(;++o;){let s=o-1,i=t[r+s],a=127&i;if(n|=a<<s*7,!(i&128))break}return [n,r+o]}});c();c();var se=class extends Error{constructor(r,n,o){super(`Expected [${r}] to have ${n} items, got ${o}.`);A(this,"name","InvalidNumberOfItemsError");}},ie=class extends Error{constructor(r,n){super(`The remainder of the buffer (${r} bytes) cannot be split into chunks of ${n} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${r} modulo ${n} should be equal to zero.`);A(this,"name","InvalidArrayLikeRemainderSizeError");}},ae=class extends Error{constructor(r){super(`Unrecognized array-like serializer size: ${JSON.stringify(r)}`);A(this,"name","UnrecognizedArrayLikeSerializerSizeError");}};c();c();function W(e){return e.reduce((t,r)=>t===null||r===null?null:t+r,0)}function Le(e,t,r,n){if(typeof e=="number")return [e,n];if(typeof e=="object")return e.deserialize(r,n);if(e==="remainder"){let o=W(t);if(o===null)throw new D('Serializers of "remainder" size must have fixed-size items.');let s=r.slice(n).length;if(s%o!==0)throw new ie(s,o);return [s/o,n]}throw new ae(e)}function M(e){return typeof e=="object"?e.description:`${e}`}function he(e,t){if(typeof e!="number")return null;if(e===0)return 0;let r=W(t);return r===null?null:r*e}function Be(e,t){return typeof e=="object"?e.serialize(t):new Uint8Array}function O(e,t={}){let r=t.size??H();if(r==="remainder"&&e.fixedSize===null)throw new D('Serializers of "remainder" size must have fixed-size items.');return {description:t.description??`array(${e.description}; ${M(r)})`,fixedSize:he(r,[e.fixedSize]),maxSize:he(r,[e.maxSize]),serialize:n=>{if(typeof r=="number"&&n.length!==r)throw new se("array",r,n.length);return v([Be(r,n.length),...n.map(o=>e.serialize(o))])},deserialize:(n,o=0)=>{if(typeof r=="object"&&n.slice(o).length===0)return [[],o];let[s,i]=Le(r,[e.fixedSize],n,o);o=i;let a=[];for(let u=0;u<s;u+=1){let[l,p]=e.deserialize(n,o);a.push(l),o=p;}return [a,o]}}}c();function ce(e={}){let t=e.size??"variable",r=e.description??`bytes(${M(t)})`,n={description:r,fixedSize:null,maxSize:null,serialize:o=>new Uint8Array(o),deserialize:(o,s=0)=>{let i=o.slice(s);return [i,s+i.length]}};return t==="variable"?n:typeof t=="number"?j(n,t,r):{description:r,fixedSize:null,maxSize:null,serialize:o=>{let s=n.serialize(o),i=t.serialize(s.length);return v([i,s])},deserialize:(o,s=0)=>{if(o.slice(s).length===0)throw new k("bytes");let[i,a]=t.deserialize(o,s),u=Number(i);s=a;let l=o.slice(s,s+u);if(l.length<u)throw new R("bytes",u,l.length);let[p,f]=n.deserialize(l);return s+=f,[p,s]}}}c();function G(e={}){let t=e.size??H(),r=e.encoding??ge,n=e.description??`string(${r.description}; ${M(t)})`;return t==="variable"?{...r,description:n}:typeof t=="number"?j(r,t,n):{description:n,fixedSize:null,maxSize:null,serialize:o=>{let s=r.serialize(o),i=t.serialize(s.length);return v([i,s])},deserialize:(o,s=0)=>{if(o.slice(s).length===0)throw new k("string");let[i,a]=t.deserialize(o,s),u=Number(i);s=a;let l=o.slice(s,s+u);if(l.length<u)throw new R("string",u,l.length);let[p,f]=r.deserialize(l);return s+=f,[p,s]}}}c();function P(e,t={}){let r=e.map(([n,o])=>`${String(n)}: ${o.description}`).join(", ");return {description:t.description??`struct(${r})`,fixedSize:W(e.map(([,n])=>n.fixedSize)),maxSize:W(e.map(([,n])=>n.maxSize)),serialize:n=>{let o=e.map(([s,i])=>i.serialize(n[s]));return v(o)},deserialize:(n,o=0)=>{let s={};return e.forEach(([i,a])=>{let[u,l]=a.deserialize(n,o);o=l,s[i]=u;}),[s,o]}}}c();function V(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}var $;async function Lt(e){return $===void 0&&($=new Promise(t=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{t($=!1);}).then(()=>{t($=!0);});})),typeof $=="boolean"?$:await $}async function Pe(){if(V(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!="function")throw new Error("No digest implementation could be found")}async function De(){if(V(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.generateKey!="function")throw new Error("No key generation implementation could be found");if(!await Lt(globalThis.crypto.subtle))throw new Error(`This runtime does not support the generation of Ed25519 key pairs.
|
|
6
6
|
|
|
7
7
|
Install and import \`@solana/webcrypto-ed25519-polyfill\` before generating keys in environments that do not support Ed25519.
|
|
8
8
|
|
|
9
|
-
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function xe(){if($(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function Ee(){if($(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}async function Se(){if($(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.verify!="function")throw new Error("No signature verification implementation could be found")}function fo(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=C.serialize(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function L(e){return P({description:e?.description??(""),encoding:C,size:32})}function re(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var pr=37095705934669439343138083508754565189542113879843219016388785533085940283555n,b=57896044618658097711785492504343953926634992332820282019728792003956564819949n,Ae=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function w(e){let r=e%b;return r>=0n?r:b+r}function A(e,r){let t=e;for(;r-- >0n;)t*=t,t%=b;return t}function mr(e){let t=e*e%b*e%b,n=A(t,2n)*t%b,o=A(n,1n)*e%b,s=A(o,5n)*o%b,i=A(s,10n)*s%b,c=A(i,20n)*i%b,u=A(c,40n)*c%b,l=A(u,80n)*u%b,d=A(l,80n)*u%b,m=A(d,10n)*s%b;return A(m,2n)*e%b}function gr(e,r){let t=w(r*r*r),n=w(t*t*r),o=mr(e*n),s=w(e*t*o),i=w(r*s*s),c=s,u=w(s*Ae),l=i===e,d=i===w(-e),m=i===w(-e*Ae);return l&&(s=c),(d||m)&&(s=u),(w(s)&1n)===1n&&(s=w(-s)),!l&&!d?null:s}function hr(e,r){let t=w(e*e),n=w(t-1n),o=w(pr*t+1n),s=gr(n,o);if(s===null)return !1;let i=(r&128)!==0;return !(s===0n&&i)}function br(e){let r=e.toString(16);return r.length===1?`0${r}`:r}function yr(e){let t=`0x${e.reduce((n,o,s)=>`${br(s===31?o&-129:o)}${n}`,"")}`;return BigInt(t)}async function wr(e){if(e.byteLength!==32)return !1;let r=yr(e);return hr(r,e[31])}var Te=32,ze=16,ee=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115],Ie=class extends Error{};async function xr({programAddress:e,seeds:r}){if(await ye(),r.length>ze)throw new Error(`A maximum of ${ze} seeds may be supplied when creating an address`);let t,n=r.reduce((u,l,d)=>{let m=typeof l=="string"?(t||(t=new TextEncoder)).encode(l):l;if(m.byteLength>Te)throw new Error(`The seed at index ${d} exceeds the maximum length of 32 bytes`);return u.push(...m),u},[]),o=L(),s=o.serialize(e),i=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...s,...ee])),c=new Uint8Array(i);if(await wr(c))throw new Ie("Invalid seeds; point must fall off the Ed25519 curve");return o.deserialize(c)[0]}async function po({programAddress:e,seeds:r}){let t=255;for(;t>0;)try{return {bumpSeed:t,pda:await xr({programAddress:e,seeds:[...r,new Uint8Array([t])]})}}catch(n){if(n instanceof Ie)t--;else throw n}throw new Error("Unable to find a viable program address bump seed")}async function mo({baseAddress:e,programAddress:r,seed:t}){let{serialize:n,deserialize:o}=L(),s=typeof t=="string"?new TextEncoder().encode(t):t;if(s.byteLength>Te)throw new Error("The seed exceeds the maximum length of 32 bytes");let i=n(r);if(i.length>=ee.length&&i.slice(-ee.length).every((l,d)=>l===ee[d]))throw new Error("programAddress cannot end with the PDA marker");let c=await crypto.subtle.digest("SHA-256",new Uint8Array([...n(e),...s,...i])),u=new Uint8Array(c);return o(u)[0]}async function Re(e){if(await xe(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let r=await crypto.subtle.exportKey("raw",e),[t]=L().deserialize(new Uint8Array(r));return t}a();var Er=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(Er||{}),ve=2,ae=1;function yo(e){return e&~ve}function wo(e){return e&~ae}function xo(e){return e>=2}function Eo(e){return (e&ae)!==0}function So(e,r){return e|r}function Ao(e){return e|ve}function zo(e){return e|ae}a();async function vo(){return await we(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function Ne(e,r){await Ee();let t=await crypto.subtle.sign("Ed25519",e,r);return new Uint8Array(t)}async function No(e,r,t){return await Se(),await crypto.subtle.verify("Ed25519",e,r,t)}a();function j(e){if("signatures"in e){let{signatures:r,...t}=e;return t}else return e}function Oo(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=C.serialize(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(r){throw new Error(`\`${e}\` is not a blockhash`,{cause:r})}}function Do(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let t={...j(r),lifetimeConstraint:e};return Object.freeze(t),t}function Po({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}var E=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(E||{}),Sr=1;function U(e){return e>=2}function M(e){return (e&Sr)!==0}function Ce(e,r){return e|r}var _e="SysvarRecentB1ockHashes11111111111111111111",Le="11111111111111111111111111111111";function $o(e){if(!Oe(e))throw new Error("Transaction is not a durable nonce transaction")}function Ar(e,r){return {accounts:[{address:e,role:E.WRITABLE},{address:_e,role:E.READONLY},{address:r,role:E.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Le}}function zr(e){return e.programAddress===Le&&e.data!=null&&Tr(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===E.WRITABLE&&e.accounts[1].address===_e&&e.accounts[1].role===E.READONLY&&e.accounts[2].address!=null&&e.accounts[2].role===E.READONLY_SIGNER}function Tr(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Oe(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&zr(e.instructions[0])}function Uo({nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:t},n){let o=Oe(n);if(o&&n.lifetimeConstraint.nonce===e&&n.instructions[0].accounts[0].address===r&&n.instructions[0].accounts[2].address===t)return n;let s={...j(n),instructions:[Ar(r,t),...o?n.instructions.slice(1):n.instructions],lifetimeConstraint:{nonce:e}};return Object.freeze(s),s}function Mo(e,r){if("feePayer"in r&&e===r.feePayer)return r;let t={...j(r),feePayer:e};return Object.freeze(t),t}function jo(e,r){let t={...j(r),instructions:[...r.instructions,e]};return Object.freeze(t),t}function Ko(e,r){let t={...j(r),instructions:[e,...r.instructions]};return Object.freeze(t),t}function Be(e,r,t){e[r]=t(e[r]??{role:E.READONLY});}var g=Symbol("AddressMapTypeProperty");function Ir(e,r){let t={[e]:{[g]:0,role:E.WRITABLE_SIGNER}},n=new Set;for(let o of r){Be(t,o.programAddress,i=>{if(n.add(o.programAddress),g in i){if(M(i.role))switch(i[g]){case 0:throw new Error(`This transaction includes an address (\`${o.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`);default:throw new Error(`This transaction includes an address (\`${o.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(i[g]===2)return i}return {[g]:2,role:E.READONLY}});let s;if(o.accounts)for(let i of o.accounts)Be(t,i.address,c=>{let{address:u,...l}=i;if(g in c)switch(c[g]){case 0:return c;case 1:{let d=Ce(c.role,l.role);if("lookupTableAddress"in l){if(c.lookupTableAddress!==l.lookupTableAddress&&(s||(s=re()))(l.lookupTableAddress,c.lookupTableAddress)<0)return {[g]:1,...l,role:d}}else if(U(l.role))return {[g]:2,role:d};return c.role!==d?{...c,role:d}:c}case 2:{let d=Ce(c.role,l.role);if(n.has(i.address)){if(M(l.role))throw new Error(`This transaction includes an address (\`${i.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return c.role!==d?{...c,role:d}:c}else return "lookupTableAddress"in l&&!U(c.role)?{...l,[g]:1,role:d}:c.role!==d?{...c,role:d}:c}}return "lookupTableAddress"in l?{...l,[g]:1}:{...l,[g]:2}});}return t}function Rr(e){let r;return Object.entries(e).sort(([n,o],[s,i])=>{if(o[g]!==i[g]){if(o[g]===0)return -1;if(i[g]===0)return 1;if(o[g]===2)return -1;if(i[g]===2)return 1}let c=U(o.role);if(c!==U(i.role))return c?-1:1;let u=M(o.role);return u!==M(i.role)?u?-1:1:(r||(r=re()),o[g]===1&&i[g]===1&&o.lookupTableAddress!==i.lookupTableAddress?r(o.lookupTableAddress,i.lookupTableAddress):r(n,s))}).map(([n,o])=>({address:n,...o}))}function vr(e){var r;let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let o=t[r=n.lookupTableAddress]||(t[r]={readableIndices:[],writableIndices:[]});n.role===E.WRITABLE?o.writableIndices.push(n.addressIndex):o.readableIndices.push(n.addressIndex);}return Object.keys(t).sort(re()).map(n=>({lookupTableAddress:n,...t[n]}))}function Nr(e){let r=0,t=0,n=0;for(let o of e){if("lookupTableAddress"in o)break;let s=M(o.role);U(o.role)?(n++,s||t++):s||r++;}return {numReadonlyNonSignerAccounts:r,numReadonlySignerAccounts:t,numSignerAccounts:n}}function Cr(e){let r={};for(let[t,n]of e.entries())r[n.address]=t;return r}function Br(e,r){let t=Cr(r);return e.map(({accounts:n,data:o,programAddress:s})=>({programAddressIndex:t[s],...n?{accountIndices:n.map(({address:i})=>t[i])}:null,...o?{data:o}:null}))}function kr(e){return "nonce"in e?e.nonce:e.blockhash}function _r(e){let r=e.findIndex(n=>"lookupTableAddress"in n);return (r===-1?e:e.slice(0,r)).map(({address:n})=>n)}function De(e){let r=Ir(e.feePayer,e.instructions),t=Rr(r);return {...e.version!=="legacy"?{addressTableLookups:vr(t)}:null,header:Nr(t),instructions:Br(e.instructions,t),lifetimeToken:kr(e.lifetimeConstraint),staticAccounts:_r(t),version:e.version}}function Lr(){return v([["lookupTableAddress",L(void 0)],["writableIndices",R(I(),{...null,size:S()})],["readableIndices",R(I(),{...void 0,size:S()})]],void 0)}function Or(){return v([["numSignerAccounts",I(void 0)],["numReadonlySignerAccounts",I(void 0)],["numReadonlyNonSignerAccounts",I(void 0)]],void 0)}function Dr(){return G(v([["programAddressIndex",I(void 0)],["accountIndices",R(I({description:""}),{description:"",size:S()})],["data",Q({description:"",size:S()})]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)},e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:r,data:t,...n}=e;return {...n,...r.length?{accountIndices:r}:null,...t.byteLength?{data:t}:null}})}function Pr(e,r){let t=r+e[0].toUpperCase()+e.slice(1);return new Error(`No ${e} exists for ${r}. Use \`get${t}()\` if you need a ${e}, and \`get${r}Codec()\` if you need to both encode and decode ${r}`)}function Pe(e){return ()=>{throw Pr("decoder",e)}}var ce=128,$r={description:"",fixedSize:null,maxSize:1};function Ur(e,r=0){let t=e[r];return t&ce?[t^ce,r+1]:["legacy",r]}function Mr(e){if(e==="legacy")return new Uint8Array;if(e<0||e>127)throw new Error(`Transaction version must be in the range [0, 127]. \`${e}\` given.`);return new Uint8Array([e|ce])}function jr(){return {...$r,deserialize:Ur,serialize:Mr}}var Kr={description:"",fixedSize:null,maxSize:null};function Fr(e){return e.version==="legacy"?v(ke()).serialize(e):G(v([...ke(),["addressTableLookups",Wr()]]),r=>r.version==="legacy"?r:{...r,addressTableLookups:r.addressTableLookups??[]}).serialize(e)}function ke(){return [["version",jr()],["header",Or()],["staticAccounts",R(L(),{description:"",size:S()})],["lifetimeToken",P({description:"",encoding:C,size:32})],["instructions",R(Dr(),{description:"",size:S()})]]}function Wr(){return R(Lr(),{...null,size:S()})}function $e(){return {...Kr,deserialize:Pe("CompiledMessage"),serialize:Fr}}async function Gr(e,r){let t=$e().serialize(e);return await Ne(r,t)}async function Fo(e,r){let t=De(r),[n,o]=await Promise.all([Re(e.publicKey),Gr(t,e.privateKey)]),s={..."signatures"in r?r.signatures:null,[n]:o},i={...r,signatures:s};return Object.freeze(i),i}function Hr(e){let r=De(e),t;if("signatures"in e){t=[];for(let n=0;n<r.header.numSignerAccounts;n++)t[n]=e.signatures[r.staticAccounts[n]]??new Uint8Array(Array(64).fill(0));}else t=Array(r.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:r,signatures:t}}var Vr={description:"",fixedSize:null,maxSize:null};function qr(e){let r=Hr(e);return v([["signatures",R(Q({size:64}),{...null,size:S()})],["compiledMessage",$e()]]).serialize(r)}function Jr(){return {...Vr,deserialize:Pe("CompiledMessage"),serialize:qr}}function Wo(e){let r=Jr().serialize(e);return btoa(String.fromCharCode(...r))}a();a();function le(e,r,t){if(Array.isArray(e))return e.map((n,o)=>le(n,[...r,o],t));if(typeof e=="object"&&e!==null){let n={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=le(e[o],[...r,o],t));return n}else return typeof e=="bigint"?(t&&(e>Number.MAX_SAFE_INTEGER||e<-Number.MAX_SAFE_INTEGER)&&t(r,e),Number(e)):e}function Yr(e,r){return le(e,[],r)}var f={},ue;function Xr(){if(!ue){let e=[["data","parsed","info","tokenAmount","decimals"],["data","parsed","info","tokenAmount","uiAmount"],["data","parsed","info","rentExemptReserve","decimals"],["data","parsed","info","rentExemptReserve","uiAmount"],["data","parsed","info","delegatedAmount","decimals"],["data","parsed","info","delegatedAmount","uiAmount"],["data","parsed","info","extensions",f,"state","olderTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",f,"state","newerTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",f,"state","preUpdateAverageRate"],["data","parsed","info","extensions",f,"state","currentRate"]],r=[...e,["data","parsed","info","lastExtendedSlotStartIndex"],["data","parsed","info","slashPenalty"],["data","parsed","info","warmupCooldownRate"],["data","parsed","info","decimals"],["data","parsed","info","numRequiredSigners"],["data","parsed","info","numValidSigners"],["data","parsed","info","stake","delegation","warmupCooldownRate"],["data","parsed","info","exemptionThreshold"],["data","parsed","info","burnPercent"],["data","parsed","info","commission"],["data","parsed","info","votes",f,"confirmationCount"]];ue={getAccountInfo:r.map(t=>["value",...t]),getBlockTime:[[]],getClusterNodes:[[f,"featureSet"],[f,"shredVersion"]],getInflationGovernor:[["initial"],["foundation"],["foundationTerm"],["taper"],["terminal"]],getInflationRate:[["foundation"],["total"],["validator"]],getInflationReward:[[f,"commission"]],getMultipleAccounts:r.map(t=>["value",f,...t]),getProgramAccounts:r.flatMap(t=>[["value",f,"account",...t],[f,"account",...t]]),getRecentPerformanceSamples:[[f,"samplePeriodSecs"]],getTokenAccountBalance:[["value","decimals"],["value","uiAmount"]],getTokenAccountsByDelegate:e.map(t=>["value",f,"account",...t]),getTokenAccountsByOwner:e.map(t=>["value",f,"account",...t]),getTokenLargestAccounts:[["value",f,"decimals"],["value",f,"uiAmount"]],getTokenSupply:[["value","decimals"],["value","uiAmount"]],getTransaction:[["meta","preTokenBalances",f,"accountIndex"],["meta","preTokenBalances",f,"uiTokenAmount","decimals"],["meta","postTokenBalances",f,"accountIndex"],["meta","postTokenBalances",f,"uiTokenAmount","decimals"],["meta","rewards",f,"commission"],["meta","innerInstructions",f,"index"],["meta","innerInstructions",f,"instructions",f,"programIdIndex"],["meta","innerInstructions",f,"instructions",f,"accounts",f],["transaction","message","addressTableLookups",f,"writableIndexes",f],["transaction","message","addressTableLookups",f,"readonlyIndexes",f],["transaction","message","instructions",f,"programIdIndex"],["transaction","message","instructions",f,"accounts",f],["transaction","message","header","numReadonlySignedAccounts"],["transaction","message","header","numReadonlyUnsignedAccounts"],["transaction","message","header","numRequiredSignatures"]],getVersion:[["feature-set"]],getVoteAccounts:[["current",f,"commission"],["delinquent",f,"commission"]],simulateTransaction:r.map(t=>["value","accounts",f,...t])};}return ue}function Ue(e,r){return e.filter(t=>t[0]===f&&typeof r=="number"||t[0]===r).map(t=>t.slice(1))}function de(e,r){if(Array.isArray(e))return e.map((t,n)=>{let o=Ue(r,n);return de(t,o)});if(typeof e=="object"&&e!==null){let t={};for(let[n,o]of Object.entries(e)){let s=Ue(r,n);t[n]=de(o,s);}return t}else return typeof e=="number"&&r.length===0&&Number.isInteger(e)?BigInt(e):e}function Zr(e,r){let t=r?Xr()[r]:void 0;return de(e,t??[])}function Me(e){return new Proxy({},{defineProperty(){return !1},deleteProperty(){return !1},get(...r){let[t,n]=r,o=n.toString();return function(...s){let i=e?.onIntegerOverflow,c=Yr(s,i?(u,l)=>i(o,u,l):void 0);return {methodName:o,params:c,responseProcessor:u=>Zr(u,o)}}}})}a();var Qr=class extends Error{constructor(e){super(`JSON-RPC 2.0 error (${e.code}): ${e.message}`),Error.captureStackTrace(this,this.constructor),this.code=e.code,this.data=e.data;}get name(){return "SolanaJsonRpcError"}},fe=0;function et(){let e=fe;return fe=(fe+1)%Number.MAX_SAFE_INTEGER,e}function rt(e,r){return {id:et(),jsonrpc:"2.0",method:e,params:r}}function tt(e,r){return {async send(t){let{methodName:n,params:o,responseProcessor:s}=r,i=rt(n,o),c=await e.transport({payload:i,signal:t?.abortSignal});if("error"in c)throw new Qr(c.error);return s?s(c.result):c.result}}}function nt(e){return new Proxy(e.api,{defineProperty(){return !1},deleteProperty(){return !1},get(r,t,n){return function(...o){let s=t.toString(),i=Reflect.get(r,s,n),c=i?i(...o):{methodName:s,params:o};return tt(e,c)}}})}function Ke(e){return nt(e)}var ot=globalThis.fetch,st=class extends Error{constructor(e){super(`HTTP error (${e.statusCode}): ${e.message}`),Error.captureStackTrace(this,this.constructor),this.statusCode=e.statusCode;}get name(){return "SolanaHttpError"}};function ut(e){let r={};for(let t in e)r[t.toLowerCase()]=e[t];return r}function Fe({httpAgentNodeOnly:e,headers:r,url:t}){let n=void 0;let o=r&&ut(r);return async function({payload:i,signal:c}){let u=JSON.stringify(i),l={agent:n,body:u,headers:{...o,accept:"application/json","content-length":u.length.toString(),"content-type":"application/json; charset=utf-8"},method:"POST",signal:c},d=await ot(t,l);if(!d.ok)throw new st({message:d.statusText,statusCode:d.status});return await d.json()}}a();a();var te=class extends Error{constructor(t,n,o){let s=(typeof n[0]=="number"?n[0]:parseInt(n[0],10))+1,i="",c=s%10,u=s%100;c==1&&u!=11?i=s+"st":c==2&&u!=12?i=s+"nd":c==3&&u!=13?i=s+"rd":i=s+"th";let l=n.length>1?n.slice(1).map(d=>typeof d=="number"?`[${d}]`:d).join("."):null;super(`The ${i} argument to the \`${t}\` RPC method${l?` at path \`${l}\``:""} was \`${o}\`. This number is unsafe for use with the Solana JSON-RPC because it exceeds \`Number.MAX_SAFE_INTEGER\`.`);this.keyPath=n,this.methodName=t,this.value=o;}get name(){return "SolanaJsonRpcIntegerOverflowError"}};var We={onIntegerOverflow(e,r,t){throw new te(e,r,t)}};function us(e){return Ke({...e,api:Me(We)})}a();a();function Ge(e,r){let t;return async function(o){let{payload:s,signal:i}=o,c=r(s);if(c===void 0)return await e(o);if(t||(Promise.resolve().then(()=>{t=void 0;}),t={}),t[c]==null){let l=new AbortController;t[c]={abortController:l,numConsumers:0,responsePromise:e({...o,signal:l.signal})};}let u=t[c];if(u.numConsumers++,i){let l=u.responsePromise;return await new Promise((d,m)=>{let F=Ye=>{i.removeEventListener("abort",F),u.numConsumers-=1,u.numConsumers===0&&u.abortController.abort();let Xe=new DOMException(Ye.target.reason,"AbortError");m(Xe);};i.addEventListener("abort",F),l.then(d).finally(()=>{i.removeEventListener("abort",F);});})}else return await u.responsePromise}}a();var qe=ar(Ve(),1);function Je(e){if(!(e==null||typeof e!="object"||Array.isArray(e))&&"jsonrpc"in e&&e.jsonrpc==="2.0"&&"method"in e&&"params"in e)return (0, qe.default)([e.method,e.params])}function ft(e){let r={};for(let t in e)r[t.toLowerCase()]=e[t];return r}function Es(e){return Ge(Fe({...e,headers:{...e.headers?ft(e.headers):void 0,"solana-client":"js/2.0.0-development"}}),Je)}
|
|
9
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function $e(){if(V(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function We(){if(V(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}async function Me(){if(V(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.verify!="function")throw new Error("No signature verification implementation could be found")}function Ko(e){return !(e.length<32||e.length>44||B.serialize(e).byteLength!==32)}function Pt(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let r=B.serialize(e).byteLength;if(r!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${r}`)}catch(t){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:t})}}function jo(e){return Pt(e),e}function U(e){return G({description:e?.description??(""),encoding:B,size:32})}function le(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var Dt=37095705934669439343138083508754565189542113879843219016388785533085940283555n,I=57896044618658097711785492504343953926634992332820282019728792003956564819949n,Ue=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function T(e){let t=e%I;return t>=0n?t:I+t}function C(e,t){let r=e;for(;t-- >0n;)r*=r,r%=I;return r}function $t(e){let r=e*e%I*e%I,n=C(r,2n)*r%I,o=C(n,1n)*e%I,s=C(o,5n)*o%I,i=C(s,10n)*s%I,a=C(i,20n)*i%I,u=C(a,40n)*a%I,l=C(u,80n)*u%I,p=C(l,80n)*u%I,f=C(p,10n)*s%I;return C(f,2n)*e%I}function Wt(e,t){let r=T(t*t*t),n=T(r*r*t),o=$t(e*n),s=T(e*r*o),i=T(t*s*s),a=s,u=T(s*Ue),l=i===e,p=i===T(-e),f=i===T(-e*Ue);return l&&(s=a),(p||f)&&(s=u),(T(s)&1n)===1n&&(s=T(-s)),!l&&!p?null:s}function Mt(e,t){let r=T(e*e),n=T(r-1n),o=T(Dt*r+1n),s=Wt(n,o);if(s===null)return !1;let i=(t&128)!==0;return !(s===0n&&i)}function Ut(e){let t=e.toString(16);return t.length===1?`0${t}`:t}function Ft(e){let r=`0x${e.reduce((n,o,s)=>`${Ut(s===31?o&-129:o)}${n}`,"")}`;return BigInt(r)}async function Kt(e){if(e.byteLength!==32)return !1;let t=Ft(e);return Mt(t,e[31])}var Ke=32,Fe=16,ue=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115],je=class extends Error{};async function jt({programAddress:e,seeds:t}){if(await Pe(),t.length>Fe)throw new Error(`A maximum of ${Fe} seeds may be supplied when creating an address`);let r,n=t.reduce((u,l,p)=>{let f=typeof l=="string"?(r||(r=new TextEncoder)).encode(l):l;if(f.byteLength>Ke)throw new Error(`The seed at index ${p} exceeds the maximum length of 32 bytes`);return u.push(...f),u},[]),o=U(),s=o.serialize(e),i=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...s,...ue])),a=new Uint8Array(i);if(await Kt(a))throw new je("Invalid seeds; point must fall off the Ed25519 curve");return o.deserialize(a)[0]}async function Ho({programAddress:e,seeds:t}){let r=255;for(;r>0;)try{return {bumpSeed:r,pda:await jt({programAddress:e,seeds:[...t,new Uint8Array([r])]})}}catch(n){if(n instanceof je)r--;else throw n}throw new Error("Unable to find a viable program address bump seed")}async function Go({baseAddress:e,programAddress:t,seed:r}){let{serialize:n,deserialize:o}=U(),s=typeof r=="string"?new TextEncoder().encode(r):r;if(s.byteLength>Ke)throw new Error("The seed exceeds the maximum length of 32 bytes");let i=n(t);if(i.length>=ue.length&&i.slice(-ue.length).every((l,p)=>l===ue[p]))throw new Error("programAddress cannot end with the PDA marker");let a=await crypto.subtle.digest("SHA-256",new Uint8Array([...n(e),...s,...i])),u=new Uint8Array(a);return o(u)[0]}async function He(e){if(await $e(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let t=await crypto.subtle.exportKey("raw",e),[r]=U().deserialize(new Uint8Array(t));return r}c();var Ht=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(Ht||{}),Ge=2,ye=1;function Jo(e){return e&~Ge}function Xo(e){return e&~ye}function Zo(e){return e>=2}function Qo(e){return (e&ye)!==0}function es(e,t){return e|t}function ts(e){return e|Ge}function rs(e){return e|ye}c();async function is(){return await De(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function Ve(e,t){await We();let r=await crypto.subtle.sign("Ed25519",e,t);return new Uint8Array(r)}async function as(e,t,r){return await Me(),await crypto.subtle.verify("Ed25519",e,t,r)}c();function J(e){if("signatures"in e){let{signatures:t,...r}=e;return r}else return e}function fs(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let r=B.serialize(e).byteLength;if(r!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${r}`)}catch(t){throw new Error(`\`${e}\` is not a blockhash`,{cause:t})}}function ms(e,t){if("lifetimeConstraint"in t&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return t;let r={...J(t),lifetimeConstraint:e};return Object.freeze(r),r}function gs({version:e}){let t={instructions:[],version:e};return Object.freeze(t),t}var z=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(z||{}),Gt=1;function q(e){return e>=2}function Y(e){return (e&Gt)!==0}function qe(e,t){return e|t}var Xe="SysvarRecentB1ockHashes11111111111111111111",Ze="11111111111111111111111111111111";function bs(e){if(!Qe(e))throw new Error("Transaction is not a durable nonce transaction")}function Vt(e,t){return {accounts:[{address:e,role:z.WRITABLE},{address:Xe,role:z.READONLY},{address:t,role:z.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Ze}}function qt(e){return e.programAddress===Ze&&e.data!=null&&Yt(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===z.WRITABLE&&e.accounts[1].address===Xe&&e.accounts[1].role===z.READONLY&&e.accounts[2].address!=null&&e.accounts[2].role===z.READONLY_SIGNER}function Yt(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Qe(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&qt(e.instructions[0])}function hs({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:r},n){let o=Qe(n);if(o&&n.lifetimeConstraint.nonce===e&&n.instructions[0].accounts[0].address===t&&n.instructions[0].accounts[2].address===r)return n;let s={...J(n),instructions:[Vt(t,r),...o?n.instructions.slice(1):n.instructions],lifetimeConstraint:{nonce:e}};return Object.freeze(s),s}function ys(e,t){if("feePayer"in t&&e===t.feePayer)return t;let r={...J(t),feePayer:e};return Object.freeze(r),r}function ws(e,t){let r={...J(t),instructions:[...t.instructions,e]};return Object.freeze(r),r}function Ss(e,t){let r={...J(t),instructions:[e,...t.instructions]};return Object.freeze(r),r}function Ye(e,t,r){e[t]=r(e[t]??{role:z.READONLY});}var w=Symbol("AddressMapTypeProperty");function Jt(e,t){let r={[e]:{[w]:0,role:z.WRITABLE_SIGNER}},n=new Set;for(let o of t){Ye(r,o.programAddress,i=>{if(n.add(o.programAddress),w in i){if(Y(i.role))switch(i[w]){case 0:throw new Error(`This transaction includes an address (\`${o.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`);default:throw new Error(`This transaction includes an address (\`${o.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(i[w]===2)return i}return {[w]:2,role:z.READONLY}});let s;if(o.accounts)for(let i of o.accounts)Ye(r,i.address,a=>{let{address:u,...l}=i;if(w in a)switch(a[w]){case 0:return a;case 1:{let p=qe(a.role,l.role);if("lookupTableAddress"in l){if(a.lookupTableAddress!==l.lookupTableAddress&&(s||(s=le()))(l.lookupTableAddress,a.lookupTableAddress)<0)return {[w]:1,...l,role:p}}else if(q(l.role))return {[w]:2,role:p};return a.role!==p?{...a,role:p}:a}case 2:{let p=qe(a.role,l.role);if(n.has(i.address)){if(Y(l.role))throw new Error(`This transaction includes an address (\`${i.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return a.role!==p?{...a,role:p}:a}else return "lookupTableAddress"in l&&!q(a.role)?{...l,[w]:1,role:p}:a.role!==p?{...a,role:p}:a}}return "lookupTableAddress"in l?{...l,[w]:1}:{...l,[w]:2}});}return r}function Xt(e){let t;return Object.entries(e).sort(([n,o],[s,i])=>{if(o[w]!==i[w]){if(o[w]===0)return -1;if(i[w]===0)return 1;if(o[w]===2)return -1;if(i[w]===2)return 1}let a=q(o.role);if(a!==q(i.role))return a?-1:1;let u=Y(o.role);return u!==Y(i.role)?u?-1:1:(t||(t=le()),o[w]===1&&i[w]===1&&o.lookupTableAddress!==i.lookupTableAddress?t(o.lookupTableAddress,i.lookupTableAddress):t(n,s))}).map(([n,o])=>({address:n,...o}))}function Zt(e){var t;let r={};for(let n of e){if(!("lookupTableAddress"in n))continue;let o=r[t=n.lookupTableAddress]||(r[t]={readableIndices:[],writableIndices:[]});n.role===z.WRITABLE?o.writableIndices.push(n.addressIndex):o.readableIndices.push(n.addressIndex);}return Object.keys(r).sort(le()).map(n=>({lookupTableAddress:n,...r[n]}))}function Qt(e){let t=0,r=0,n=0;for(let o of e){if("lookupTableAddress"in o)break;let s=Y(o.role);q(o.role)?(n++,s||r++):s||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:r,numSignerAccounts:n}}function er(e){let t={};for(let[r,n]of e.entries())t[n.address]=r;return t}function tr(e,t){let r=er(t);return e.map(({accounts:n,data:o,programAddress:s})=>({programAddressIndex:r[s],...n?{accountIndices:n.map(({address:i})=>r[i])}:null,...o?{data:o}:null}))}function rr(e){return "nonce"in e?e.nonce:e.blockhash}function nr(e){let t=e.findIndex(n=>"lookupTableAddress"in n);return (t===-1?e:e.slice(0,t)).map(({address:n})=>n)}function et(e){let t=Jt(e.feePayer,e.instructions),r=Xt(t);return {...e.version!=="legacy"?{addressTableLookups:Zt(r)}:null,header:Qt(r),instructions:tr(e.instructions,r),lifetimeToken:rr(e.lifetimeConstraint),staticAccounts:nr(r),version:e.version}}function or(){return P([["lookupTableAddress",U(void 0)],["writableIndices",O(N(),{...null,size:_()})],["readableIndices",O(N(),{...void 0,size:_()})]],void 0)}function sr(){return P([["numSignerAccounts",N(void 0)],["numReadonlySignerAccounts",N(void 0)],["numReadonlyNonSignerAccounts",N(void 0)]],void 0)}function ir(){return ee(P([["programAddressIndex",N(void 0)],["accountIndices",O(N({description:""}),{description:"",size:_()})],["data",ce({description:"",size:_()})]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)},e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:r,...n}=e;return {...n,...t.length?{accountIndices:t}:null,...r.byteLength?{data:r}:null}})}function ar(e,t){let r=t+e[0].toUpperCase()+e.slice(1);return new Error(`No ${e} exists for ${t}. Use \`get${r}()\` if you need a ${e}, and \`get${t}Codec()\` if you need to both encode and decode ${t}`)}function tt(e){return ()=>{throw ar("decoder",e)}}var we=128,cr={description:"",fixedSize:null,maxSize:1};function ur(e,t=0){let r=e[t];return r&we?[r^we,t+1]:["legacy",t]}function lr(e){if(e==="legacy")return new Uint8Array;if(e<0||e>127)throw new Error(`Transaction version must be in the range [0, 127]. \`${e}\` given.`);return new Uint8Array([e|we])}function dr(){return {...cr,deserialize:ur,serialize:lr}}var pr={description:"",fixedSize:null,maxSize:null};function fr(e){return e.version==="legacy"?P(Je()).serialize(e):ee(P([...Je(),["addressTableLookups",mr()]]),t=>t.version==="legacy"?t:{...t,addressTableLookups:t.addressTableLookups??[]}).serialize(e)}function Je(){return [["version",dr()],["header",sr()],["staticAccounts",O(U(),{description:"",size:_()})],["lifetimeToken",G({description:"",encoding:B,size:32})],["instructions",O(ir(),{description:"",size:_()})]]}function mr(){return O(or(),{...null,size:_()})}function rt(){return {...pr,deserialize:tt("CompiledMessage"),serialize:fr}}async function gr(e,t){let r=rt().serialize(e);return await Ve(t,r)}async function Es(e,t){let r=et(t),n="signatures"in t?{...t.signatures}:{},o=await Promise.all(e.map(i=>Promise.all([He(i.publicKey),gr(r,i.privateKey)])));for(let[i,a]of o)n[i]=a;let s={...t,signatures:n};return Object.freeze(s),s}function br(e){let t=et(e),r;if("signatures"in e){r=[];for(let n=0;n<t.header.numSignerAccounts;n++)r[n]=e.signatures[t.staticAccounts[n]]??new Uint8Array(Array(64).fill(0));}else r=Array(t.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:t,signatures:r}}var hr={description:"",fixedSize:null,maxSize:null};function yr(e){let t=br(e);return P([["signatures",O(ce({size:64}),{...null,size:_()})],["compiledMessage",rt()]]).serialize(t)}function wr(){return {...hr,deserialize:tt("CompiledMessage"),serialize:yr}}function xs(e){let t=wr().serialize(e);return btoa(String.fromCharCode(...t))}c();c();function F(e,...t){return t.reduce((r,n)=>n(r),e)}c();function xe(e,t,r){if(Array.isArray(e))return e.map((n,o)=>xe(n,[...t,o],r));if(typeof e=="object"&&e!==null){let n={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=xe(e[o],[...t,o],r));return n}else return typeof e=="bigint"?(r&&(e>Number.MAX_SAFE_INTEGER||e<-Number.MAX_SAFE_INTEGER)&&r(t,e),Number(e)):e}function ot(e,t){return xe(e,[],t)}var d={},Se,Ee;function Sr(){return Se||(Se={}),Se}function Er(){if(!Ee){let e=[["data","parsed","info","tokenAmount","decimals"],["data","parsed","info","tokenAmount","uiAmount"],["data","parsed","info","rentExemptReserve","decimals"],["data","parsed","info","rentExemptReserve","uiAmount"],["data","parsed","info","delegatedAmount","decimals"],["data","parsed","info","delegatedAmount","uiAmount"],["data","parsed","info","extensions",d,"state","olderTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",d,"state","newerTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",d,"state","preUpdateAverageRate"],["data","parsed","info","extensions",d,"state","currentRate"]],t=[...e,["data","parsed","info","lastExtendedSlotStartIndex"],["data","parsed","info","slashPenalty"],["data","parsed","info","warmupCooldownRate"],["data","parsed","info","decimals"],["data","parsed","info","numRequiredSigners"],["data","parsed","info","numValidSigners"],["data","parsed","info","stake","delegation","warmupCooldownRate"],["data","parsed","info","exemptionThreshold"],["data","parsed","info","burnPercent"],["data","parsed","info","commission"],["data","parsed","info","votes",d,"confirmationCount"]];Ee={getAccountInfo:t.map(r=>["value",...r]),getBlock:[["blockTime"],["transactions",d,"meta","preTokenBalances",d,"accountIndex"],["transactions",d,"meta","preTokenBalances",d,"uiTokenAmount","decimals"],["transactions",d,"meta","postTokenBalances",d,"accountIndex"],["transactions",d,"meta","postTokenBalances",d,"uiTokenAmount","decimals"],["transactions",d,"meta","rewards",d,"commission"],["transactions",d,"meta","innerInstructions",d,"index"],["transactions",d,"meta","innerInstructions",d,"instructions",d,"programIdIndex"],["transactions",d,"meta","innerInstructions",d,"instructions",d,"accounts",d],["transactions",d,"transaction","message","addressTableLookups",d,"writableIndexes",d],["transactions",d,"transaction","message","addressTableLookups",d,"readonlyIndexes",d],["transactions",d,"transaction","message","instructions",d,"programIdIndex"],["transactions",d,"transaction","message","instructions",d,"accounts",d],["transactions",d,"transaction","message","header","numReadonlySignedAccounts"],["transactions",d,"transaction","message","header","numReadonlyUnsignedAccounts"],["transactions",d,"transaction","message","header","numRequiredSignatures"],["rewards",d,"commission"]],getBlockTime:[[]],getClusterNodes:[[d,"featureSet"],[d,"shredVersion"]],getInflationGovernor:[["initial"],["foundation"],["foundationTerm"],["taper"],["terminal"]],getInflationRate:[["foundation"],["total"],["validator"]],getInflationReward:[[d,"commission"]],getMultipleAccounts:t.map(r=>["value",d,...r]),getProgramAccounts:t.flatMap(r=>[["value",d,"account",...r],[d,"account",...r]]),getRecentPerformanceSamples:[[d,"samplePeriodSecs"]],getTokenAccountBalance:[["value","decimals"],["value","uiAmount"]],getTokenAccountsByDelegate:e.map(r=>["value",d,"account",...r]),getTokenAccountsByOwner:e.map(r=>["value",d,"account",...r]),getTokenLargestAccounts:[["value",d,"decimals"],["value",d,"uiAmount"]],getTokenSupply:[["value","decimals"],["value","uiAmount"]],getTransaction:[["meta","preTokenBalances",d,"accountIndex"],["meta","preTokenBalances",d,"uiTokenAmount","decimals"],["meta","postTokenBalances",d,"accountIndex"],["meta","postTokenBalances",d,"uiTokenAmount","decimals"],["meta","rewards",d,"commission"],["meta","innerInstructions",d,"index"],["meta","innerInstructions",d,"instructions",d,"programIdIndex"],["meta","innerInstructions",d,"instructions",d,"accounts",d],["transaction","message","addressTableLookups",d,"writableIndexes",d],["transaction","message","addressTableLookups",d,"readonlyIndexes",d],["transaction","message","instructions",d,"programIdIndex"],["transaction","message","instructions",d,"accounts",d],["transaction","message","header","numReadonlySignedAccounts"],["transaction","message","header","numReadonlyUnsignedAccounts"],["transaction","message","header","numRequiredSignatures"]],getVersion:[["feature-set"]],getVoteAccounts:[["current",d,"commission"],["delinquent",d,"commission"]],simulateTransaction:t.map(r=>["value","accounts",d,...r])};}return Ee}function nt(e,t){return e.filter(r=>r[0]===d&&typeof t=="number"||r[0]===t).map(r=>r.slice(1))}function de(e,t){if(Array.isArray(e))return e.map((r,n)=>{let o=nt(t,n);return de(r,o)});if(typeof e=="object"&&e!==null){let r={};for(let[n,o]of Object.entries(e)){let s=nt(t,n);r[n]=de(o,s);}return r}else return typeof e=="number"&&t.length===0&&Number.isInteger(e)?BigInt(e):e}function xr(e,t){let r=t?Er()[t]:void 0;return de(e,r??[])}function Ir(e,t){let r=t?Sr()[t]:void 0;return de(e,r??[])}function st(e){return new Proxy({},{defineProperty(){return !1},deleteProperty(){return !1},get(...t){let[r,n]=t,o=n.toString();return function(...s){let i=e?.onIntegerOverflow,a=ot(s,i?(u,l)=>i(o,u,l):void 0);return {methodName:o,params:a,responseProcessor:u=>xr(u,o)}}}})}function it(e){return new Proxy({},{defineProperty(){return !1},deleteProperty(){return !1},get(...t){let[r,n]=t,o=n.toString();return function(...s){let i=e?.onIntegerOverflow;return {params:ot(s,i?(u,l)=>i(o,u,l):void 0),responseProcessor:u=>Ir(u,o),subscribeMethodName:o.replace(/Notifications$/,"Subscribe"),unsubscribeMethodName:o.replace(/Notifications$/,"Unsubscribe")}}}})}c();var ct=class extends Error{constructor(e){super(`JSON-RPC 2.0 error (${e.code}): ${e.message}`),Error.captureStackTrace(this,this.constructor),this.code=e.code,this.data=e.data;}get name(){return "SolanaJsonRpcError"}},Ie=0;function Ar(){let e=Ie;return Ie=(Ie+1)%Number.MAX_SAFE_INTEGER,e}function Te(e,t){return {id:Ar(),jsonrpc:"2.0",method:e,params:t}}function Tr(e,t){return {async send(r){let{methodName:n,params:o,responseProcessor:s}=t,i=Te(n,o),a=await e.transport({payload:i,signal:r?.abortSignal});if("error"in a)throw new ct(a.error);return s?s(a.result):a.result}}}function Rr(e){return new Proxy(e.api,{defineProperty(){return !1},deleteProperty(){return !1},get(t,r,n){return function(...o){let s=r.toString(),i=Reflect.get(t,s,n),a=i?i(...o):{methodName:s,params:o};return Tr(e,a)}}})}function ut(e){return Rr(e)}function zr(e,t){(async()=>{try{for await(let r of e);}catch{}finally{t();}})();}function _r(e,{params:t,subscribeMethodName:r,unsubscribeMethodName:n,responseProcessor:o}){return {async subscribe({abortSignal:s}){s.throwIfAborted();let i;function a(){if(i!==void 0){let g=Te(n,[i]);p.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(g).finally(()=>{u.abort();});}else u.abort();}s.addEventListener("abort",a);let u=new AbortController,l=Te(r,t),p=await e.transport({payload:l,signal:u.signal});function f(){s.removeEventListener("abort",a);}zr(p,f);for await(let g of p)if("id"in g&&g.id===l.id){if("error"in g)throw new ct(g.error);i=g.result;break}if(i==null)throw new Error("Failed to obtain a subscription id from the server");return {async*[Symbol.asyncIterator](){for await(let g of p){if(!("params"in g)||g.params.subscription!==i)continue;let E=g.params.result;yield o?o(E):E;}}}}}}function Cr(e){return new Proxy(e.api,{defineProperty(){return !1},deleteProperty(){return !1},get(t,r,n){return function(...o){let s=r.toString(),i=Reflect.get(t,s,n);if(r.toString().endsWith("Notifications")===!1&&!i)throw new Error("Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names.");let a=i?i(...o):{params:o,subscribeMethodName:s.replace(/Notifications$/,"Subscribe"),unsubscribeMethodName:s.replace(/Notifications$/,"Unsubscribe")};return _r(e,a)}}})}function lt(e){return Cr(e)}var vr=globalThis.fetch,kr=class extends Error{constructor(e){super(`HTTP error (${e.statusCode}): ${e.message}`),Error.captureStackTrace(this,this.constructor),this.statusCode=e.statusCode;}get name(){return "SolanaHttpError"}};function Br(e){let t={};for(let r in e)t[r.toLowerCase()]=e[r];return t}function dt({httpAgentNodeOnly:e,headers:t,url:r}){let n=void 0;let o=t&&Br(t);return async function({payload:i,signal:a}){let u=JSON.stringify(i),l={agent:n,body:u,headers:{...o,accept:"application/json","content-length":u.length.toString(),"content-type":"application/json; charset=utf-8"},method:"POST",signal:a},p=await vr(r,l);if(!p.ok)throw new kr({message:p.statusText,statusCode:p.status});return await p.json()}}var X=globalThis.WebSocket,at=Symbol(void 0);async function Pr({sendBufferHighWatermark:e,signal:t,url:r}){return new Promise((n,o)=>{t.addEventListener("abort",a,{once:!0});let s=new Map;function i(h){let y=[...s.values()].filter(x=>x.__hasPolled).map(({onError:x})=>x);s.clear(),y.forEach(x=>{try{x(h);}catch{}});}function a(){i(at),b.readyState!==X.CLOSED&&b.readyState!==X.CLOSING&&b.close(1e3);}function u(h){f?.onCancel(),t.removeEventListener("abort",a),b.removeEventListener("close",u),b.removeEventListener("error",l),b.removeEventListener("open",g),b.removeEventListener("message",E),i(h);}function l(h){p||o(new Error("WebSocket failed to connect",{cause:h}));}let p=!1,f;function g(){p=!0,n({async send(h){let y=JSON.stringify(h);if(!f&&b.readyState===X.OPEN&&b.bufferedAmount>e){let x,L=new Promise((K,Et)=>{let Ce=setInterval(()=>{(b.readyState!==X.OPEN||!(b.bufferedAmount>e))&&(clearInterval(Ce),f=void 0,K());},16);x=()=>{f=void 0,clearInterval(Ce),Et(new Error("WebSocket was closed before payload could be sent"));};});f={onCancel:x,promise:L};}f&&await f.promise,b.send(y);},async*[Symbol.asyncIterator](){let h=Symbol();s.set(h,{__hasPolled:!1,queuedMessages:[]});try{for(;;){let y=s.get(h);if(!y)throw new Error("Invariant: WebSocket message iterator is missing state storage");if(y.__hasPolled)throw new Error("Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise");let x=y.queuedMessages;if(x.length)y.queuedMessages=[],yield*x;else try{yield await new Promise((L,K)=>{s.set(h,{__hasPolled:!0,onError:K,onMessage:L});});}catch(L){if(L===at)return;throw new Error("WebSocket connection closed",{cause:L})}}}finally{s.delete(h);}}});}function E({data:h}){let y=JSON.parse(h);s.forEach((x,L)=>{if(x.__hasPolled){let{onMessage:K}=x;s.set(L,{__hasPolled:!1,queuedMessages:[]}),K(y);}else x.queuedMessages.push(y);});}let b=new X(r);b.addEventListener("close",u),b.addEventListener("error",l),b.addEventListener("open",g),b.addEventListener("message",E);})}function pt({sendBufferHighWatermark:e,url:t}){if(/^wss?:/i.test(t)===!1){let r=t.match(/^([^:]+):/);throw new DOMException(r?`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${r[1]}:' is not allowed.`:`Failed to construct 'WebSocket': The URL '${t}' is invalid.`)}return async function({payload:n,signal:o}){o?.throwIfAborted();let s=await Pr({sendBufferHighWatermark:e,signal:o,url:t});return o?.throwIfAborted(),await s.send(n),{[Symbol.asyncIterator]:s[Symbol.asyncIterator].bind(s),send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:s.send.bind(s)}}}var gt=ve(Re(),1);c();c();var pe=class extends Error{constructor(r,n,o){let s=(typeof n[0]=="number"?n[0]:parseInt(n[0],10))+1,i="",a=s%10,u=s%100;a==1&&u!=11?i=s+"st":a==2&&u!=12?i=s+"nd":a==3&&u!=13?i=s+"rd":i=s+"th";let l=n.length>1?n.slice(1).map(p=>typeof p=="number"?`[${p}]`:p).join("."):null;super(`The ${i} argument to the \`${r}\` RPC method${l?` at path \`${l}\``:""} was \`${o}\`. This number is unsafe for use with the Solana JSON-RPC because it exceeds \`Number.MAX_SAFE_INTEGER\`.`);this.keyPath=n,this.methodName=r,this.value=o;}get name(){return "SolanaJsonRpcIntegerOverflowError"}};var ze={onIntegerOverflow(e,t,r){throw new pe(e,t,r)}};c();c();function Wr(e,t){(async()=>{try{for await(let r of e);}catch{}finally{t();}})();}function fe({getAbortSignalFromInputArgs:e,getCacheEntryMissingError:t,getCacheKeyFromInputArgs:r,onCacheHit:n,onCreateIterable:o}){let s=new Map;function i(a){let u=s.get(a);if(!u)throw t(a);return u}return async(...a)=>{let u=r(...a),l=e(...a);if(u===void 0)return await o(l,...a);let p=()=>{s.delete(u),l.removeEventListener("abort",f);},f=()=>{let g=i(u);g.purgeScheduled!==!0&&(g.purgeScheduled=!0,globalThis.queueMicrotask(()=>{g.purgeScheduled=!1,g.referenceCount===0&&(g.abortController.abort(),p());})),g.referenceCount--;};l.addEventListener("abort",f);try{let g=s.get(u);if(g){g.referenceCount++;let E=g.iterable,b="then"in E?await E:E;return await n(b,...a),b}else {let E=new AbortController,b=o(E.signal,...a),h={abortController:E,iterable:b,purgeScheduled:!1,referenceCount:1};s.set(u,h);let y=await b;return Wr(y,p),h.iterable=y,y}}catch(g){throw p(),g}}}var _e=Symbol(void 0);function Mr(e,t){(async()=>{try{for await(let r of e);}catch{}finally{t();}})();}function mt({getDeduplicationKey:e,rpcSubscriptions:t}){let r=new Map;return new Proxy(t,{defineProperty(){return !1},deleteProperty(){return !1},get(n,o,s){let i=Reflect.get(n,o,s);return typeof i!="function"?i:function(...a){let u=e(o,a);if(u===void 0)return i(...a);if(r.has(u))return r.get(u);let l=fe({getAbortSignalFromInputArgs:({abortSignal:f})=>f,getCacheEntryMissingError(f){return new Error(`Found no cache entry for subscription with deduplication key \`${f?.toString()}\``)},getCacheKeyFromInputArgs:()=>u,async onCacheHit(f,g){},async onCreateIterable(f,g){let b=await i(...a).subscribe({...g,abortSignal:f});return Mr(b,()=>{r.delete(u);}),b}}),p={async subscribe(...f){let g=await l(...f),{abortSignal:E}=f[0],b;return {...g,async*[Symbol.asyncIterator](){b||(b=E.aborted?Promise.reject(_e):new Promise((h,y)=>{E.addEventListener("abort",()=>{y(_e);});}));try{let h=g[Symbol.asyncIterator]();for(;;){let y=await Promise.race([h.next(),b]);if(y.done)return;yield y.value;}}catch(h){if(h===_e)return;throw r.delete(u),h}}}}};return r.set(u,p),p}}})}function Zs(e){return ut({...e,api:st(ze)})}function Qs(e){return F(lt({...e,api:it(ze)}),t=>mt({getDeduplicationKey:(...r)=>(0, gt.default)(r),rpcSubscriptions:t}))}c();c();function bt(e,t){let r;return async function(o){let{payload:s,signal:i}=o,a=t(s);if(a===void 0)return await e(o);if(r||(Promise.resolve().then(()=>{r=void 0;}),r={}),r[a]==null){let l=new AbortController;r[a]={abortController:l,numConsumers:0,responsePromise:e({...o,signal:l.signal})};}let u=r[a];if(u.numConsumers++,i){let l=u.responsePromise;return await new Promise((p,f)=>{let g=E=>{i.removeEventListener("abort",g),u.numConsumers-=1,u.numConsumers===0&&u.abortController.abort();let b=new DOMException(E.target.reason,"AbortError");f(b);};i.addEventListener("abort",g),l.then(p).finally(()=>{i.removeEventListener("abort",g);});})}else return await u.responsePromise}}c();var ht=ve(Re(),1);function Ur(e){return e==null||typeof e!="object"||Array.isArray(e)?!1:"jsonrpc"in e&&e.jsonrpc==="2.0"&&"method"in e&&typeof e.method=="string"&&"params"in e}function yt(e){return Ur(e)?(0, ht.default)([e.method,e.params]):void 0}function Fr(e){let t={};for(let r in e)t[r.toLowerCase()]=e[r];return t}function li(e){return F(dt({...e,headers:{...e.headers?Fr(e.headers):void 0,"solana-client":"js/2.0.0-development"}}),t=>bt(t,yt))}c();c();var Kr={jsonrpc:"2.0",method:"ping"};function wt({intervalMs:e,transport:t}){let r=new Map;return async(...n)=>{let o=await t(...n),s;function i(){o.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(Kr);}function a(){clearInterval(s),s=setInterval(i,e);}if(r.has(o)===!1){r.set(o,{[Symbol.asyncIterator]:o[Symbol.asyncIterator].bind(o),send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:(...p)=>(a(),o.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...p))}),(async()=>{try{for await(let p of o)a();}catch{}finally{r.delete(o),clearInterval(s),u&&globalThis.window.removeEventListener("offline",u),l&&globalThis.window.removeEventListener("online",l);}})(),globalThis.navigator.onLine&&a();let u,l;u=()=>{clearInterval(s);},l=()=>{i(),a();},globalThis.window.addEventListener("offline",u),globalThis.window.addEventListener("online",l);}return r.get(o)}}c();var jr=Symbol(void 0);function St({getShard:e,transport:t}){return fe({getAbortSignalFromInputArgs:({signal:r})=>r,getCacheEntryMissingError(r){return new Error(`Found no cache entry for connection with shard key \`${r?.toString()}\``)},getCacheKeyFromInputArgs:({payload:r})=>e?e(r):jr,onCacheHit:(r,{payload:n})=>r.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(n),onCreateIterable:(r,n)=>t({...n,signal:r})})}function xi(e){let{getShard:t,intervalMs:r,...n}=e;return F(pt({...n,sendBufferHighWatermark:e.sendBufferHighWatermark??131072}),o=>wt({intervalMs:r??5e3,transport:o}),o=>St({getShard:t,transport:o}))}
|
|
10
10
|
|
|
11
|
-
exports.AccountRole =
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
11
|
+
exports.AccountRole = Ht;
|
|
12
|
+
exports.address = jo;
|
|
13
|
+
exports.appendTransactionInstruction = ws;
|
|
14
|
+
exports.assertIsBase58EncodedAddress = Pt;
|
|
15
|
+
exports.assertIsBlockhash = fs;
|
|
16
|
+
exports.assertIsDurableNonceTransaction = bs;
|
|
17
|
+
exports.createAddressWithSeed = Go;
|
|
18
|
+
exports.createDefaultRpcSubscriptionsTransport = xi;
|
|
19
|
+
exports.createDefaultRpcTransport = li;
|
|
20
|
+
exports.createSolanaRpc = Zs;
|
|
21
|
+
exports.createSolanaRpcSubscriptions = Qs;
|
|
22
|
+
exports.createTransaction = gs;
|
|
23
|
+
exports.downgradeRoleToNonSigner = Jo;
|
|
24
|
+
exports.downgradeRoleToReadonly = Xo;
|
|
25
|
+
exports.generateKeyPair = is;
|
|
26
|
+
exports.getAddressFromPublicKey = He;
|
|
27
|
+
exports.getBase58EncodedAddressCodec = U;
|
|
28
|
+
exports.getBase58EncodedAddressComparator = le;
|
|
29
|
+
exports.getBase64EncodedWireTransaction = xs;
|
|
30
|
+
exports.getProgramDerivedAddress = Ho;
|
|
31
|
+
exports.isBase58EncodedAddress = Ko;
|
|
32
|
+
exports.isSignerRole = Zo;
|
|
33
|
+
exports.isWritableRole = Qo;
|
|
34
|
+
exports.mergeRoles = es;
|
|
35
|
+
exports.prependTransactionInstruction = Ss;
|
|
36
|
+
exports.setTransactionFeePayer = ys;
|
|
37
|
+
exports.setTransactionLifetimeUsingBlockhash = ms;
|
|
38
|
+
exports.setTransactionLifetimeUsingDurableNonce = hs;
|
|
39
|
+
exports.signBytes = Ve;
|
|
40
|
+
exports.signTransaction = Es;
|
|
41
|
+
exports.upgradeRoleToSigner = ts;
|
|
42
|
+
exports.upgradeRoleToWritable = rs;
|
|
43
|
+
exports.verifySignature = as;
|
|
40
44
|
|
|
41
45
|
return exports;
|
|
42
46
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type CacheKey = string | symbol;
|
|
2
|
+
type Config<TInput extends unknown[], TIterable extends AsyncIterable<unknown>> = Readonly<{
|
|
3
|
+
getAbortSignalFromInputArgs: (...args: TInput) => AbortSignal;
|
|
4
|
+
getCacheEntryMissingError: (cacheKey: CacheKey) => Error;
|
|
5
|
+
getCacheKeyFromInputArgs: (...args: TInput) => CacheKey | undefined;
|
|
6
|
+
onCacheHit: (iterable: TIterable, ...args: TInput) => Promise<void>;
|
|
7
|
+
onCreateIterable: (abortSignal: AbortSignal, ...args: TInput) => Promise<TIterable>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function getCachedAbortableIterableFactory<TInput extends unknown[], TIterable extends AsyncIterable<unknown>>({ getAbortSignalFromInputArgs, getCacheEntryMissingError, getCacheKeyFromInputArgs, onCacheHit, onCreateIterable, }: Config<TInput, TIterable>): (...args: TInput) => Promise<TIterable>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=cached-abortable-iterable.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RpcSubscriptions } from '@solana/rpc-transport/dist/types/json-rpc-types';
|
|
2
|
+
type CacheKey = string | undefined;
|
|
3
|
+
type Config<TRpcSubscriptionsMethods> = Readonly<{
|
|
4
|
+
getDeduplicationKey: GetDeduplicationKeyFn;
|
|
5
|
+
rpcSubscriptions: RpcSubscriptions<TRpcSubscriptionsMethods>;
|
|
6
|
+
}>;
|
|
7
|
+
type GetDeduplicationKeyFn = (subscriptionMethod: string | symbol, payload: unknown) => CacheKey;
|
|
8
|
+
export declare function getRpcSubscriptionsWithSubscriptionCoalescing<TRpcSubscriptionsMethods>({ getDeduplicationKey, rpcSubscriptions, }: Config<TRpcSubscriptionsMethods>): RpcSubscriptions<TRpcSubscriptionsMethods>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=rpc-subscription-coalescer.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IRpcWebSocketTransport } from '@solana/rpc-transport/dist/types/transports/transport-types';
|
|
2
|
+
type Config = Readonly<{
|
|
3
|
+
intervalMs: number;
|
|
4
|
+
transport: IRpcWebSocketTransport;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function getWebSocketTransportWithAutoping({ intervalMs, transport }: Config): IRpcWebSocketTransport;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=rpc-websocket-autopinger.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IRpcWebSocketTransport } from '@solana/rpc-transport/dist/types/transports/transport-types';
|
|
2
|
+
type Config = Readonly<{
|
|
3
|
+
/**
|
|
4
|
+
* You might like to open more subscriptions per connection than your RPC provider allows for.
|
|
5
|
+
* Using the initial payload as input, return a shard key from this method to assign
|
|
6
|
+
* subscriptions to separate connections. One socket will be opened per shard key.
|
|
7
|
+
*/
|
|
8
|
+
getShard?: (payload: unknown) => string | symbol;
|
|
9
|
+
transport: IRpcWebSocketTransport;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function getWebSocketTransportWithConnectionSharding({ getShard, transport }: Config): IRpcWebSocketTransport;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=rpc-websocket-connection-sharding.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createWebSocketTransport } from '@solana/rpc-transport';
|
|
2
|
+
import { IRpcWebSocketTransport } from '@solana/rpc-transport/dist/types/transports/transport-types';
|
|
3
|
+
export declare function createDefaultRpcSubscriptionsTransport(config: Omit<Parameters<typeof createWebSocketTransport>[0], 'sendBufferHighWatermark'> & {
|
|
4
|
+
/**
|
|
5
|
+
* You might like to open more subscriptions per connection than your RPC provider allows
|
|
6
|
+
* for. Using the initial payload as input, return a shard key from this method to assign
|
|
7
|
+
* subscriptions to separate connections. One socket will be opened per shard key.
|
|
8
|
+
*/
|
|
9
|
+
getShard?: (payload: unknown) => string;
|
|
10
|
+
intervalMs?: number;
|
|
11
|
+
sendBufferHighWatermark?: number;
|
|
12
|
+
}): IRpcWebSocketTransport;
|
|
13
|
+
//# sourceMappingURL=rpc-websocket-transport.d.ts.map
|
package/dist/types/rpc.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { SolanaRpcMethods } from '@solana/rpc-core';
|
|
2
|
-
import { createJsonRpc } from '@solana/rpc-transport';
|
|
3
|
-
import type { Rpc } from '@solana/rpc-transport/dist/types/json-rpc-types';
|
|
1
|
+
import { SolanaRpcMethods, SolanaRpcSubscriptions } from '@solana/rpc-core';
|
|
2
|
+
import { createJsonRpc, createJsonSubscriptionRpc } from '@solana/rpc-transport';
|
|
3
|
+
import type { Rpc, RpcSubscriptions } from '@solana/rpc-transport/dist/types/json-rpc-types';
|
|
4
4
|
export declare function createSolanaRpc(config: Omit<Parameters<typeof createJsonRpc>[0], 'api'>): Rpc<SolanaRpcMethods>;
|
|
5
|
+
export declare function createSolanaRpcSubscriptions(config: Omit<Parameters<typeof createJsonSubscriptionRpc>[0], 'api'>): RpcSubscriptions<SolanaRpcSubscriptions>;
|
|
5
6
|
//# sourceMappingURL=rpc.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.ba46ce1",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -50,30 +50,31 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"fast-stable-stringify": "^1.0.0",
|
|
53
|
-
"@solana/addresses": "2.0.0-experimental.
|
|
54
|
-
"@solana/
|
|
55
|
-
"@solana/
|
|
56
|
-
"@solana/
|
|
57
|
-
"@solana/rpc-
|
|
58
|
-
"@solana/
|
|
53
|
+
"@solana/addresses": "2.0.0-experimental.ba46ce1",
|
|
54
|
+
"@solana/functional": "2.0.0-experimental.ba46ce1",
|
|
55
|
+
"@solana/instructions": "2.0.0-experimental.ba46ce1",
|
|
56
|
+
"@solana/keys": "2.0.0-experimental.ba46ce1",
|
|
57
|
+
"@solana/rpc-core": "2.0.0-experimental.ba46ce1",
|
|
58
|
+
"@solana/rpc-transport": "2.0.0-experimental.ba46ce1",
|
|
59
|
+
"@solana/transactions": "2.0.0-experimental.ba46ce1"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@solana/eslint-config-solana": "^1.0.2",
|
|
62
63
|
"@swc/jest": "^0.2.28",
|
|
63
|
-
"@types/jest": "^29.5.
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
64
|
+
"@types/jest": "^29.5.5",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
65
66
|
"@typescript-eslint/parser": "^6.3.0",
|
|
66
67
|
"agadoo": "^3.0.0",
|
|
67
68
|
"eslint": "^8.45.0",
|
|
68
69
|
"eslint-plugin-jest": "^27.2.3",
|
|
69
70
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
70
|
-
"jest": "^29.
|
|
71
|
+
"jest": "^29.7.0",
|
|
71
72
|
"jest-environment-jsdom": "^29.6.4",
|
|
72
73
|
"jest-runner-eslint": "^2.1.0",
|
|
73
74
|
"jest-runner-prettier": "^1.0.0",
|
|
74
75
|
"prettier": "^2.8",
|
|
75
76
|
"tsup": "7.2.0",
|
|
76
|
-
"typescript": "^5.
|
|
77
|
+
"typescript": "^5.2.2",
|
|
77
78
|
"version-from-git": "^1.1.1",
|
|
78
79
|
"build-scripts": "0.0.0",
|
|
79
80
|
"test-config": "0.0.0",
|