@solana/addresses 2.0.0-experimental.762ff13 → 2.0.0-experimental.76cf6b4

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,20 +2,20 @@ this.globalThis = this.globalThis || {};
2
2
  this.globalThis.solanaWeb3 = (function (exports) {
3
3
  'use strict';
4
4
 
5
- function y(e,r,t=0){if(r.length-t<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function h(e,r,t,n=0){let s=t.length-n;if(s<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${s}.`)}var I=e=>{let r=e.filter(o=>o.length);if(r.length===0)return e.length?e[0]:new Uint8Array;if(r.length===1)return r[0];let t=r.reduce((o,i)=>o+i.length,0),n=new Uint8Array(t),s=0;return r.forEach(o=>{n.set(o,s),s+=o.length;}),n},Y=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},C=(e,r)=>Y(e.length<=r?e:e.slice(0,r),r);function x(e,r,t){if(e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);if(t===void 0&&e.description!==r.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${r.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:r.decode,description:t??e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function D(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r}}function U(e,r,t){return {...D(e,r,t),encode:n=>C(e.encode(n),r)}}function T(e,r,t){return {...D(e,r,t),decode:(n,s=0)=>{h("fixCodec",r,n,s),(s>0||n.length>r)&&(n=n.slice(s,s+r)),e.fixedSize!==null&&(n=C(n,e.fixedSize));let[o]=e.decode(n,0);return [o,s+r]}}}function $(e,r){return {description:e.description,encode:t=>e.encode(r(t)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function J(e,r,t,n){if(n<r||n>t)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${t}], got ${n}.`)}function P(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===0,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,littleEndian:r,maxSize:e.size}}function Q(e){let r=P(e);return {description:r.description,encode(t){e.range&&J(e.name,e.range[0],e.range[1],t);let n=new ArrayBuffer(e.size);return e.set(new DataView(n),t,r.littleEndian),new Uint8Array(n)},fixedSize:r.fixedSize,maxSize:r.maxSize}}function ee(e){let r=P(e);return {decode(t,n=0){y(r.description,t,n),h(r.description,e.size,t,n);let s=new DataView(re(t,n,e.size));return [e.get(s,r.littleEndian),n+e.size]},description:r.description,fixedSize:r.fixedSize,maxSize:r.maxSize}}function re(e,r,t){let n=e.byteOffset+(r??0),s=t??e.byteLength;return e.buffer.slice(n,n+s)}var N=(e={})=>Q({name:"u32",options:e,range:[0,+"0xffffffff"],set:(r,t,n)=>r.setUint32(0,t,n),size:4}),F=(e={})=>ee({get:(r,t)=>r.getUint32(0,t),name:"u32",options:e,size:4});function te(e,r,t=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${t}].`)}var ne=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,encode(n){if(te(e,n),n==="")return new Uint8Array;let s=[...n],o=s.findIndex(g=>g!==e[0]);o=o===-1?s.length:o;let i=Array(o).fill(0);if(o===s.length)return Uint8Array.from(i);let a=s.slice(o),d=0n,c=1n;for(let g=a.length-1;g>=0;g-=1)d+=c*BigInt(e.indexOf(a[g])),c*=t;let f=[];for(;d>0n;)f.unshift(Number(d%256n)),d/=256n;return Uint8Array.from(i.concat(f))},fixedSize:null,maxSize:null}},oe=e=>{let r=e.length,t=BigInt(r);return {decode(n,s=0){let o=s===0?n:n.slice(s);if(o.length===0)return ["",0];let i=o.findIndex(f=>f!==0);i=i===-1?o.length:i;let a=e[0].repeat(i);if(i===o.length)return [a,n.length];let d=o.slice(i).reduce((f,g)=>f*256n+BigInt(g),0n),c=[];for(;d>0n;)c.unshift(e[Number(d%t)]),d/=t;return [a+c.join(""),n.length]},description:`base${r}`,fixedSize:null,maxSize:null}};var _="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",O=()=>ne(_),R=()=>oe(_);var se=e=>e.replace(/\u0000/g,"");var ie=globalThis.TextDecoder,de=globalThis.TextEncoder,ce=()=>{let e;return {description:"utf8",encode:r=>new Uint8Array((e||(e=new de)).encode(r)),fixedSize:null,maxSize:null}},ae=()=>{let e;return {decode(r,t=0){let n=(e||(e=new ie)).decode(r.slice(t));return [se(n),r.length]},description:"utf8",fixedSize:null,maxSize:null}};var L=(e={})=>{let r=e.size??N(),t=e.encoding??ce(),n=e.description??`string(${t.description}; ${K(r)})`;return r==="variable"?{...t,description:n}:typeof r=="number"?U(t,r,n):{description:n,encode:s=>{let o=t.encode(s),i=r.encode(o.length);return I([i,o])},fixedSize:null,maxSize:null}},k=(e={})=>{let r=e.size??F(),t=e.encoding??ae(),n=e.description??`string(${t.description}; ${K(r)})`;return r==="variable"?{...t,description:n}:typeof r=="number"?T(t,r,n):{decode:(s,o=0)=>{y("string",s,o);let[i,a]=r.decode(s,o),d=Number(i);o=a;let c=s.slice(o,o+d);h("string",d,c);let[f,g]=t.decode(c);return o+=g,[f,o]},description:n,fixedSize:null,maxSize:null}};function K(e){return typeof e=="object"?e.description:`${e}`}var v,A;function z(){return v||(v=O()),v}function fe(){return A||(A=R()),A}function M(e){return !(e.length<32||e.length>44||z().encode(e).byteLength!==32)}function w(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 n=z().encode(e).byteLength;if(n!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${n}`)}catch(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function ge(e){return w(e),e}function ue(e){return $(L({description:e?.description??"Base58EncodedAddress",encoding:z(),size:32}),r=>ge(r))}function B(e){return k({description:e?.description??"Base58EncodedAddress",encoding:fe(),size:32})}function S(e){return x(ue(e),B(e))}function Fe(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function X(){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 H(){if(X(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!="function")throw new Error("No digest implementation could be found")}async function V(){if(X(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}var le=37095705934669439343138083508754565189542113879843219016388785533085940283555n,u=57896044618658097711785492504343953926634992332820282019728792003956564819949n,G=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function l(e){let r=e%u;return r>=0n?r:u+r}function m(e,r){let t=e;for(;r-- >0n;)t*=t,t%=u;return t}function me(e){let t=e*e%u*e%u,n=m(t,2n)*t%u,s=m(n,1n)*e%u,o=m(s,5n)*s%u,i=m(o,10n)*o%u,a=m(i,20n)*i%u,d=m(a,40n)*a%u,c=m(d,80n)*d%u,f=m(c,80n)*d%u,g=m(f,10n)*o%u;return m(g,2n)*e%u}function pe(e,r){let t=l(r*r*r),n=l(t*t*r),s=me(e*n),o=l(e*t*s),i=l(r*o*o),a=o,d=l(o*G),c=i===e,f=i===l(-e),g=i===l(-e*G);return c&&(o=a),(f||g)&&(o=d),(l(o)&1n)===1n&&(o=l(-o)),!c&&!f?null:o}function j(e,r){let t=l(e*e),n=l(t-1n),s=l(le*t+1n),o=pe(n,s);if(o===null)return !1;let i=(r&128)!==0;return !(o===0n&&i)}function he(e){let r=e.toString(16);return r.length===1?`0${r}`:r}function ye(e){let t=`0x${e.reduce((n,s,o)=>`${he(o===31?s&-129:s)}${n}`,"")}`;return BigInt(t)}async function W(e){if(e.byteLength!==32)return !1;let r=ye(e);return j(r,e[31])}function qe(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"&&e[1]>=0&&e[1]<=255&&M(e[0])}function Ze(e){if(!(Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"))throw new Error("Expected given program derived address to have the following format: [Base58EncodedAddress, ProgramDerivedAddressBump].");if(e[1]<0||e[1]>255)throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${e[1]}.`);w(e[0]);}var Z=32,q=16,b=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115],E=class extends Error{};async function xe({programAddress:e,seeds:r}){if(await H(),r.length>q)throw new Error(`A maximum of ${q} seeds may be supplied when creating an address`);let t,n=r.reduce((d,c,f)=>{let g=typeof c=="string"?(t||(t=new TextEncoder)).encode(c):c;if(g.byteLength>Z)throw new Error(`The seed at index ${f} exceeds the maximum length of 32 bytes`);return d.push(...g),d},[]),s=S(),o=s.encode(e),i=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...o,...b])),a=new Uint8Array(i);if(await W(a))throw new E("Invalid seeds; point must fall off the Ed25519 curve");return s.decode(a)[0]}async function Ye({programAddress:e,seeds:r}){let t=255;for(;t>0;)try{return [await xe({programAddress:e,seeds:[...r,new Uint8Array([t])]}),t]}catch(n){if(n instanceof E)t--;else throw n}throw new Error("Unable to find a viable program address bump seed")}async function Je({baseAddress:e,programAddress:r,seed:t}){let{encode:n,decode:s}=S(),o=typeof t=="string"?new TextEncoder().encode(t):t;if(o.byteLength>Z)throw new Error("The seed exceeds the maximum length of 32 bytes");let i=n(r);if(i.length>=b.length&&i.slice(-b.length).every((c,f)=>c===b[f]))throw new Error("programAddress cannot end with the PDA marker");let a=await crypto.subtle.digest("SHA-256",new Uint8Array([...n(e),...o,...i])),d=new Uint8Array(a);return s(d)[0]}async function or(e){if(await V(),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]=B().decode(new Uint8Array(r));return t}
5
+ function E(e,r,t=0){if(r.length-t<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function x(e,r,t,n=0){let o=t.length-n;if(o<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${o}.`)}var re=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},te=(e,r)=>re(e.length<=r?e:e.slice(0,r),r);function w(e,r){return "fixedSize"in r?r.fixedSize:r.getSizeFromValue(e)}function p(e){return Object.freeze({...e,encode:r=>{let t=new Uint8Array(w(r,e));return e.write(r,t,0),t}})}function b(e){return Object.freeze({...e,decode:(r,t=0)=>e.read(r,t)[0]})}function y(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function ne(e){return !y(e)}function A(e,r){if(y(e)!==y(r))throw new Error("Encoder and decoder must either both be fixed-size or variable-size.");if(y(e)&&y(r)&&e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(!y(e)&&!y(r)&&e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);return {...r,...e,decode:r.decode,encode:e.encode,read:r.read,write:e.write}}function T(e,r){return p({fixedSize:r,write:(t,n,o)=>{let s=e.encode(t),i=s.length>r?s.slice(0,r):s;return n.set(i,o),o+r}})}function N(e,r){return b({fixedSize:r,read:(t,n)=>{x("fixCodec",r,t,n),(n>0||t.length>r)&&(t=t.slice(n,n+r)),y(e)&&(t=te(t,e.fixedSize));let[o]=e.read(t,0);return [o,n+r]}})}function P(e,r){return p({...ne(e)?{...e,getSizeFromValue:t=>e.getSizeFromValue(r(t))}:e,write:(t,n,o)=>e.write(r(t),n,o)})}function oe(e,r,t,n){if(n<r||n>t)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${t}], got ${n}.`)}function $(e){return (e==null?void 0:e.endian)!==1}function se(e){return p({fixedSize:e.size,write(r,t,n){e.range&&oe(e.name,e.range[0],e.range[1],r);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),r,$(e.config)),t.set(new Uint8Array(o),n),n+e.size}})}function ie(e){return b({fixedSize:e.size,read(r,t=0){E(e.name,r,t),x(e.name,e.size,r,t);let n=new DataView(ae(r,t,e.size));return [e.get(n,$(e.config)),t+e.size]}})}function ae(e,r,t){let n=e.byteOffset+(r!=null?r:0),o=t!=null?t:e.byteLength;return e.buffer.slice(n,n+o)}var O=(e={})=>se({config:e,name:"u32",range:[0,+"0xffffffff"],set:(r,t,n)=>r.setUint32(0,t,n),size:4}),_=(e={})=>ie({config:e,get:(r,t)=>r.getUint32(0,t),name:"u32",size:4});function de(e,r,t=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${t}].`)}var ce=e=>p({getSizeFromValue:r=>{let[t,n]=L(r,e[0]);if(n==="")return r.length;let o=V(n,e);return t.length+Math.ceil(o.toString(16).length/2)},write(r,t,n){if(de(e,r),r==="")return n;let[o,s]=L(r,e[0]);if(s==="")return t.set(new Uint8Array(o.length).fill(0),n),n+o.length;let i=V(s,e),d=[];for(;i>0n;)d.unshift(Number(i%256n)),i/=256n;let a=[...Array(o.length).fill(0),...d];return t.set(a,n),n+a.length}}),fe=e=>b({read(r,t){let n=t===0?r:r.slice(t);if(n.length===0)return ["",0];let o=n.findIndex(a=>a!==0);o=o===-1?n.length:o;let s=e[0].repeat(o);if(o===n.length)return [s,r.length];let i=n.slice(o).reduce((a,c)=>a*256n+BigInt(c),0n),d=ge(i,e);return [s+d,r.length]}});function L(e,r){let t=[...e].findIndex(n=>n!==r);return t===-1?[e,""]:[e.slice(0,t),e.slice(t)]}function V(e,r){let t=BigInt(r.length);return [...e].reduce((n,o)=>n*t+BigInt(r.indexOf(o)),0n)}function ge(e,r){let t=BigInt(r.length),n=[];for(;e>0n;)n.unshift(r[Number(e%t)]),e/=t;return n.join("")}var k="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",M=()=>ce(k),K=()=>fe(k);var ue=e=>e.replace(/\u0000/g,"");var le=globalThis.TextDecoder,R=globalThis.TextEncoder,me=()=>{let e;return p({getSizeFromValue:r=>(e||(e=new R)).encode(r).length,write:(r,t,n)=>{let o=(e||(e=new R)).encode(r);return t.set(o,n),n+o.length}})},he=()=>{let e;return b({read(r,t){let n=(e||(e=new le)).decode(r.slice(t));return [ue(n),r.length]}})};function X(e={}){var n,o;let r=(n=e.size)!=null?n:O(),t=(o=e.encoding)!=null?o:me();return r==="variable"?t:typeof r=="number"?T(t,r):p({getSizeFromValue:s=>{let i=w(s,t);return w(i,r)+i},write:(s,i,d)=>{let a=w(s,t);return d=r.write(a,i,d),t.write(s,i,d)}})}function H(e={}){var n,o;let r=(n=e.size)!=null?n:_(),t=(o=e.encoding)!=null?o:he();return r==="variable"?t:typeof r=="number"?N(t,r):b({read:(s,i=0)=>{E("string",s,i);let[d,a]=r.read(s,i),c=Number(d);i=a;let u=s.slice(i,i+c);x("string",c,u);let[h,F]=t.read(u,0);return i+=F,[h,i]}})}var B,I;function S(){return B||(B=M()),B}function ye(){return I||(I=K()),I}function j(e){return !(e.length<32||e.length>44||S().encode(e).byteLength!==32)}function C(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 n=S().encode(e).byteLength;if(n!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${n}`)}catch(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function pe(e){return C(e),e}function be(){return P(X({encoding:S(),size:32}),e=>pe(e))}function D(){return H({encoding:ye(),size:32})}function U(){return A(be(),D())}function Me(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function G(){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 Z(){var e;if(G(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.digest)!="function")throw new Error("No digest implementation could be found")}async function W(){var e;if(G(),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")}var xe=37095705934669439343138083508754565189542113879843219016388785533085940283555n,f=57896044618658097711785492504343953926634992332820282019728792003956564819949n,q=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function g(e){let r=e%f;return r>=0n?r:f+r}function l(e,r){let t=e;for(;r-- >0n;)t*=t,t%=f;return t}function we(e){let t=e*e%f*e%f,n=l(t,2n)*t%f,o=l(n,1n)*e%f,s=l(o,5n)*o%f,i=l(s,10n)*s%f,d=l(i,20n)*i%f,a=l(d,40n)*d%f,c=l(a,80n)*a%f,u=l(c,80n)*a%f,h=l(u,10n)*s%f;return l(h,2n)*e%f}function Ee(e,r){let t=g(r*r*r),n=g(t*t*r),o=we(e*n),s=g(e*t*o),i=g(r*s*s),d=s,a=g(s*q),c=i===e,u=i===g(-e),h=i===g(-e*q);return c&&(s=d),(u||h)&&(s=a),(g(s)&1n)===1n&&(s=g(-s)),!c&&!u?null:s}function Y(e,r){let t=g(e*e),n=g(t-1n),o=g(xe*t+1n),s=Ee(n,o);if(s===null)return !1;let i=(r&128)!==0;return !(s===0n&&i)}function Ae(e){let r=e.toString(16);return r.length===1?`0${r}`:r}function ve(e){let t=`0x${e.reduce((n,o,s)=>`${Ae(s===31?o&-129:o)}${n}`,"")}`;return BigInt(t)}async function J(e){if(e.byteLength!==32)return !1;let r=ve(e);return Y(r,e[31])}function tr(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"&&e[1]>=0&&e[1]<=255&&j(e[0])}function nr(e){if(!(Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"))throw new Error("Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].");if(e[1]<0||e[1]>255)throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${e[1]}.`);C(e[0]);}var ee=32,Q=16,v=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115],z=class extends Error{};async function ze({programAddress:e,seeds:r}){if(await Z(),r.length>Q)throw new Error(`A maximum of ${Q} seeds may be supplied when creating an address`);let t,n=r.reduce((a,c,u)=>{let h=typeof c=="string"?(t||(t=new TextEncoder)).encode(c):c;if(h.byteLength>ee)throw new Error(`The seed at index ${u} exceeds the maximum length of 32 bytes`);return a.push(...h),a},[]),o=U(),s=o.encode(e),i=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...s,...v])),d=new Uint8Array(i);if(await J(d))throw new z("Invalid seeds; point must fall off the Ed25519 curve");return o.decode(d)}async function or({programAddress:e,seeds:r}){let t=255;for(;t>0;)try{return [await ze({programAddress:e,seeds:[...r,new Uint8Array([t])]}),t]}catch(n){if(n instanceof z)t--;else throw n}throw new Error("Unable to find a viable program address bump seed")}async function sr({baseAddress:e,programAddress:r,seed:t}){let{encode:n,decode:o}=U(),s=typeof t=="string"?new TextEncoder().encode(t):t;if(s.byteLength>ee)throw new Error("The seed exceeds the maximum length of 32 bytes");let i=n(r);if(i.length>=v.length&&i.slice(-v.length).every((c,u)=>c===v[u]))throw new Error("programAddress cannot end with the PDA marker");let d=await crypto.subtle.digest("SHA-256",new Uint8Array([...n(e),...s,...i])),a=new Uint8Array(d);return o(a)}async function gr(e){if(await W(),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);return D().decode(new Uint8Array(r))}
6
6
 
7
- exports.address = ge;
8
- exports.assertIsAddress = w;
9
- exports.assertIsProgramDerivedAddress = Ze;
10
- exports.createAddressWithSeed = Je;
11
- exports.getAddressCodec = S;
12
- exports.getAddressComparator = Fe;
13
- exports.getAddressDecoder = B;
14
- exports.getAddressEncoder = ue;
15
- exports.getAddressFromPublicKey = or;
16
- exports.getProgramDerivedAddress = Ye;
17
- exports.isAddress = M;
18
- exports.isProgramDerivedAddress = qe;
7
+ exports.address = pe;
8
+ exports.assertIsAddress = C;
9
+ exports.assertIsProgramDerivedAddress = nr;
10
+ exports.createAddressWithSeed = sr;
11
+ exports.getAddressCodec = U;
12
+ exports.getAddressComparator = Me;
13
+ exports.getAddressDecoder = D;
14
+ exports.getAddressEncoder = be;
15
+ exports.getAddressFromPublicKey = gr;
16
+ exports.getProgramDerivedAddress = or;
17
+ exports.isAddress = j;
18
+ exports.isProgramDerivedAddress = tr;
19
19
 
20
20
  return exports;
21
21
 
@@ -1,18 +1,12 @@
1
- import { Codec, Decoder, Encoder } from '@solana/codecs-core';
2
- export type Base58EncodedAddress<TAddress extends string = string> = TAddress & {
1
+ import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
2
+ export type Address<TAddress extends string = string> = TAddress & {
3
3
  readonly __brand: unique symbol;
4
4
  };
5
- export declare function isAddress(putativeBase58EncodedAddress: string): putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
6
- export declare function assertIsAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
7
- export declare function address<TAddress extends string = string>(putativeBase58EncodedAddress: TAddress): Base58EncodedAddress<TAddress>;
8
- export declare function getAddressEncoder(config?: Readonly<{
9
- description: string;
10
- }>): Encoder<Base58EncodedAddress>;
11
- export declare function getAddressDecoder(config?: Readonly<{
12
- description: string;
13
- }>): Decoder<Base58EncodedAddress>;
14
- export declare function getAddressCodec(config?: Readonly<{
15
- description: string;
16
- }>): Codec<Base58EncodedAddress>;
5
+ export declare function isAddress(putativeAddress: string): putativeAddress is Address<typeof putativeAddress>;
6
+ export declare function assertIsAddress(putativeAddress: string): asserts putativeAddress is Address<typeof putativeAddress>;
7
+ export declare function address<TAddress extends string = string>(putativeAddress: TAddress): Address<TAddress>;
8
+ export declare function getAddressEncoder(): FixedSizeEncoder<Address, 32>;
9
+ export declare function getAddressDecoder(): FixedSizeDecoder<Address, 32>;
10
+ export declare function getAddressCodec(): FixedSizeCodec<Address, Address, 32>;
17
11
  export declare function getAddressComparator(): (x: string, y: string) => number;
18
12
  //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAEnB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,MAAM,OAAO,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,GAAG;IAC/D,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC;CACnC,CAAC;AAeF,wBAAgB,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,eAAe,IAAI,OAAO,CAAC,OAAO,eAAe,CAAC,CAkBrG;AAED,wBAAgB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,eAAe,CAAC,CAuBnH;AAED,wBAAgB,OAAO,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAGtG;AAED,wBAAgB,iBAAiB,IAAI,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,CAIjE;AAED,wBAAgB,iBAAiB,IAAI,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,CAEjE;AAED,wBAAgB,eAAe,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAEtE;AAED,wBAAgB,oBAAoB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CASvE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curve.d.ts","sourceRoot":"","sources":["../../src/curve.ts"],"names":[],"mappings":"AAiBA,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAMxF"}
@@ -1,4 +1,4 @@
1
- export * from './address';
2
- export * from './program-derived-address';
3
- export * from './public-key';
1
+ export * from './address.js';
2
+ export * from './program-derived-address.js';
3
+ export * from './public-key.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC"}
@@ -1,11 +1,11 @@
1
- import { Base58EncodedAddress } from './address';
1
+ import { Address } from './address.js';
2
2
  /**
3
3
  * An address derived from a program address and a set of seeds.
4
4
  * It includes the bump seed used to derive the address and
5
5
  * ensure the address is not on the Ed25519 curve.
6
6
  */
7
7
  export type ProgramDerivedAddress<TAddress extends string = string> = Readonly<[
8
- Base58EncodedAddress<TAddress>,
8
+ Address<TAddress>,
9
9
  ProgramDerivedAddressBump
10
10
  ]>;
11
11
  /**
@@ -23,16 +23,16 @@ export declare function isProgramDerivedAddress<TAddress extends string = string
23
23
  */
24
24
  export declare function assertIsProgramDerivedAddress<TAddress extends string = string>(value: unknown): asserts value is ProgramDerivedAddress<TAddress>;
25
25
  type ProgramDerivedAddressInput = Readonly<{
26
- programAddress: Base58EncodedAddress;
26
+ programAddress: Address;
27
27
  seeds: Seed[];
28
28
  }>;
29
29
  type SeedInput = Readonly<{
30
- baseAddress: Base58EncodedAddress;
31
- programAddress: Base58EncodedAddress;
30
+ baseAddress: Address;
31
+ programAddress: Address;
32
32
  seed: Seed;
33
33
  }>;
34
34
  type Seed = string | Uint8Array;
35
35
  export declare function getProgramDerivedAddress({ programAddress, seeds, }: ProgramDerivedAddressInput): Promise<ProgramDerivedAddress>;
36
- export declare function createAddressWithSeed({ baseAddress, programAddress, seed, }: SeedInput): Promise<Base58EncodedAddress>;
36
+ export declare function createAddressWithSeed({ baseAddress, programAddress, seed }: SeedInput): Promise<Address>;
37
37
  export {};
38
38
  //# sourceMappingURL=program-derived-address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program-derived-address.d.ts","sourceRoot":"","sources":["../../src/program-derived-address.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAA+C,MAAM,WAAW,CAAC;AAGjF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CAC1E;IAAC,OAAO,CAAC,QAAQ,CAAC;IAAE,yBAAyB;CAAC,CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG;IAC7C,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EACpE,KAAK,EAAE,OAAO,GACf,KAAK,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAU1C;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAC1E,KAAK,EAAE,OAAO,GACf,OAAO,CAAC,KAAK,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAclD;AAED,KAAK,0BAA0B,GAAG,QAAQ,CAAC;IACvC,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,IAAI,EAAE,CAAC;CACjB,CAAC,CAAC;AAEH,KAAK,SAAS,GAAG,QAAQ,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC;CACd,CAAC,CAAC;AAEH,KAAK,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;AA0ChC,wBAAsB,wBAAwB,CAAC,EAC3C,cAAc,EACd,KAAK,GACR,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAmB7D;AAED,wBAAsB,qBAAqB,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAyB9G"}
@@ -1,3 +1,3 @@
1
- import { Base58EncodedAddress } from './address';
2
- export declare function getAddressFromPublicKey(publicKey: CryptoKey): Promise<Base58EncodedAddress>;
1
+ import { Address } from './address.js';
2
+ export declare function getAddressFromPublicKey(publicKey: CryptoKey): Promise<Address>;
3
3
  //# sourceMappingURL=public-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-key.d.ts","sourceRoot":"","sources":["../../src/public-key.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAqB,MAAM,WAAW,CAAC;AAEvD,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAQpF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../../../../src/vendor/noble/ed25519.ts"],"names":[],"mappings":"AAgFA,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAanE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/addresses",
3
- "version": "2.0.0-experimental.762ff13",
3
+ "version": "2.0.0-experimental.76cf6b4",
4
4
  "description": "Helpers for generating account addresses",
5
5
  "exports": {
6
6
  "browser": {
@@ -49,14 +49,14 @@
49
49
  "node": ">=17.4"
50
50
  },
51
51
  "dependencies": {
52
- "@solana/assertions": "2.0.0-experimental.762ff13",
53
- "@solana/codecs-core": "2.0.0-experimental.762ff13",
54
- "@solana/codecs-strings": "2.0.0-experimental.762ff13"
52
+ "@solana/assertions": "2.0.0-experimental.76cf6b4",
53
+ "@solana/codecs-core": "2.0.0-experimental.76cf6b4",
54
+ "@solana/codecs-strings": "2.0.0-experimental.76cf6b4"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@solana/eslint-config-solana": "^1.0.2",
58
58
  "@swc/jest": "^0.2.29",
59
- "@types/jest": "^29.5.6",
59
+ "@types/jest": "^29.5.11",
60
60
  "@typescript-eslint/eslint-plugin": "^6.7.0",
61
61
  "@typescript-eslint/parser": "^6.3.0",
62
62
  "agadoo": "^3.0.0",
@@ -67,8 +67,8 @@
67
67
  "jest-environment-jsdom": "^29.7.0",
68
68
  "jest-runner-eslint": "^2.1.2",
69
69
  "jest-runner-prettier": "^1.0.0",
70
- "prettier": "^2.8",
71
- "tsup": "7.2.0",
70
+ "prettier": "^3.1",
71
+ "tsup": "^8.0.1",
72
72
  "typescript": "^5.2.2",
73
73
  "version-from-git": "^1.1.1",
74
74
  "build-scripts": "0.0.0",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "scripts": {
87
87
  "compile:js": "tsup --config build-scripts/tsup.config.library.ts",
88
- "compile:typedefs": "tsc -p ./tsconfig.declarations.json",
88
+ "compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
89
89
  "dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
90
90
  "publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
91
91
  "style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",