Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/addresses

Package Overview
Dependencies
Maintainers
12
Versions
1295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/addresses - npm Package Compare versions

Comparing version 2.0.0-experimental.53a2f8c to 2.0.0-experimental.5432cbe

23

dist/index.browser.js

@@ -6,2 +6,17 @@ import { base58, string } from '@metaplex-foundation/umi-serializers';

var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
function isBase58EncodedAddress(putativeBase58EncodedAddress) {
if (
// Lowest address (32 bytes of zeroes)
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
putativeBase58EncodedAddress.length > 44
) {
return false;
}
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;
if (numBytes !== 32) {
return false;
}
return true;
}
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {

@@ -27,2 +42,6 @@ try {

}
function address(putativeBase58EncodedAddress) {
assertIsBase58EncodedAddress(putativeBase58EncodedAddress);
return putativeBase58EncodedAddress;
}
function getBase58EncodedAddressCodec(config) {

@@ -243,2 +262,4 @@ return string({

export { assertIsBase58EncodedAddress, createAddressWithSeed, getAddressFromPublicKey, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getProgramDerivedAddress };
export { address, assertIsBase58EncodedAddress, createAddressWithSeed, getAddressFromPublicKey, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getProgramDerivedAddress, isBase58EncodedAddress };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

@@ -270,2 +270,17 @@ this.globalThis = this.globalThis || {};

// src/base58.ts
function isBase58EncodedAddress(putativeBase58EncodedAddress) {
if (
// Lowest address (32 bytes of zeroes)
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
putativeBase58EncodedAddress.length > 44
) {
return false;
}
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;
if (numBytes !== 32) {
return false;
}
return true;
}
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {

@@ -291,2 +306,6 @@ try {

}
function address(putativeBase58EncodedAddress) {
assertIsBase58EncodedAddress(putativeBase58EncodedAddress);
return putativeBase58EncodedAddress;
}
function getBase58EncodedAddressCodec(config) {

@@ -530,2 +549,3 @@ return string({

exports.address = address;
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;

@@ -537,2 +557,3 @@ exports.createAddressWithSeed = createAddressWithSeed;

exports.getProgramDerivedAddress = getProgramDerivedAddress;
exports.isBase58EncodedAddress = isBase58EncodedAddress;

@@ -539,0 +560,0 @@ return exports;

@@ -6,2 +6,17 @@ import { base58, string } from '@metaplex-foundation/umi-serializers';

var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
function isBase58EncodedAddress(putativeBase58EncodedAddress) {
if (
// Lowest address (32 bytes of zeroes)
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
putativeBase58EncodedAddress.length > 44
) {
return false;
}
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;
if (numBytes !== 32) {
return false;
}
return true;
}
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {

@@ -27,2 +42,6 @@ try {

}
function address(putativeBase58EncodedAddress) {
assertIsBase58EncodedAddress(putativeBase58EncodedAddress);
return putativeBase58EncodedAddress;
}
function getBase58EncodedAddressCodec(config) {

@@ -243,2 +262,4 @@ return string({

export { assertIsBase58EncodedAddress, createAddressWithSeed, getAddressFromPublicKey, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getProgramDerivedAddress };
export { address, assertIsBase58EncodedAddress, createAddressWithSeed, getAddressFromPublicKey, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getProgramDerivedAddress, isBase58EncodedAddress };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -6,2 +6,17 @@ import { base58, string } from '@metaplex-foundation/umi-serializers';

var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
function isBase58EncodedAddress(putativeBase58EncodedAddress) {
if (
// Lowest address (32 bytes of zeroes)
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
putativeBase58EncodedAddress.length > 44
) {
return false;
}
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;
if (numBytes !== 32) {
return false;
}
return true;
}
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {

@@ -27,2 +42,6 @@ try {

}
function address(putativeBase58EncodedAddress) {
assertIsBase58EncodedAddress(putativeBase58EncodedAddress);
return putativeBase58EncodedAddress;
}
function getBase58EncodedAddressCodec(config) {

@@ -243,2 +262,4 @@ return string({

export { assertIsBase58EncodedAddress, createAddressWithSeed, getAddressFromPublicKey, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getProgramDerivedAddress };
export { address, assertIsBase58EncodedAddress, createAddressWithSeed, getAddressFromPublicKey, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getProgramDerivedAddress, isBase58EncodedAddress };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

16

dist/index.production.min.js

@@ -5,10 +5,12 @@ this.globalThis = this.globalThis || {};

var j=Object.defineProperty;var H=(e,r,t)=>r in e?j(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var x=(e,r,t)=>(H(e,typeof r!="symbol"?r+"":r,t),t);var I=e=>{let r=e.reduce((i,o)=>i+o.length,0),t=new Uint8Array(r),n=0;return e.forEach(i=>{t.set(i,n),n+=i.length;}),t},_=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},E=(e,r)=>_(e.slice(0,r),r);var h=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);x(this,"name","DeserializingEmptyBufferError");}},y=class extends Error{constructor(t,n,i){super(`Serializer [${t}] expected ${n} bytes, got ${i}.`);x(this,"name","NotEnoughBytesError");}};function C(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:n=>E(e.serialize(n),r),deserialize:(n,i=0)=>{if(n=n.slice(i,i+r),n.length<r)throw new y("fixSerializer",r,n.length);e.fixedSize!==null&&(n=E(n,e.fixedSize));let[o]=e.deserialize(n,0);return [o,i+r]}}}var w=class extends Error{constructor(t,n,i){let o=`Expected a string of base ${n}, got [${t}].`;super(o);x(this,"name","InvalidBaseStringError");this.cause=i;}};var $=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new w(n,r);if(n==="")return new Uint8Array;let i=[...n],o=i.findIndex(p=>p!==e[0]);o=o===-1?i.length:o;let s=Array(o).fill(0);if(o===i.length)return Uint8Array.from(s);let l=i.slice(o),c=0n,d=1n;for(let p=l.length-1;p>=0;p-=1)c+=d*BigInt(e.indexOf(l[p])),d*=t;let f=[];for(;c>0n;)f.unshift(Number(c%256n)),c/=256n;return Uint8Array.from(s.concat(f))},deserialize(n,i=0){if(n.length===0)return ["",0];let o=n.slice(i),s=o.findIndex(f=>f!==0);s=s===-1?o.length:s;let l=e[0].repeat(s);if(s===o.length)return [l,n.length];let c=o.slice(s).reduce((f,p)=>f*256n+BigInt(p),0n),d=[];for(;c>0n;)d.unshift(e[Number(c%t)]),c/=t;return [l+d.join(""),n.length]}}};var z=$("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var U=e=>e.replace(/\u0000/g,"");var D={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,r=0){let t=new TextDecoder().decode(e.slice(r));return [U(t),e.length]}};var S;(function(e){e.Little="le",e.Big="be";})(S||(S={}));var A=class extends RangeError{constructor(t,n,i,o){super(`Serializer [${t}] expected number to be between ${n} and ${i}, got ${o}.`);x(this,"name","NumberOutOfRangeError");}};function R(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===S.Little,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,maxSize:e.size,serialize(n){e.range&&Z(e.name,e.range[0],e.range[1],n);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),n,r),new Uint8Array(i)},deserialize(n,i=0){let o=n.slice(i,i+e.size);q("i8",o,e.size);let s=W(o);return [e.get(s,r),i+e.size]}}}var G=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),W=e=>new DataView(G(e)),Z=(e,r,t,n)=>{if(n<r||n>t)throw new A(e,r,t,n)},q=(e,r,t)=>{if(r.length===0)throw new h(e);if(r.length<t)throw new y(e,t,r.length)};var N=(e={})=>R({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,t,n)=>r.setUint32(0,Number(t),n),get:(r,t)=>r.getUint32(0,t),options:e});function P(e){return typeof e=="object"?e.description:`${e}`}function T(e={}){let r=e.size??N(),t=e.encoding??D,n=e.description??`string(${t.description}; ${P(r)})`;return r==="variable"?{...t,description:n}:typeof r=="number"?C(t,r,n):{description:n,fixedSize:null,maxSize:null,serialize:i=>{let o=t.serialize(i),s=r.serialize(o.length);return I([s,o])},deserialize:(i,o=0)=>{if(i.slice(o).length===0)throw new h("string");let[s,l]=r.deserialize(i,o),c=Number(s);o=l;let d=i.slice(o,o+c);if(d.length<c)throw new y("string",c,d.length);let[f,p]=t.deserialize(d);return o+=p,[f,o]}}}function xr(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=z.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 b(e){return T({description:e?.description??"",encoding:z,size:32})}function hr(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function O(){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 L(){if(O(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!="function")throw new Error("No digest implementation could be found")}async function k(){if(O(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}var Y=37095705934669439343138083508754565189542113879843219016388785533085940283555n,u=57896044618658097711785492504343953926634992332820282019728792003956564819949n,K=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function m(e){let r=e%u;return r>=0n?r:u+r}function g(e,r){let t=e;for(;r-- >0n;)t*=t,t%=u;return t}function J(e){let t=e*e%u*e%u,n=g(t,2n)*t%u,i=g(n,1n)*e%u,o=g(i,5n)*i%u,s=g(o,10n)*o%u,l=g(s,20n)*s%u,c=g(l,40n)*l%u,d=g(c,80n)*c%u,f=g(d,80n)*c%u,p=g(f,10n)*o%u;return g(p,2n)*e%u}function Q(e,r){let t=m(r*r*r),n=m(t*t*r),i=J(e*n),o=m(e*t*i),s=m(r*o*o),l=o,c=m(o*K),d=s===e,f=s===m(-e),p=s===m(-e*K);return d&&(o=l),(f||p)&&(o=c),(m(o)&1n)===1n&&(o=m(-o)),!d&&!f?null:o}function V(e,r){let t=m(e*e),n=m(t-1n),i=m(Y*t+1n),o=Q(n,i);if(o===null)return !1;let s=(r&128)!==0;return !(o===0n&&s)}function ee(e){let r=e.toString(16);return r.length===1?`0${r}`:r}function re(e){let t=`0x${e.reduce((n,i,o)=>`${ee(o===31?i&-129:i)}${n}`,"")}`;return BigInt(t)}async function F(e){if(e.byteLength!==32)return !1;let r=re(e);return V(r,e[31])}var M=32,X=16,B=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115],v=class extends Error{};async function te({programAddress:e,seeds:r}){if(await L(),r.length>X)throw new Error(`A maximum of ${X} seeds may be supplied when creating an address`);let t,n=r.reduce((c,d,f)=>{let p=typeof d=="string"?(t||(t=new TextEncoder)).encode(d):d;if(p.byteLength>M)throw new Error(`The seed at index ${f} exceeds the maximum length of 32 bytes`);return c.push(...p),c},[]),i=b(),o=i.serialize(e),s=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...o,...B])),l=new Uint8Array(s);if(await F(l))throw new v("Invalid seeds; point must fall off the Ed25519 curve");return i.deserialize(l)[0]}async function _r({programAddress:e,seeds:r}){let t=255;for(;t>0;)try{return {bumpSeed:t,pda:await te({programAddress:e,seeds:[...r,new Uint8Array([t])]})}}catch(n){if(n instanceof v)t--;else throw n}throw new Error("Unable to find a viable program address bump seed")}async function $r({baseAddress:e,programAddress:r,seed:t}){let{serialize:n,deserialize:i}=b(),o=typeof t=="string"?new TextEncoder().encode(t):t;if(o.byteLength>M)throw new Error("The seed exceeds the maximum length of 32 bytes");let s=n(r);if(s.length>=B.length&&s.slice(-B.length).every((d,f)=>d===B[f]))throw new Error("programAddress cannot end with the PDA marker");let l=await crypto.subtle.digest("SHA-256",new Uint8Array([...n(e),...o,...s])),c=new Uint8Array(l);return i(c)[0]}async function kr(e){if(await k(),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().deserialize(new Uint8Array(r));return t}
var j=Object.defineProperty;var H=(e,r,t)=>r in e?j(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var x=(e,r,t)=>(H(e,typeof r!="symbol"?r+"":r,t),t);var I=e=>{let r=e.reduce((i,o)=>i+o.length,0),t=new Uint8Array(r),n=0;return e.forEach(i=>{t.set(i,n),n+=i.length;}),t},_=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},w=(e,r)=>_(e.slice(0,r),r);var h=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);x(this,"name","DeserializingEmptyBufferError");}},y=class extends Error{constructor(t,n,i){super(`Serializer [${t}] expected ${n} bytes, got ${i}.`);x(this,"name","NotEnoughBytesError");}};function T(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:n=>w(e.serialize(n),r),deserialize:(n,i=0)=>{if(n=n.slice(i,i+r),n.length<r)throw new y("fixSerializer",r,n.length);e.fixedSize!==null&&(n=w(n,e.fixedSize));let[o]=e.deserialize(n,0);return [o,i+r]}}}var A=class extends Error{constructor(t,n,i){let o=`Expected a string of base ${n}, got [${t}].`;super(o);x(this,"name","InvalidBaseStringError");this.cause=i;}};var $=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new A(n,r);if(n==="")return new Uint8Array;let i=[...n],o=i.findIndex(u=>u!==e[0]);o=o===-1?i.length:o;let s=Array(o).fill(0);if(o===i.length)return Uint8Array.from(s);let l=i.slice(o),c=0n,d=1n;for(let u=l.length-1;u>=0;u-=1)c+=d*BigInt(e.indexOf(l[u])),d*=t;let f=[];for(;c>0n;)f.unshift(Number(c%256n)),c/=256n;return Uint8Array.from(s.concat(f))},deserialize(n,i=0){if(n.length===0)return ["",0];let o=n.slice(i),s=o.findIndex(f=>f!==0);s=s===-1?o.length:s;let l=e[0].repeat(s);if(s===o.length)return [l,n.length];let c=o.slice(s).reduce((f,u)=>f*256n+BigInt(u),0n),d=[];for(;c>0n;)d.unshift(e[Number(c%t)]),c/=t;return [l+d.join(""),n.length]}}};var b=$("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var U=e=>e.replace(/\u0000/g,"");var C={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,r=0){let t=new TextDecoder().decode(e.slice(r));return [U(t),e.length]}};var z;(function(e){e.Little="le",e.Big="be";})(z||(z={}));var S=class extends RangeError{constructor(t,n,i,o){super(`Serializer [${t}] expected number to be between ${n} and ${i}, got ${o}.`);x(this,"name","NumberOutOfRangeError");}};function R(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===z.Little,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,maxSize:e.size,serialize(n){e.range&&Z(e.name,e.range[0],e.range[1],n);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),n,r),new Uint8Array(i)},deserialize(n,i=0){let o=n.slice(i,i+e.size);q("i8",o,e.size);let s=W(o);return [e.get(s,r),i+e.size]}}}var G=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),W=e=>new DataView(G(e)),Z=(e,r,t,n)=>{if(n<r||n>t)throw new S(e,r,t,n)},q=(e,r,t)=>{if(r.length===0)throw new h(e);if(r.length<t)throw new y(e,t,r.length)};var D=(e={})=>R({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,t,n)=>r.setUint32(0,Number(t),n),get:(r,t)=>r.getUint32(0,t),options:e});function P(e){return typeof e=="object"?e.description:`${e}`}function N(e={}){let r=e.size??D(),t=e.encoding??C,n=e.description??`string(${t.description}; ${P(r)})`;return r==="variable"?{...t,description:n}:typeof r=="number"?T(t,r,n):{description:n,fixedSize:null,maxSize:null,serialize:i=>{let o=t.serialize(i),s=r.serialize(o.length);return I([s,o])},deserialize:(i,o=0)=>{if(i.slice(o).length===0)throw new h("string");let[s,l]=r.deserialize(i,o),c=Number(s);o=l;let d=i.slice(o,o+c);if(d.length<c)throw new y("string",c,d.length);let[f,u]=t.deserialize(d);return o+=u,[f,o]}}}function hr(e){return !(e.length<32||e.length>44||b.serialize(e).byteLength!==32)}function Y(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=b.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 br(e){return Y(e),e}function E(e){return N({description:e?.description??"",encoding:b,size:32})}function Er(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function L(){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 O(){if(L(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!="function")throw new Error("No digest implementation could be found")}async function k(){if(L(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}var J=37095705934669439343138083508754565189542113879843219016388785533085940283555n,p=57896044618658097711785492504343953926634992332820282019728792003956564819949n,K=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function m(e){let r=e%p;return r>=0n?r:p+r}function g(e,r){let t=e;for(;r-- >0n;)t*=t,t%=p;return t}function Q(e){let t=e*e%p*e%p,n=g(t,2n)*t%p,i=g(n,1n)*e%p,o=g(i,5n)*i%p,s=g(o,10n)*o%p,l=g(s,20n)*s%p,c=g(l,40n)*l%p,d=g(c,80n)*c%p,f=g(d,80n)*c%p,u=g(f,10n)*o%p;return g(u,2n)*e%p}function ee(e,r){let t=m(r*r*r),n=m(t*t*r),i=Q(e*n),o=m(e*t*i),s=m(r*o*o),l=o,c=m(o*K),d=s===e,f=s===m(-e),u=s===m(-e*K);return d&&(o=l),(f||u)&&(o=c),(m(o)&1n)===1n&&(o=m(-o)),!d&&!f?null:o}function V(e,r){let t=m(e*e),n=m(t-1n),i=m(J*t+1n),o=ee(n,i);if(o===null)return !1;let s=(r&128)!==0;return !(o===0n&&s)}function re(e){let r=e.toString(16);return r.length===1?`0${r}`:r}function te(e){let t=`0x${e.reduce((n,i,o)=>`${re(o===31?i&-129:i)}${n}`,"")}`;return BigInt(t)}async function F(e){if(e.byteLength!==32)return !1;let r=te(e);return V(r,e[31])}var M=32,X=16,B=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115],v=class extends Error{};async function ne({programAddress:e,seeds:r}){if(await O(),r.length>X)throw new Error(`A maximum of ${X} seeds may be supplied when creating an address`);let t,n=r.reduce((c,d,f)=>{let u=typeof d=="string"?(t||(t=new TextEncoder)).encode(d):d;if(u.byteLength>M)throw new Error(`The seed at index ${f} exceeds the maximum length of 32 bytes`);return c.push(...u),c},[]),i=E(),o=i.serialize(e),s=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...o,...B])),l=new Uint8Array(s);if(await F(l))throw new v("Invalid seeds; point must fall off the Ed25519 curve");return i.deserialize(l)[0]}async function Ur({programAddress:e,seeds:r}){let t=255;for(;t>0;)try{return {bumpSeed:t,pda:await ne({programAddress:e,seeds:[...r,new Uint8Array([t])]})}}catch(n){if(n instanceof v)t--;else throw n}throw new Error("Unable to find a viable program address bump seed")}async function Rr({baseAddress:e,programAddress:r,seed:t}){let{serialize:n,deserialize:i}=E(),o=typeof t=="string"?new TextEncoder().encode(t):t;if(o.byteLength>M)throw new Error("The seed exceeds the maximum length of 32 bytes");let s=n(r);if(s.length>=B.length&&s.slice(-B.length).every((d,f)=>d===B[f]))throw new Error("programAddress cannot end with the PDA marker");let l=await crypto.subtle.digest("SHA-256",new Uint8Array([...n(e),...o,...s])),c=new Uint8Array(l);return i(c)[0]}async function Vr(e){if(await k(),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]=E().deserialize(new Uint8Array(r));return t}
exports.assertIsBase58EncodedAddress = xr;
exports.createAddressWithSeed = $r;
exports.getAddressFromPublicKey = kr;
exports.getBase58EncodedAddressCodec = b;
exports.getBase58EncodedAddressComparator = hr;
exports.getProgramDerivedAddress = _r;
exports.address = br;
exports.assertIsBase58EncodedAddress = Y;
exports.createAddressWithSeed = Rr;
exports.getAddressFromPublicKey = Vr;
exports.getBase58EncodedAddressCodec = E;
exports.getBase58EncodedAddressComparator = Er;
exports.getProgramDerivedAddress = Ur;
exports.isBase58EncodedAddress = hr;

@@ -15,0 +17,0 @@ return exports;

@@ -5,3 +5,5 @@ import { Serializer } from '@metaplex-foundation/umi-serializers';

};
export declare function isBase58EncodedAddress(putativeBase58EncodedAddress: string): putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
export declare function address<TAddress extends string = string>(putativeBase58EncodedAddress: TAddress): Base58EncodedAddress<TAddress>;
export declare function getBase58EncodedAddressCodec(config?: Readonly<{

@@ -8,0 +10,0 @@ description: string;

{
"name": "@solana/addresses",
"version": "2.0.0-experimental.53a2f8c",
"version": "2.0.0-experimental.5432cbe",
"description": "Helpers for generating account addresses",

@@ -53,3 +53,3 @@ "exports": {

"@metaplex-foundation/umi-serializers": "^0.8.9",
"@solana/assertions": "2.0.0-experimental.53a2f8c"
"@solana/assertions": "2.0.0-experimental.5432cbe"
},

@@ -59,4 +59,4 @@ "devDependencies": {

"@swc/jest": "^0.2.28",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@types/jest": "^29.5.5",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.3.0",

@@ -67,3 +67,3 @@ "agadoo": "^3.0.0",

"eslint-plugin-sort-keys-fix": "^1.1.2",
"jest": "^29.6.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.6.4",

@@ -74,3 +74,3 @@ "jest-runner-eslint": "^2.1.0",

"tsup": "7.2.0",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"version-from-git": "^1.1.1",

@@ -77,0 +77,0 @@ "build-scripts": "0.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc