@solana/transactions 2.0.0-experimental.e6fc977 → 2.0.0-experimental.e72afd8

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.
@@ -2,25 +2,29 @@ this.globalThis = this.globalThis || {};
2
2
  this.globalThis.solanaWeb3 = (function (exports) {
3
3
  'use strict';
4
4
 
5
- function v(e,n,r=0){if(n.length-r<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function w(e,n,r,t=0){let o=r.length-t;if(o<n)throw new Error(`Codec [${e}] expected ${n} bytes, got ${o}.`)}var N=e=>{let n=e.filter(i=>i.length);if(n.length===0)return e.length?e[0]:new Uint8Array;if(n.length===1)return n[0];let r=n.reduce((i,s)=>i+s.length,0),t=new Uint8Array(r),o=0;return n.forEach(i=>{t.set(i,o),o+=i.length;}),t},zn=(e,n)=>{if(e.length>=n)return e;let r=new Uint8Array(n).fill(0);return r.set(e),r},X=(e,n)=>zn(e.length<=n?e:e.slice(0,n),n);function C(e,n,r){if(e.fixedSize!==n.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${n.fixedSize}].`);if(e.maxSize!==n.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${n.maxSize}].`);if(r===void 0&&e.description!==n.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${n.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:n.decode,description:r??e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function fe(e,n,r){return {description:r??`fixed(${n}, ${e.description})`,fixedSize:n,maxSize:n}}function M(e,n,r){return {...fe(e,n,r),encode:t=>X(e.encode(t),n)}}function U(e,n,r){return {...fe(e,n,r),decode:(t,o=0)=>{w("fixCodec",n,t,o),(o>0||t.length>n)&&(t=t.slice(o,o+n)),e.fixedSize!==null&&(t=X(t,e.fixedSize));let[i]=e.decode(t,0);return [i,o+n]}}}function z(e,n){return {description:e.description,encode:r=>e.encode(n(r)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function D(e,n){return {decode:(r,t=0)=>{let[o,i]=e.decode(r,t);return [n(o,r,t),i]},description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize}}function ge(e,n,r,t){if(t<n||t>r)throw new Error(`Codec [${e}] expected number to be in the range [${n}, ${r}], got ${t}.`)}function pe(e){let n,r=e.name;return e.size>1&&(n=!("endian"in e.options)||e.options.endian===0,r+=n?"(le)":"(be)"),{description:e.options.description??r,fixedSize:e.size,littleEndian:n,maxSize:e.size}}function me(e){let n=pe(e);return {description:n.description,encode(r){e.range&&ge(e.name,e.range[0],e.range[1],r);let t=new ArrayBuffer(e.size);return e.set(new DataView(t),r,n.littleEndian),new Uint8Array(t)},fixedSize:n.fixedSize,maxSize:n.maxSize}}function Te(e){let n=pe(e);return {decode(r,t=0){v(n.description,r,t),w(n.description,e.size,r,t);let o=new DataView(wn(r,t,e.size));return [e.get(o,n.littleEndian),t+e.size]},description:n.description,fixedSize:n.fixedSize,maxSize:n.maxSize}}function wn(e,n,r){let t=e.byteOffset+(n??0),o=r??e.byteLength;return e.buffer.slice(t,t+o)}var m=(e={})=>({description:e.description??"shortU16",encode:n=>{ge("shortU16",0,65535,n);let r=[0];for(let t=0;;t+=1){let o=n>>t*7;if(o===0)break;let i=127&o;r[t]=i,t>0&&(r[t-1]|=128);}return new Uint8Array(r)},fixedSize:null,maxSize:3}),T=(e={})=>({decode:(n,r=0)=>{let t=0,o=0;for(;++o;){let i=o-1,s=n[r+i],c=127&s;if(t|=c<<i*7,!(s&128))break}return [t,r+o]},description:e.description??"shortU16",fixedSize:null,maxSize:3});var O=(e={})=>me({name:"u32",options:e,range:[0,+"0xffffffff"],set:(n,r,t)=>n.setUint32(0,r,t),size:4}),$=(e={})=>Te({get:(n,r)=>n.getUint32(0,r),name:"u32",options:e,size:4});var x=(e={})=>me({name:"u8",options:e,range:[0,+"0xff"],set:(n,r)=>n.setUint8(0,r),size:1}),E=(e={})=>Te({get:n=>n.getUint8(0),name:"u8",options:e,size:1});function Dn(e,n,r=n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${r}].`)}var Bn=e=>{let n=e.length,r=BigInt(n);return {description:`base${n}`,encode(t){if(Dn(e,t),t==="")return new Uint8Array;let o=[...t],i=o.findIndex(p=>p!==e[0]);i=i===-1?o.length:i;let s=Array(i).fill(0);if(i===o.length)return Uint8Array.from(s);let c=o.slice(i),u=0n,a=1n;for(let p=c.length-1;p>=0;p-=1)u+=a*BigInt(e.indexOf(c[p])),a*=r;let l=[];for(;u>0n;)l.unshift(Number(u%256n)),u/=256n;return Uint8Array.from(s.concat(l))},fixedSize:null,maxSize:null}},vn=e=>{let n=e.length,r=BigInt(n);return {decode(t,o=0){let i=o===0?t:t.slice(o);if(i.length===0)return ["",0];let s=i.findIndex(l=>l!==0);s=s===-1?i.length:s;let c=e[0].repeat(s);if(s===i.length)return [c,t.length];let u=i.slice(s).reduce((l,p)=>l*256n+BigInt(p),0n),a=[];for(;u>0n;)a.unshift(e[Number(u%r)]),u/=r;return [c+a.join(""),t.length]},description:`base${n}`,fixedSize:null,maxSize:null}};var ye="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",k=()=>Bn(ye),_=()=>vn(ye);var Nn=e=>e.replace(/\u0000/g,"");var kn=globalThis.TextDecoder,_n=globalThis.TextEncoder,Ln=()=>{let e;return {description:"utf8",encode:n=>new Uint8Array((e||(e=new _n)).encode(n)),fixedSize:null,maxSize:null}},Rn=()=>{let e;return {decode(n,r=0){let t=(e||(e=new kn)).decode(n.slice(r));return [Nn(t),n.length]},description:"utf8",fixedSize:null,maxSize:null}};var W=(e={})=>{let n=e.size??O(),r=e.encoding??Ln(),t=e.description??`string(${r.description}; ${Ae(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?M(r,n,t):{description:t,encode:o=>{let i=r.encode(o),s=n.encode(i.length);return N([s,i])},fixedSize:null,maxSize:null}},P=(e={})=>{let n=e.size??$(),r=e.encoding??Rn(),t=e.description??`string(${r.description}; ${Ae(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?U(r,n,t):{decode:(o,i=0)=>{v("string",o,i);let[s,c]=n.decode(o,i),u=Number(s);i=c;let a=o.slice(i,i+u);w("string",u,a);let[l,p]=r.decode(a);return i+=p,[l,i]},description:t,fixedSize:null,maxSize:null}};function Ae(e){return typeof e=="object"?e.description:`${e}`}function I(e){if("signatures"in e){let{signatures:n,...r}=e;return r}else return e}var Z;function Cr(e){Z||(Z=k());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=Z.encode(e).byteLength;if(r!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${r}`)}catch(n){throw new Error(`\`${e}\` is not a blockhash`,{cause:n})}}function he(e,n){if("lifetimeConstraint"in n&&n.lifetimeConstraint.blockhash===e.blockhash&&n.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return n;let r={...I(n),lifetimeConstraint:e};return Object.freeze(r),r}function be({version:e}){let n={instructions:[],version:e};return Object.freeze(n),n}var g=(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))(g||{});var Mn=1;function y(e){return e>=2}function B(e){return (e&Mn)!==0}function J(e,n){return e|n}var xe="SysvarRecentB1ockHashes11111111111111111111",Ee="11111111111111111111111111111111";function Pr(e){if(!Ie(e))throw new Error("Transaction is not a durable nonce transaction")}function Se(e,n){return {accounts:[{address:e,role:g.WRITABLE},{address:xe,role:g.READONLY},{address:n,role:g.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Ee}}function V(e){return e.programAddress===Ee&&e.data!=null&&Un(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===g.WRITABLE&&e.accounts[1].address===xe&&e.accounts[1].role===g.READONLY&&e.accounts[2].address!=null&&y(e.accounts[2].role)}function Un(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Ie(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&V(e.instructions[0])}function On(e,n,r){return e.accounts[0].address===n&&e.accounts[2].address===r}function Ce({nonce:e,nonceAccountAddress:n,nonceAuthorityAddress:r},t){let o,i=t.instructions[0];if(i&&V(i))if(On(i,n,r)){if(Ie(t)&&t.lifetimeConstraint.nonce===e)return t;o=[i,...t.instructions.slice(1)];}else o=[Se(n,r),...t.instructions.slice(1)];else o=[Se(n,r),...t.instructions];let s={...I(t),instructions:o,lifetimeConstraint:{nonce:e}};return Object.freeze(s),s}function ze(e,n){if("feePayer"in n&&e===n.feePayer)return n;let r={...I(n),feePayer:e};return Object.freeze(r),r}function we(e,n){let r={...I(n),instructions:[...n.instructions,e]};return Object.freeze(r),r}function Gr(e,n){let r={...I(n),instructions:[e,...n.instructions]};return Object.freeze(r),r}function F(e){return e.reduce((n,r)=>n===null||r===null?null:n+r,0)}function $n(e,n,r,t){if(typeof e=="number")return [e,t];if(typeof e=="object")return e.decode(r,t);if(e==="remainder"){let o=F(n);if(o===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');let i=r.slice(t).length;if(i%o!==0)throw new Error(`The remainder of the byte array (${i} bytes) cannot be split into chunks of ${o} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${i} modulo ${o} should be equal to zero.`);return [i/o,t]}throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(e)}`)}function Wn(e){return typeof e=="object"?e.description:`${e}`}function De(e,n){if(typeof e!="number")return null;if(e===0)return 0;let r=F(n);return r===null?null:r*e}function Pn(e,n){return typeof e=="object"?e.encode(n):new Uint8Array}function Vn(e,n,r){if(n!==r)throw new Error(`Expected [${e}] to have ${n} items, got ${r}.`)}function Be(e,n,r){if(n==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:r??`array(${e.description}; ${Wn(n)})`,fixedSize:De(n,[e.fixedSize]),maxSize:De(n,[e.maxSize])}}function A(e,n={}){let r=n.size??O();return {...Be(e,r,n.description),encode:t=>(typeof r=="number"&&Vn("array",r,t.length),N([Pn(r,t.length),...t.map(o=>e.encode(o))]))}}function h(e,n={}){let r=n.size??$();return {...Be(e,r,n.description),decode:(t,o=0)=>{if(typeof r=="object"&&t.slice(o).length===0)return [[],o];let[i,s]=$n(r,[e.fixedSize],t,o);o=s;let c=[];for(let u=0;u<i;u+=1){let[a,l]=e.decode(t,o);c.push(a),o=l;}return [c,o]}}}function H(e={}){let n=e.size??"variable",r=typeof n=="object"?n.description:`${n}`,t=e.description??`bytes(${r})`,o={description:t,encode:i=>i,fixedSize:null,maxSize:null};return n==="variable"?o:typeof n=="number"?M(o,n,t):{...o,encode:i=>{let s=o.encode(i),c=n.encode(s.length);return N([c,s])}}}function K(e={}){let n=e.size??"variable",r=typeof n=="object"?n.description:`${n}`,t=e.description??`bytes(${r})`,o={decode:(i,s=0)=>{let c=i.slice(s);return [c,s+c.length]},description:t,fixedSize:null,maxSize:null};return n==="variable"?o:typeof n=="number"?U(o,n,t):{...o,decode:(i,s=0)=>{v("bytes",i,s);let[c,u]=n.decode(i,s),a=Number(c);s=u;let l=i.slice(s,s+a);w("bytes",a,l);let[p,Cn]=o.decode(l);return s+=Cn,[p,s]}}}function ve(e,n){let r=e.map(([t,o])=>`${String(t)}: ${o.description}`).join(", ");return {description:n??`struct(${r})`,fixedSize:F(e.map(([,t])=>t.fixedSize)),maxSize:F(e.map(([,t])=>t.maxSize))}}function b(e,n={}){return {...ve(e,n.description),encode:r=>{let t=e.map(([o,i])=>i.encode(r[o]));return N(t)}}}function S(e,n={}){return {...ve(e,n.description),decode:(r,t=0)=>{let o={};return e.forEach(([i,s])=>{let[c,u]=s.decode(r,t);t=u,o[i]=c;}),[o,t]}}}function Ne(){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")}async function ke(){if(Ne(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function _e(){if(Ne(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}var Q,ee;function Le(){return Q||(Q=k()),Q}function Fn(){return ee||(ee=_()),ee}function j(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=Le().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(n){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:n})}}function Hn(e){return j(e),e}function Y(e){return z(W({description:e?.description??"Address",encoding:Le(),size:32}),n=>Hn(n))}function L(e){return P({description:e?.description??"Address",encoding:Fn(),size:32})}function R(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}async function Re(e){if(await ke(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let n=await crypto.subtle.exportKey("raw",e),[r]=L().decode(new Uint8Array(n));return r}function Me(e,n,r){e[n]=r(e[n]??{role:g.READONLY});}var f=Symbol("AddressMapTypeProperty");function Ue(e,n){let r={[e]:{[f]:0,role:g.WRITABLE_SIGNER}},t=new Set;for(let o of n){Me(r,o.programAddress,s=>{if(t.add(o.programAddress),f in s){if(B(s.role))switch(s[f]){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(s[f]===2)return s}return {[f]:2,role:g.READONLY}});let i;if(o.accounts)for(let s of o.accounts)Me(r,s.address,c=>{let{address:u,...a}=s;if(f in c)switch(c[f]){case 0:return c;case 1:{let l=J(c.role,a.role);if("lookupTableAddress"in a){if(c.lookupTableAddress!==a.lookupTableAddress&&(i||(i=R()))(a.lookupTableAddress,c.lookupTableAddress)<0)return {[f]:1,...a,role:l}}else if(y(a.role))return {[f]:2,role:l};return c.role!==l?{...c,role:l}:c}case 2:{let l=J(c.role,a.role);if(t.has(s.address)){if(B(a.role))throw new Error(`This transaction includes an address (\`${s.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return c.role!==l?{...c,role:l}:c}else return "lookupTableAddress"in a&&!y(c.role)?{...a,[f]:1,role:l}:c.role!==l?{...c,role:l}:c}}return "lookupTableAddress"in a?{...a,[f]:1}:{...a,[f]:2}});}return r}function Oe(e){let n;return Object.entries(e).sort(([t,o],[i,s])=>{if(o[f]!==s[f]){if(o[f]===0)return -1;if(s[f]===0)return 1;if(o[f]===2)return -1;if(s[f]===2)return 1}let c=y(o.role);if(c!==y(s.role))return c?-1:1;let u=B(o.role);return u!==B(s.role)?u?-1:1:(n||(n=R()),o[f]===1&&s[f]===1&&o.lookupTableAddress!==s.lookupTableAddress?n(o.lookupTableAddress,s.lookupTableAddress):n(t,i))}).map(([t,o])=>({address:t,...o}))}function $e(e){var r;let n={};for(let t of e){if(!("lookupTableAddress"in t))continue;let o=n[r=t.lookupTableAddress]||(n[r]={readableIndices:[],writableIndices:[]});t.role===g.WRITABLE?o.writableIndices.push(t.addressIndex):o.readableIndices.push(t.addressIndex);}return Object.keys(n).sort(R()).map(t=>({lookupTableAddress:t,...n[t]}))}function We(e){let n=0,r=0,t=0;for(let o of e){if("lookupTableAddress"in o)break;let i=B(o.role);y(o.role)?(t++,i||r++):i||n++;}return {numReadonlyNonSignerAccounts:n,numReadonlySignerAccounts:r,numSignerAccounts:t}}function Kn(e){let n={};for(let[r,t]of e.entries())n[t.address]=r;return n}function Pe(e,n){let r=Kn(n);return e.map(({accounts:t,data:o,programAddress:i})=>({programAddressIndex:r[i],...t?{accountIndices:t.map(({address:s})=>r[s])}:null,...o?{data:o}:null}))}function Ve(e){return "nonce"in e?e.nonce:e.blockhash}function Fe(e){let n=e.findIndex(t=>"lookupTableAddress"in t);return (n===-1?e:e.slice(0,n)).map(({address:t})=>t)}function G(e){let n=Ue(e.feePayer,e.instructions),r=Oe(n);return {...e.version!=="legacy"?{addressTableLookups:$e(r)}:null,header:We(r),instructions:Pe(e.instructions,r),lifetimeToken:Ve(e.lifetimeConstraint),staticAccounts:Fe(r),version:e.version}}function He(e){let n=G(e),r;if("signatures"in e){r=[];for(let t=0;t<n.header.numSignerAccounts;t++)r[t]=e.signatures[n.staticAccounts[t]]??new Uint8Array(Array(64).fill(0));}else r=Array(n.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:n,signatures:r}}function Ke(e,...n){return n.reduce((r,t)=>t(r),e)}function jn(e){let{header:n}=e,r=n.numSignerAccounts-n.numReadonlySignerAccounts,t=e.staticAccounts.length-n.numSignerAccounts-n.numReadonlyNonSignerAccounts,o=[],i=0;for(let s=0;s<r;s++)o.push({address:e.staticAccounts[i],role:g.WRITABLE_SIGNER}),i++;for(let s=0;s<n.numReadonlySignerAccounts;s++)o.push({address:e.staticAccounts[i],role:g.READONLY_SIGNER}),i++;for(let s=0;s<t;s++)o.push({address:e.staticAccounts[i],role:g.WRITABLE}),i++;for(let s=0;s<n.numReadonlyNonSignerAccounts;s++)o.push({address:e.staticAccounts[i],role:g.READONLY}),i++;return o}function Yn(e,n){let r=n[e.programAddressIndex]?.address;if(!r)throw new Error(`Could not find program address at index ${e.programAddressIndex}`);let t=e.accountIndices?.map(i=>n[i]),{data:o}=e;return {programAddress:r,...t&&t.length?{accounts:t}:{},...o&&o.length?{data:o}:{}}}function Gn(e,n,r){if(!n||!V(n))return {blockhash:e,lastValidBlockHeight:r??2n**64n-1n};{let t=n.accounts[0].address;j(t);let o=n.accounts[2].address;return j(o),{nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:o}}}function qn(e){let{compiledMessage:{staticAccounts:n},signatures:r}=e;return r.reduce((t,o,i)=>{if(o.every(u=>u===0))return t;let c=n[i];return {...t,[c]:o}},{})}function je(e,n){let{compiledMessage:r}=e;if("addressTableLookups"in r&&r.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let t=r.staticAccounts[0];if(!t)throw new Error("No fee payer set in CompiledTransaction");let o=jn(r),i=r.instructions.map(a=>Yn(a,o)),s=i[0],c=Gn(r.lifetimeToken,s,n),u=qn(e);return Ke(be({version:r.version}),a=>ze(t,a),a=>i.reduce((l,p)=>we(p,l),a),a=>"blockhash"in c?he(c,a):Ce(c,a),a=>e.signatures.length?{...a,signatures:u}:a)}var Ye="lookupTableAddress",Ge="writableIndices",qe="readableIndices",Xe="addressTableLookup",ne;function Ze(){return ne||(ne=b([["lookupTableAddress",Y({description:Ye})],["writableIndices",A(x(),{description:Ge,size:m()})],["readableIndices",A(x(),{description:qe,size:m()})]],{description:Xe})),ne}var re;function Je(){return re||(re=S([["lookupTableAddress",L({description:Ye})],["writableIndices",h(E(),{description:Ge,size:T()})],["readableIndices",h(E(),{description:qe,size:T()})]],{description:Xe})),re}var te;function Xn(){return te||(te=x()),te}function oe(e){let n=Xn();return {...n,description:e??n.description}}var ie;function Zn(){return ie||(ie=E()),ie}function se(e){let n=Zn();return {...n,description:e??n.description}}var Qe=void 0,en=void 0,nn=void 0,rn=void 0;function tn(){return b([["numSignerAccounts",oe(Qe)],["numReadonlySignerAccounts",oe(en)],["numReadonlyNonSignerAccounts",oe(nn)]],{description:rn})}function on(){return S([["numSignerAccounts",se(Qe)],["numReadonlySignerAccounts",se(en)],["numReadonlyNonSignerAccounts",se(nn)]],{description:rn})}var sn="programAddressIndex",cn=void 0,an="accountIndices",dn="data",ce;function un(){return ce||(ce=z(b([["programAddressIndex",x({description:sn})],["accountIndices",A(x({description:cn}),{description:an,size:m()})],["data",H({description:dn,size:m()})]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),ce}var ae;function ln(){return ae||(ae=D(S([["programAddressIndex",E({description:sn})],["accountIndices",h(E({description:cn}),{description:an,size:T()})],["data",K({description:dn,size:T()})]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:n,data:r,...t}=e;return {...t,...n.length?{accountIndices:n}:null,...r.byteLength?{data:r}:null}})),ae}var de=128,fn={description:"",fixedSize:null,maxSize:1};function Jn(e,n=0){let r=e[n];return r&de?[r^de,n+1]:["legacy",n]}function Qn(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|de])}function gn(){return {...fn,decode:Jn}}function pn(){return {...fn,encode:Qn}}var mn="staticAccounts",Tn="lifetimeToken",yn="instructions",An="addressTableLookups";function er(){return b(hn())}function nr(){return z(b([...hn(),["addressTableLookups",tr()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function hn(){return [["version",pn()],["header",tn()],["staticAccounts",A(Y(),{description:mn,size:m()})],["lifetimeToken",W({description:Tn,encoding:k(),size:32})],["instructions",A(un(),{description:yn,size:m()})]]}function rr(){return [["version",gn()],["header",on()],["staticAccounts",h(L(),{description:mn,size:T()})],["lifetimeToken",P({description:Tn,encoding:_(),size:32})],["instructions",h(ln(),{description:yn,size:T()})],["addressTableLookups",or()]]}function tr(){return A(Ze(),{description:An,size:m()})}function or(){return h(Je(),{description:An,size:T()})}var bn="message";function q(){return {description:bn,encode:e=>e.version==="legacy"?er().encode(e):nr().encode(e),fixedSize:null,maxSize:null}}function Sn(){return D(S(rr(),{description:bn}),({addressTableLookups:e,...n})=>n.version==="legacy"||!e?.length?n:{...n,addressTableLookups:e})}var xn="signatures",En="transaction";function ir(){return b([["signatures",A(H({size:64}),{description:xn,size:m()})],["compiledMessage",q()]],{description:En})}function sr(){return D(K({size:64}),e=>e)}function cr(){return S([["signatures",h(sr(),{description:xn,size:T()})],["compiledMessage",Sn()]],{description:En})}function ue(){return z(ir(),He)}function ar(e){return D(cr(),n=>je(n,e))}function ci(e){return C(ue(),ar(e))}async function In(e,n){await _e();let r=await crypto.subtle.sign("Ed25519",e,n);return new Uint8Array(r)}var le;function Ii(e){le||(le=_());let n=e.signatures[e.feePayer];if(!n)throw new Error("Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.");return le.decode(n)[0]}async function dr(e,n){let r=G(n),t="signatures"in n?{...n.signatures}:{},o=q().encode(r),i=await Promise.all(e.map(c=>Promise.all([Re(c.publicKey),In(c.privateKey,o)])));for(let[c,u]of i)t[c]=u;let s={...n,signatures:t};return Object.freeze(s),s}async function Ci(e,n){let r=await dr(e,n);return ur(r),Object.freeze(r),r}function ur(e){let n=e.instructions.flatMap(t=>t.accounts?.filter(o=>y(o.role))??[]).map(t=>t.address);new Set([e.feePayer,...n]).forEach(t=>{if(!e.signatures[t])throw new Error(`Transaction is missing signature for address \`${t}\``)});}function Bi(e){let n=ue().encode(e);return btoa(String.fromCharCode(...n))}
5
+ function v(e,n,r=0){if(n.length-r<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function w(e,n,r,t=0){let o=r.length-t;if(o<n)throw new Error(`Codec [${e}] expected ${n} bytes, got ${o}.`)}var N=e=>{let n=e.filter(i=>i.length);if(n.length===0)return e.length?e[0]:new Uint8Array;if(n.length===1)return n[0];let r=n.reduce((i,s)=>i+s.length,0),t=new Uint8Array(r),o=0;return n.forEach(i=>{t.set(i,o),o+=i.length;}),t},Bn=(e,n)=>{if(e.length>=n)return e;let r=new Uint8Array(n).fill(0);return r.set(e),r},Q=(e,n)=>Bn(e.length<=n?e:e.slice(0,n),n);function x(e,n,r){if(e.fixedSize!==n.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${n.fixedSize}].`);if(e.maxSize!==n.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${n.maxSize}].`);if(r===void 0&&e.description!==n.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${n.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:n.decode,description:r!=null?r:e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function Te(e,n,r){return {description:r!=null?r:`fixed(${n}, ${e.description})`,fixedSize:n,maxSize:n}}function O(e,n,r){return {...Te(e,n,r),encode:t=>Q(e.encode(t),n)}}function $(e,n,r){return {...Te(e,n,r),decode:(t,o=0)=>{w("fixCodec",n,t,o),(o>0||t.length>n)&&(t=t.slice(o,o+n)),e.fixedSize!==null&&(t=Q(t,e.fixedSize));let[i]=e.decode(t,0);return [i,o+n]}}}function z(e,n){return {description:e.description,encode:r=>e.encode(n(r)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function D(e,n){return {decode:(r,t=0)=>{let[o,i]=e.decode(r,t);return [n(o,r,t),i]},description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize}}function ye(e,n,r,t){if(t<n||t>r)throw new Error(`Codec [${e}] expected number to be in the range [${n}, ${r}], got ${t}.`)}function Ae(e){var t;let n,r=e.name;return e.size>1&&(n=!("endian"in e.config)||e.config.endian===0,r+=n?"(le)":"(be)"),{description:(t=e.config.description)!=null?t:r,fixedSize:e.size,littleEndian:n,maxSize:e.size}}function he(e){let n=Ae(e);return {description:n.description,encode(r){e.range&&ye(e.name,e.range[0],e.range[1],r);let t=new ArrayBuffer(e.size);return e.set(new DataView(t),r,n.littleEndian),new Uint8Array(t)},fixedSize:n.fixedSize,maxSize:n.maxSize}}function be(e){let n=Ae(e);return {decode(r,t=0){v(n.description,r,t),w(n.description,e.size,r,t);let o=new DataView(vn(r,t,e.size));return [e.get(o,n.littleEndian),t+e.size]},description:n.description,fixedSize:n.fixedSize,maxSize:n.maxSize}}function vn(e,n,r){let t=e.byteOffset+(n!=null?n:0),o=r!=null?r:e.byteLength;return e.buffer.slice(t,t+o)}var p=(e={})=>{var n;return {description:(n=e.description)!=null?n:"shortU16",encode:r=>{ye("shortU16",0,65535,r);let t=[0];for(let o=0;;o+=1){let i=r>>o*7;if(i===0)break;let s=127&i;t[o]=s,o>0&&(t[o-1]|=128);}return new Uint8Array(t)},fixedSize:null,maxSize:3}},T=(e={})=>{var n;return {decode:(r,t=0)=>{let o=0,i=0;for(;++i;){let s=i-1,c=r[t+s],a=127&c;if(o|=a<<s*7,!(c&128))break}return [o,t+i]},description:(n=e.description)!=null?n:"shortU16",fixedSize:null,maxSize:3}};var P=(e={})=>he({config:e,name:"u32",range:[0,+"0xffffffff"],set:(n,r,t)=>n.setUint32(0,r,t),size:4}),W=(e={})=>be({config:e,get:(n,r)=>n.getUint32(0,r),name:"u32",size:4});var E=(e={})=>he({config:e,name:"u8",range:[0,+"0xff"],set:(n,r)=>n.setUint8(0,r),size:1}),I=(e={})=>be({config:e,get:n=>n.getUint8(0),name:"u8",size:1});function Nn(e,n,r=n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${r}].`)}var kn=e=>{let n=e.length,r=BigInt(n);return {description:`base${n}`,encode(t){if(Nn(e,t),t==="")return new Uint8Array;let o=[...t],i=o.findIndex(g=>g!==e[0]);i=i===-1?o.length:i;let s=Array(i).fill(0);if(i===o.length)return Uint8Array.from(s);let c=o.slice(i),a=0n,d=1n;for(let g=c.length-1;g>=0;g-=1)a+=d*BigInt(e.indexOf(c[g])),d*=r;let l=[];for(;a>0n;)l.unshift(Number(a%256n)),a/=256n;return Uint8Array.from(s.concat(l))},fixedSize:null,maxSize:null}},_n=e=>{let n=e.length,r=BigInt(n);return {decode(t,o=0){let i=o===0?t:t.slice(o);if(i.length===0)return ["",0];let s=i.findIndex(l=>l!==0);s=s===-1?i.length:s;let c=e[0].repeat(s);if(s===i.length)return [c,t.length];let a=i.slice(s).reduce((l,g)=>l*256n+BigInt(g),0n),d=[];for(;a>0n;)d.unshift(e[Number(a%r)]),a/=r;return [c+d.join(""),t.length]},description:`base${n}`,fixedSize:null,maxSize:null}};var Se="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",k=()=>kn(Se),_=()=>_n(Se);var xe=()=>({decode(e,n=0){let r=e.slice(n);return [btoa(String.fromCharCode(...r)),e.length]},description:"base64",fixedSize:null,maxSize:null});var Rn=e=>e.replace(/\u0000/g,"");var Ln=globalThis.TextDecoder,Mn=globalThis.TextEncoder,Un=()=>{let e;return {description:"utf8",encode:n=>new Uint8Array((e||(e=new Mn)).encode(n)),fixedSize:null,maxSize:null}},On=()=>{let e;return {decode(n,r=0){let t=(e||(e=new Ln)).decode(n.slice(r));return [Rn(t),n.length]},description:"utf8",fixedSize:null,maxSize:null}};var V=(e={})=>{var o,i,s;let n=(o=e.size)!=null?o:P(),r=(i=e.encoding)!=null?i:Un(),t=(s=e.description)!=null?s:`string(${r.description}; ${Ee(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?O(r,n,t):{description:t,encode:c=>{let a=r.encode(c),d=n.encode(a.length);return N([d,a])},fixedSize:null,maxSize:null}},F=(e={})=>{var o,i,s;let n=(o=e.size)!=null?o:W(),r=(i=e.encoding)!=null?i:On(),t=(s=e.description)!=null?s:`string(${r.description}; ${Ee(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?$(r,n,t):{decode:(c,a=0)=>{v("string",c,a);let[d,l]=n.decode(c,a),g=Number(d);a=l;let R=c.slice(a,a+g);w("string",g,R);let[Z,J]=r.decode(R);return a+=J,[Z,a]},description:t,fixedSize:null,maxSize:null}};function Ee(e){return typeof e=="object"?e.description:`${e}`}function C(e){if("signatures"in e){let{signatures:n,...r}=e;return r}else return e}var ee;function Dr(e){ee||(ee=k());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=ee.encode(e).byteLength;if(r!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${r}`)}catch(n){throw new Error(`\`${e}\` is not a blockhash`,{cause:n})}}function Ie(e,n){if("lifetimeConstraint"in n&&n.lifetimeConstraint.blockhash===e.blockhash&&n.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return n;let r={...C(n),lifetimeConstraint:e};return Object.freeze(r),r}function Ce({version:e}){let n={instructions:[],version:e};return Object.freeze(n),n}var m=(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))(m||{});var $n=1;function y(e){return e>=2}function B(e){return (e&$n)!==0}function ne(e,n){return e|n}var we="SysvarRecentB1ockHashes11111111111111111111",De="11111111111111111111111111111111";function Hr(e){if(!Be(e))throw new Error("Transaction is not a durable nonce transaction")}function ze(e,n){return {accounts:[{address:e,role:m.WRITABLE},{address:we,role:m.READONLY},{address:n,role:m.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:De}}function H(e){var n;return e.programAddress===De&&e.data!=null&&Pn(e.data)&&((n=e.accounts)==null?void 0:n.length)===3&&e.accounts[0].address!=null&&e.accounts[0].role===m.WRITABLE&&e.accounts[1].address===we&&e.accounts[1].role===m.READONLY&&e.accounts[2].address!=null&&y(e.accounts[2].role)}function Pn(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Be(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&H(e.instructions[0])}function Wn(e,n,r){return e.accounts[0].address===n&&e.accounts[2].address===r}function ve({nonce:e,nonceAccountAddress:n,nonceAuthorityAddress:r},t){let o,i=t.instructions[0];if(i&&H(i))if(Wn(i,n,r)){if(Be(t)&&t.lifetimeConstraint.nonce===e)return t;o=[i,...t.instructions.slice(1)];}else o=[ze(n,r),...t.instructions.slice(1)];else o=[ze(n,r),...t.instructions];let s={...C(t),instructions:o,lifetimeConstraint:{nonce:e}};return Object.freeze(s),s}function Ne(e,n){if("feePayer"in n&&e===n.feePayer)return n;let r={...C(n),feePayer:e};return Object.freeze(r),r}function ke(e,n){let r={...C(n),instructions:[...n.instructions,e]};return Object.freeze(r),r}function Zr(e,n){let r={...C(n),instructions:[e,...n.instructions]};return Object.freeze(r),r}function _e(){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")}async function Re(){var e;if(_e(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.exportKey)!="function")throw new Error("No key export implementation could be found")}async function Le(){var e;if(_e(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.sign)!="function")throw new Error("No signing implementation could be found")}var re,te;function Me(){return re||(re=k()),re}function Vn(){return te||(te=_()),te}function K(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=Me().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(n){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:n})}}function Fn(e){return K(e),e}function j(e){var n;return z(V({description:(n=e==null?void 0:e.description)!=null?n:"Address",encoding:Me(),size:32}),r=>Fn(r))}function L(e){var n;return F({description:(n=e==null?void 0:e.description)!=null?n:"Address",encoding:Vn(),size:32})}function M(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}async function Ue(e){if(await Re(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let n=await crypto.subtle.exportKey("raw",e),[r]=L().decode(new Uint8Array(n));return r}function Oe(e,n,r){var t;e[n]=r((t=e[n])!=null?t:{role:m.READONLY});}var f=Symbol("AddressMapTypeProperty");function $e(e,n){let r={[e]:{[f]:0,role:m.WRITABLE_SIGNER}},t=new Set;for(let o of n){Oe(r,o.programAddress,s=>{if(t.add(o.programAddress),f in s){if(B(s.role))switch(s[f]){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(s[f]===2)return s}return {[f]:2,role:m.READONLY}});let i;if(o.accounts)for(let s of o.accounts)Oe(r,s.address,c=>{let{address:a,...d}=s;if(f in c)switch(c[f]){case 0:return c;case 1:{let l=ne(c.role,d.role);if("lookupTableAddress"in d){if(c.lookupTableAddress!==d.lookupTableAddress&&(i||(i=M()))(d.lookupTableAddress,c.lookupTableAddress)<0)return {[f]:1,...d,role:l}}else if(y(d.role))return {[f]:2,role:l};return c.role!==l?{...c,role:l}:c}case 2:{let l=ne(c.role,d.role);if(t.has(s.address)){if(B(d.role))throw new Error(`This transaction includes an address (\`${s.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return c.role!==l?{...c,role:l}:c}else return "lookupTableAddress"in d&&!y(c.role)?{...d,[f]:1,role:l}:c.role!==l?{...c,role:l}:c}}return "lookupTableAddress"in d?{...d,[f]:1}:{...d,[f]:2}});}return r}function Pe(e){let n;return Object.entries(e).sort(([t,o],[i,s])=>{if(o[f]!==s[f]){if(o[f]===0)return -1;if(s[f]===0)return 1;if(o[f]===2)return -1;if(s[f]===2)return 1}let c=y(o.role);if(c!==y(s.role))return c?-1:1;let a=B(o.role);return a!==B(s.role)?a?-1:1:(n||(n=M()),o[f]===1&&s[f]===1&&o.lookupTableAddress!==s.lookupTableAddress?n(o.lookupTableAddress,s.lookupTableAddress):n(t,i))}).map(([t,o])=>({address:t,...o}))}function We(e){var r;let n={};for(let t of e){if(!("lookupTableAddress"in t))continue;let o=n[r=t.lookupTableAddress]||(n[r]={readableIndices:[],writableIndices:[]});t.role===m.WRITABLE?o.writableIndices.push(t.addressIndex):o.readableIndices.push(t.addressIndex);}return Object.keys(n).sort(M()).map(t=>({lookupTableAddress:t,...n[t]}))}function Ve(e){let n=0,r=0,t=0;for(let o of e){if("lookupTableAddress"in o)break;let i=B(o.role);y(o.role)?(t++,i||r++):i||n++;}return {numReadonlyNonSignerAccounts:n,numReadonlySignerAccounts:r,numSignerAccounts:t}}function Hn(e){let n={};for(let[r,t]of e.entries())n[t.address]=r;return n}function Fe(e,n){let r=Hn(n);return e.map(({accounts:t,data:o,programAddress:i})=>({programAddressIndex:r[i],...t?{accountIndices:t.map(({address:s})=>r[s])}:null,...o?{data:o}:null}))}function He(e){return "nonce"in e?e.nonce:e.blockhash}function Ke(e){let n=e.findIndex(t=>"lookupTableAddress"in t);return (n===-1?e:e.slice(0,n)).map(({address:t})=>t)}function Y(e){let n=$e(e.feePayer,e.instructions),r=Pe(n);return {...e.version!=="legacy"?{addressTableLookups:We(r)}:null,header:Ve(r),instructions:Fe(e.instructions,r),lifetimeToken:He(e.lifetimeConstraint),staticAccounts:Ke(r),version:e.version}}function G(e){return e.reduce((n,r)=>n===null||r===null?null:n+r,0)}function Kn(e,n,r,t){if(typeof e=="number")return [e,t];if(typeof e=="object")return e.decode(r,t);if(e==="remainder"){let o=G(n);if(o===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');let i=r.slice(t).length;if(i%o!==0)throw new Error(`The remainder of the byte array (${i} bytes) cannot be split into chunks of ${o} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${i} modulo ${o} should be equal to zero.`);return [i/o,t]}throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(e)}`)}function jn(e){return typeof e=="object"?e.description:`${e}`}function je(e,n){if(typeof e!="number")return null;if(e===0)return 0;let r=G(n);return r===null?null:r*e}function Yn(e,n){return typeof e=="object"?e.encode(n):new Uint8Array}function Gn(e,n,r){if(n!==r)throw new Error(`Expected [${e}] to have ${n} items, got ${r}.`)}function Ye(e,n,r){if(n==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:r!=null?r:`array(${e.description}; ${jn(n)})`,fixedSize:je(n,[e.fixedSize]),maxSize:je(n,[e.maxSize])}}function A(e,n={}){var t;let r=(t=n.size)!=null?t:P();return {...Ye(e,r,n.description),encode:o=>(typeof r=="number"&&Gn("array",r,o.length),N([Yn(r,o.length),...o.map(i=>e.encode(i))]))}}function h(e,n={}){var t;let r=(t=n.size)!=null?t:W();return {...Ye(e,r,n.description),decode:(o,i=0)=>{if(typeof r=="object"&&o.slice(i).length===0)return [[],i];let[s,c]=Kn(r,[e.fixedSize],o,i);i=c;let a=[];for(let d=0;d<s;d+=1){let[l,g]=e.decode(o,i);a.push(l),i=g;}return [a,i]}}}function q(e={}){var i,s;let n=(i=e.size)!=null?i:"variable",r=typeof n=="object"?n.description:`${n}`,t=(s=e.description)!=null?s:`bytes(${r})`,o={description:t,encode:c=>c,fixedSize:null,maxSize:null};return n==="variable"?o:typeof n=="number"?O(o,n,t):{...o,encode:c=>{let a=o.encode(c),d=n.encode(a.length);return N([d,a])}}}function X(e={}){var i,s;let n=(i=e.size)!=null?i:"variable",r=typeof n=="object"?n.description:`${n}`,t=(s=e.description)!=null?s:`bytes(${r})`,o={decode:(c,a=0)=>{let d=c.slice(a);return [d,a+d.length]},description:t,fixedSize:null,maxSize:null};return n==="variable"?o:typeof n=="number"?$(o,n,t):{...o,decode:(c,a=0)=>{v("bytes",c,a);let[d,l]=n.decode(c,a),g=Number(d);a=l;let R=c.slice(a,a+g);w("bytes",g,R);let[Z,J]=o.decode(R);return a+=J,[Z,a]}}}function Ge(e,n){let r=e.map(([t,o])=>`${String(t)}: ${o.description}`).join(", ");return {description:n!=null?n:`struct(${r})`,fixedSize:G(e.map(([,t])=>t.fixedSize)),maxSize:G(e.map(([,t])=>t.maxSize))}}function b(e,n={}){return {...Ge(e,n.description),encode:r=>{let t=e.map(([o,i])=>i.encode(r[o]));return N(t)}}}function S(e,n={}){return {...Ge(e,n.description),decode:(r,t=0)=>{let o={};return e.forEach(([i,s])=>{let[c,a]=s.decode(r,t);t=a,o[i]=c;}),[o,t]}}}var qe="lookupTableAddress",Xe="writableIndices",Ze="readableIndices",Je="addressTableLookup",oe;function Qe(){return oe||(oe=b([["lookupTableAddress",j({description:qe})],["writableIndices",A(E(),{description:Xe,size:p()})],["readableIndices",A(E(),{description:Ze,size:p()})]],{description:Je})),oe}var ie;function en(){return ie||(ie=S([["lookupTableAddress",L({description:qe})],["writableIndices",h(I(),{description:Xe,size:T()})],["readableIndices",h(I(),{description:Ze,size:T()})]],{description:Je})),ie}var se;function qn(){return se||(se=E()),se}function ce(e){let n=qn();return {...n,description:e!=null?e:n.description}}var ae;function Xn(){return ae||(ae=I()),ae}function de(e){let n=Xn();return {...n,description:e!=null?e:n.description}}var nn=void 0,rn=void 0,tn=void 0,on=void 0;function sn(){return b([["numSignerAccounts",ce(nn)],["numReadonlySignerAccounts",ce(rn)],["numReadonlyNonSignerAccounts",ce(tn)]],{description:on})}function cn(){return S([["numSignerAccounts",de(nn)],["numReadonlySignerAccounts",de(rn)],["numReadonlyNonSignerAccounts",de(tn)]],{description:on})}var an="programAddressIndex",dn=void 0,un="accountIndices",ln="data",ue;function fn(){return ue||(ue=z(b([["programAddressIndex",E({description:an})],["accountIndices",A(E({description:dn}),{description:un,size:p()})],["data",q({description:ln,size:p()})]]),e=>{var n,r;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(n=e.accountIndices)!=null?n:[],data:(r=e.data)!=null?r:new Uint8Array(0)}})),ue}var le;function gn(){return le||(le=D(S([["programAddressIndex",I({description:an})],["accountIndices",h(I({description:dn}),{description:un,size:T()})],["data",X({description:ln,size:T()})]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:n,data:r,...t}=e;return {...t,...n.length?{accountIndices:n}:null,...r.byteLength?{data:r}:null}})),le}var fe=128,mn={description:"",fixedSize:null,maxSize:1};function Zn(e,n=0){let r=e[n];return r&fe?[r^fe,n+1]:["legacy",n]}function Jn(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|fe])}function pn(){return {...mn,decode:Zn}}function Tn(){return {...mn,encode:Jn}}var yn="staticAccounts",An="lifetimeToken",hn="instructions",bn="addressTableLookups";function Qn(){return b(Sn())}function er(){return z(b([...Sn(),["addressTableLookups",rr()]]),e=>{var n;return e.version==="legacy"?e:{...e,addressTableLookups:(n=e.addressTableLookups)!=null?n:[]}})}function Sn(){return [["version",Tn()],["header",sn()],["staticAccounts",A(j(),{description:yn,size:p()})],["lifetimeToken",V({description:An,encoding:k(),size:32})],["instructions",A(fn(),{description:hn,size:p()})]]}function nr(){return [["version",pn()],["header",cn()],["staticAccounts",h(L(),{description:yn,size:T()})],["lifetimeToken",F({description:An,encoding:_(),size:32})],["instructions",h(gn(),{description:hn,size:T()})],["addressTableLookups",tr()]]}function rr(){return A(Qe(),{description:bn,size:p()})}function tr(){return h(en(),{description:bn,size:T()})}var xn="message";function U(){return {description:xn,encode:e=>e.version==="legacy"?Qn().encode(e):er().encode(e),fixedSize:null,maxSize:null}}function ge(){return D(S(nr(),{description:xn}),({addressTableLookups:e,...n})=>n.version==="legacy"||!(e!=null&&e.length)?n:{...n,addressTableLookups:e})}function No(){return x(U(),ge())}function En(e){var t;let n=Y(e),r;if("signatures"in e){r=[];for(let o=0;o<n.header.numSignerAccounts;o++)r[o]=(t=e.signatures[n.staticAccounts[o]])!=null?t:new Uint8Array(Array(64).fill(0));}else r=Array(n.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:n,signatures:r}}function In(e,...n){return n.reduce((r,t)=>t(r),e)}function or(e){let{header:n}=e,r=n.numSignerAccounts-n.numReadonlySignerAccounts,t=e.staticAccounts.length-n.numSignerAccounts-n.numReadonlyNonSignerAccounts,o=[],i=0;for(let s=0;s<r;s++)o.push({address:e.staticAccounts[i],role:m.WRITABLE_SIGNER}),i++;for(let s=0;s<n.numReadonlySignerAccounts;s++)o.push({address:e.staticAccounts[i],role:m.READONLY_SIGNER}),i++;for(let s=0;s<t;s++)o.push({address:e.staticAccounts[i],role:m.WRITABLE}),i++;for(let s=0;s<n.numReadonlyNonSignerAccounts;s++)o.push({address:e.staticAccounts[i],role:m.READONLY}),i++;return o}function ir(e,n){var i,s;let r=(i=n[e.programAddressIndex])==null?void 0:i.address;if(!r)throw new Error(`Could not find program address at index ${e.programAddressIndex}`);let t=(s=e.accountIndices)==null?void 0:s.map(c=>n[c]),{data:o}=e;return {programAddress:r,...t&&t.length?{accounts:t}:{},...o&&o.length?{data:o}:{}}}function sr(e,n,r){if(!n||!H(n))return {blockhash:e,lastValidBlockHeight:r!=null?r:2n**64n-1n};{let t=n.accounts[0].address;K(t);let o=n.accounts[2].address;return K(o),{nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:o}}}function cr(e){let{compiledMessage:{staticAccounts:n},signatures:r}=e;return r.reduce((t,o,i)=>{if(o.every(a=>a===0))return t;let c=n[i];return {...t,[c]:o}},{})}function Cn(e,n){let{compiledMessage:r}=e;if("addressTableLookups"in r&&r.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let t=r.staticAccounts[0];if(!t)throw new Error("No fee payer set in CompiledTransaction");let o=or(r),i=r.instructions.map(d=>ir(d,o)),s=i[0],c=sr(r.lifetimeToken,s,n),a=cr(e);return In(Ce({version:r.version}),d=>Ne(t,d),d=>i.reduce((l,g)=>ke(g,l),d),d=>"blockhash"in c?Ie(c,d):ve(c,d),d=>e.signatures.length?{...d,signatures:a}:d)}var zn="signatures",wn="transaction";function ar(){return b([["signatures",A(q({size:64}),{description:zn,size:p()})],["compiledMessage",U()]],{description:wn})}function dr(){return D(X({size:64}),e=>e)}function ur(){return S([["signatures",h(dr(),{description:zn,size:T()})],["compiledMessage",ge()]],{description:wn})}function me(){return z(ar(),En)}function lr(e){return D(ur(),n=>Cn(n,e))}function li(e){return x(me(),lr(e))}async function Dn(e,n){await Le();let r=await crypto.subtle.sign("Ed25519",e,n);return new Uint8Array(r)}var pe;function Di(e){pe||(pe=_());let n=e.signatures[e.feePayer];if(!n)throw new Error("Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.");return pe.decode(n)[0]}async function fr(e,n){let r=Y(n),t="signatures"in n?{...n.signatures}:{},o=U().encode(r),i=await Promise.all(e.map(c=>Promise.all([Ue(c.publicKey),Dn(c.privateKey,o)])));for(let[c,a]of i)t[c]=a;let s={...n,signatures:t};return Object.freeze(s),s}async function Bi(e,n){let r=await fr(e,n);return gr(r),Object.freeze(r),r}function gr(e){let n=e.instructions.flatMap(t=>{var o,i;return (i=(o=t.accounts)==null?void 0:o.filter(s=>y(s.role)))!=null?i:[]}).map(t=>t.address);new Set([e.feePayer,...n]).forEach(t=>{if(!e.signatures[t])throw new Error(`Transaction is missing signature for address \`${t}\``)});}function Ri(e){let n=me().encode(e);return xe().decode(n)[0]}
6
6
 
7
- exports.appendTransactionInstruction = we;
8
- exports.assertIsBlockhash = Cr;
9
- exports.assertIsDurableNonceTransaction = Pr;
10
- exports.assertTransactionIsFullySigned = ur;
11
- exports.createTransaction = be;
12
- exports.getBase64EncodedWireTransaction = Bi;
13
- exports.getSignatureFromTransaction = Ii;
14
- exports.getTransactionCodec = ci;
15
- exports.getTransactionDecoder = ar;
16
- exports.getTransactionEncoder = ue;
17
- exports.isAdvanceNonceAccountInstruction = V;
18
- exports.partiallySignTransaction = dr;
19
- exports.prependTransactionInstruction = Gr;
20
- exports.setTransactionFeePayer = ze;
21
- exports.setTransactionLifetimeUsingBlockhash = he;
22
- exports.setTransactionLifetimeUsingDurableNonce = Ce;
23
- exports.signTransaction = Ci;
7
+ exports.appendTransactionInstruction = ke;
8
+ exports.assertIsBlockhash = Dr;
9
+ exports.assertIsDurableNonceTransaction = Hr;
10
+ exports.assertTransactionIsFullySigned = gr;
11
+ exports.compileMessage = Y;
12
+ exports.createTransaction = Ce;
13
+ exports.getBase64EncodedWireTransaction = Ri;
14
+ exports.getCompiledMessageCodec = No;
15
+ exports.getCompiledMessageDecoder = ge;
16
+ exports.getCompiledMessageEncoder = U;
17
+ exports.getSignatureFromTransaction = Di;
18
+ exports.getTransactionCodec = li;
19
+ exports.getTransactionDecoder = lr;
20
+ exports.getTransactionEncoder = me;
21
+ exports.isAdvanceNonceAccountInstruction = H;
22
+ exports.partiallySignTransaction = fr;
23
+ exports.prependTransactionInstruction = Zr;
24
+ exports.setTransactionFeePayer = Ne;
25
+ exports.setTransactionLifetimeUsingBlockhash = Ie;
26
+ exports.setTransactionLifetimeUsingDurableNonce = ve;
27
+ exports.signTransaction = Bi;
24
28
 
25
29
  return exports;
26
30
 
@@ -4,6 +4,7 @@ export * from './create-transaction';
4
4
  export * from './durable-nonce';
5
5
  export * from './fee-payer';
6
6
  export * from './instructions';
7
+ export * from './message';
7
8
  export * from './serializers';
8
9
  export * from './signatures';
9
10
  export * from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
@@ -1,2 +1,3 @@
1
+ export * from './message';
1
2
  export * from './transaction';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serializers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serializers/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"wire-transaction.d.ts","sourceRoot":"","sources":["../../src/wire-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,MAAM,4BAA4B,GAAG,MAAM,GAAG;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC;CACnC,CAAC;AAEF,wBAAgB,+BAA+B,CAC3C,WAAW,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/E,4BAA4B,CAO9B"}
1
+ {"version":3,"file":"wire-transaction.d.ts","sourceRoot":"","sources":["../../src/wire-transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,MAAM,4BAA4B,GAAG,MAAM,GAAG;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC;CACnC,CAAC;AAEF,wBAAgB,+BAA+B,CAC3C,WAAW,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/E,4BAA4B,CAG9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/transactions",
3
- "version": "2.0.0-experimental.e6fc977",
3
+ "version": "2.0.0-experimental.e72afd8",
4
4
  "description": "Helpers for creating and serializing transactions",
5
5
  "exports": {
6
6
  "browser": {
@@ -46,13 +46,13 @@
46
46
  "maintained node versions"
47
47
  ],
48
48
  "dependencies": {
49
- "@solana/addresses": "2.0.0-experimental.e6fc977",
50
- "@solana/codecs-core": "2.0.0-experimental.e6fc977",
51
- "@solana/codecs-data-structures": "2.0.0-experimental.e6fc977",
52
- "@solana/codecs-numbers": "2.0.0-experimental.e6fc977",
53
- "@solana/codecs-strings": "2.0.0-experimental.e6fc977",
54
- "@solana/functional": "2.0.0-experimental.e6fc977",
55
- "@solana/keys": "2.0.0-experimental.e6fc977"
49
+ "@solana/addresses": "2.0.0-experimental.e72afd8",
50
+ "@solana/codecs-core": "2.0.0-experimental.e72afd8",
51
+ "@solana/codecs-numbers": "2.0.0-experimental.e72afd8",
52
+ "@solana/codecs-strings": "2.0.0-experimental.e72afd8",
53
+ "@solana/codecs-data-structures": "2.0.0-experimental.e72afd8",
54
+ "@solana/functional": "2.0.0-experimental.e72afd8",
55
+ "@solana/keys": "2.0.0-experimental.e72afd8"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@solana/eslint-config-solana": "^1.0.2",
@@ -68,10 +68,10 @@
68
68
  "jest-runner-eslint": "^2.1.2",
69
69
  "jest-runner-prettier": "^1.0.0",
70
70
  "prettier": "^2.8",
71
- "tsup": "7.2.0",
71
+ "tsup": "^8.0.1",
72
72
  "typescript": "^5.2.2",
73
73
  "version-from-git": "^1.1.1",
74
- "@solana/instructions": "2.0.0-experimental.e6fc977",
74
+ "@solana/instructions": "2.0.0-experimental.e72afd8",
75
75
  "build-scripts": "0.0.0",
76
76
  "test-config": "0.0.0",
77
77
  "test-matchers": "0.0.0",