@solana/compat 2.0.0-experimental.fb88a79 → 2.0.0-experimental.fbbf6ba

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.
@@ -1,14 +0,0 @@
1
- this.globalThis = this.globalThis || {};
2
- this.globalThis.solanaWeb3 = (function (exports) {
3
- 'use strict';
4
-
5
- function Y(e){return e.toBase58()}function w(e,r){return "fixedSize"in r?r.fixedSize:r.getSizeFromValue(e)}function S(e){return Object.freeze({...e,encode:r=>{let n=new Uint8Array(w(r,e));return e.write(r,n,0),n}})}function P(e,r,n=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${n}].`)}var K=e=>S({getSizeFromValue:r=>{let[n,t]=I(r,e[0]);if(t==="")return r.length;let o=T(t,e);return n.length+Math.ceil(o.toString(16).length/2)},write(r,n,t){if(P(e,r),r==="")return t;let[o,s]=I(r,e[0]);if(s==="")return n.set(new Uint8Array(o.length).fill(0),t),t+o.length;let a=T(s,e),i=[];for(;a>0n;)i.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...i];return n.set(c,t),t+c.length}});function I(e,r){let n=[...e].findIndex(t=>t!==r);return n===-1?[e,""]:[e.slice(0,n),e.slice(n)]}function T(e,r){let n=BigInt(r.length);return [...e].reduce((t,o)=>t*n+BigInt(r.indexOf(o)),0n)}var M="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",v=()=>K(M);function _(e){return new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32,...e])}async function B(e,r){if(e.byteLength!==32)throw new Error("Private key bytes must be of length 32");let n=_(e);return await crypto.subtle.importKey("pkcs8",n,"Ed25519",r!=null?r:!1,["sign"])}async function le(e,r){let[n,t]=await Promise.all([crypto.subtle.importKey("raw",e.publicKey.toBytes(),"Ed25519",!0,["verify"]),B(e.secretKey.slice(0,32),r)]);return {privateKey:t,publicKey:n}}var h;function O(){return h||(h=v()),h}function p(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=O().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(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function y(e,...r){return r.reduce((n,t)=>t(n),e)}var u=(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))(u||{});function g(e){if("signatures"in e){let{signatures:r,...n}=e;return n}else return e}function x(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let n={...g(r),lifetimeConstraint:e};return Object.freeze(n),n}function A({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}var l=(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))(l||{});function F(e){return e>=2}var C="SysvarRecentB1ockHashes11111111111111111111",D="11111111111111111111111111111111";function z(e,r){return {accounts:[{address:e,role:l.WRITABLE},{address:C,role:l.READONLY},{address:r,role:l.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:D}}function f(e){var r;return e.programAddress===D&&e.data!=null&&W(e.data)&&((r=e.accounts)==null?void 0:r.length)===3&&e.accounts[0].address!=null&&e.accounts[0].role===l.WRITABLE&&e.accounts[1].address===C&&e.accounts[1].role===l.READONLY&&e.accounts[2].address!=null&&F(e.accounts[2].role)}function W(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function U(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&f(e.instructions[0])}function $(e,r,n){return e.accounts[0].address===r&&e.accounts[2].address===n}function L({nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:n},t){let o,s=t.instructions[0];if(s&&f(s))if($(s,r,n)){if(U(t)&&t.lifetimeConstraint.nonce===e)return t;o=[s,...t.instructions.slice(1)];}else o=[z(r,n),...t.instructions.slice(1)];else o=[z(r,n),...t.instructions];let a={...g(t),instructions:o,lifetimeConstraint:{nonce:e}};return Object.freeze(a),a}function E(e,r){if("feePayer"in r&&e===r.feePayer)return r;let n={...g(r),feePayer:e};return Object.freeze(n),n}function b(e,r){let n={...g(r),instructions:[...r.instructions,e]};return Object.freeze(n),n}function V(e,r,n){let t=r.get(n);if(!t)throw new Error(`Could not find account address at index ${n}`);let o=e.isAccountSigner(n),s=e.isAccountWritable(n),a=o?s?u.WRITABLE_SIGNER:u.READONLY_SIGNER:s?u.WRITABLE:u.READONLY;return {address:t.toBase58(),role:a}}function R(e,r,n){let t=r.get(n.programIdIndex);if(!t)throw new Error(`Could not find program address at index ${n.programIdIndex}`);let o=n.accountKeyIndexes.map(s=>V(e,r,s));return {programAddress:t.toBase58(),...o.length?{accounts:o}:{},...n.data.length?{data:n.data}:{}}}function N(e,r){return e.signatures.reduce((n,t,o)=>{if(t.every(i=>i===0))return n;let a=r[o].toBase58();return {...n,[a]:t}},{})}function Le(e,r){if(e.message.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let n=e.message.getAccountKeys(),t=n.staticAccountKeys[0];if(!t)throw new Error("No fee payer set in VersionedTransaction");let o={blockhash:e.message.recentBlockhash,lastValidBlockHeight:r!=null?r:2n**64n-1n},s=e.message.compiledInstructions.map(i=>R(e.message,n,i)),a=N(e,n.staticAccountKeys);return y(A({version:e.version}),i=>E(t.toBase58(),i),i=>x(o,i),i=>s.reduce((c,m)=>b(m,c),i),i=>e.signatures.length?{...i,signatures:a}:i)}function Re(e){if(e.message.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let r=e.message.getAccountKeys(),n=r.staticAccountKeys[0];if(!n)throw new Error("No fee payer set in VersionedTransaction");let t=e.message.compiledInstructions.map(c=>R(e.message,r,c));if(t.length===0)throw new Error("transaction with no instructions cannot be durable nonce transaction");if(!f(t[0]))throw new Error("transaction first instruction is not advance nonce account instruction");let o=t[0].accounts[0].address;p(o);let s=t[0].accounts[2].address;p(s);let a={nonce:e.message.recentBlockhash,nonceAccountAddress:o,nonceAuthorityAddress:s},i=N(e,r.staticAccountKeys);return y(A({version:e.version}),c=>E(n.toBase58(),c),c=>L(a,c),c=>t.slice(1).reduce((m,k)=>b(k,m),c),c=>e.signatures.length?{...c,signatures:i}:c)}
6
-
7
- exports.fromLegacyKeypair = le;
8
- exports.fromLegacyPublicKey = Y;
9
- exports.fromVersionedTransactionWithBlockhash = Le;
10
- exports.fromVersionedTransactionWithDurableNonce = Re;
11
-
12
- return exports;
13
-
14
- })({});