@solana/keys 2.0.0-experimental.7a6786e → 2.0.0-experimental.7b06723
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +13 -6
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +13 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +74 -170
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +13 -3
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +13 -6
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +13 -3
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +3 -2
- package/dist/types/base58.d.ts +1 -0
- package/dist/types/base58.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.browser.cjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
-
|
|
7
|
-
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
3
|
+
var umiSerializersEncodings = require('@metaplex-foundation/umi-serializers-encodings');
|
|
8
4
|
|
|
9
5
|
// src/base58.ts
|
|
10
6
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
@@ -16,7 +12,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
16
12
|
) {
|
|
17
13
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
18
14
|
}
|
|
19
|
-
const bytes =
|
|
15
|
+
const bytes = umiSerializersEncodings.base58.serialize(putativeBase58EncodedAddress);
|
|
20
16
|
const numBytes = bytes.byteLength;
|
|
21
17
|
if (numBytes !== 32) {
|
|
22
18
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -27,7 +23,18 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
27
23
|
});
|
|
28
24
|
}
|
|
29
25
|
}
|
|
26
|
+
function getBase58EncodedAddressComparator() {
|
|
27
|
+
return new Intl.Collator("en", {
|
|
28
|
+
caseFirst: "lower",
|
|
29
|
+
ignorePunctuation: false,
|
|
30
|
+
localeMatcher: "best fit",
|
|
31
|
+
numeric: false,
|
|
32
|
+
sensitivity: "variant",
|
|
33
|
+
usage: "sort"
|
|
34
|
+
}).compare;
|
|
35
|
+
}
|
|
30
36
|
|
|
31
37
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
38
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
32
39
|
//# sourceMappingURL=out.js.map
|
|
33
40
|
//# sourceMappingURL=index.browser.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
|
package/dist/index.browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { base58 } from '@metaplex-foundation/umi-serializers-encodings';
|
|
2
2
|
|
|
3
3
|
// src/base58.ts
|
|
4
4
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
@@ -10,7 +10,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
10
10
|
) {
|
|
11
11
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
12
12
|
}
|
|
13
|
-
const bytes =
|
|
13
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
14
14
|
const numBytes = bytes.byteLength;
|
|
15
15
|
if (numBytes !== 32) {
|
|
16
16
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -21,7 +21,17 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
function getBase58EncodedAddressComparator() {
|
|
25
|
+
return new Intl.Collator("en", {
|
|
26
|
+
caseFirst: "lower",
|
|
27
|
+
ignorePunctuation: false,
|
|
28
|
+
localeMatcher: "best fit",
|
|
29
|
+
numeric: false,
|
|
30
|
+
sensitivity: "variant",
|
|
31
|
+
usage: "sort"
|
|
32
|
+
}).compare;
|
|
33
|
+
}
|
|
24
34
|
|
|
25
|
-
export { assertIsBase58EncodedAddress };
|
|
35
|
+
export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
|
|
26
36
|
//# sourceMappingURL=out.js.map
|
|
27
37
|
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
|
|
@@ -2,188 +2,81 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var __create = Object.create;
|
|
6
5
|
var __defProp = Object.defineProperty;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var __esm = (fn, res) => function __init() {
|
|
12
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __publicField = (obj, key, value) => {
|
|
8
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
|
+
return value;
|
|
13
10
|
};
|
|
14
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
15
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
for (let key of __getOwnPropNames(from))
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
-
mod
|
|
32
|
-
));
|
|
33
11
|
|
|
34
|
-
//
|
|
35
|
-
var
|
|
36
|
-
|
|
12
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
13
|
+
var InvalidBaseStringError = class extends Error {
|
|
14
|
+
constructor(value, base, cause) {
|
|
15
|
+
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
16
|
+
super(message);
|
|
17
|
+
__publicField(this, "name", "InvalidBaseStringError");
|
|
18
|
+
this.cause = cause;
|
|
37
19
|
}
|
|
38
|
-
}
|
|
20
|
+
};
|
|
39
21
|
|
|
40
|
-
// ../../node_modules/.pnpm
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
for (var i = 0; i < ALPHABET.length; i++) {
|
|
53
|
-
var x = ALPHABET.charAt(i);
|
|
54
|
-
var xc = x.charCodeAt(0);
|
|
55
|
-
if (BASE_MAP[xc] !== 255) {
|
|
56
|
-
throw new TypeError(x + " is ambiguous");
|
|
57
|
-
}
|
|
58
|
-
BASE_MAP[xc] = i;
|
|
22
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
23
|
+
var baseX = (alphabet) => {
|
|
24
|
+
const base = alphabet.length;
|
|
25
|
+
const baseBigInt = BigInt(base);
|
|
26
|
+
return {
|
|
27
|
+
description: `base${base}`,
|
|
28
|
+
fixedSize: null,
|
|
29
|
+
maxSize: null,
|
|
30
|
+
serialize(value) {
|
|
31
|
+
if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
|
|
32
|
+
throw new InvalidBaseStringError(value, base);
|
|
59
33
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return "";
|
|
75
|
-
}
|
|
76
|
-
var zeroes = 0;
|
|
77
|
-
var length = 0;
|
|
78
|
-
var pbegin = 0;
|
|
79
|
-
var pend = source.length;
|
|
80
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
81
|
-
pbegin++;
|
|
82
|
-
zeroes++;
|
|
83
|
-
}
|
|
84
|
-
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
85
|
-
var b58 = new Uint8Array(size);
|
|
86
|
-
while (pbegin !== pend) {
|
|
87
|
-
var carry = source[pbegin];
|
|
88
|
-
var i2 = 0;
|
|
89
|
-
for (var it1 = size - 1; (carry !== 0 || i2 < length) && it1 !== -1; it1--, i2++) {
|
|
90
|
-
carry += 256 * b58[it1] >>> 0;
|
|
91
|
-
b58[it1] = carry % BASE >>> 0;
|
|
92
|
-
carry = carry / BASE >>> 0;
|
|
93
|
-
}
|
|
94
|
-
if (carry !== 0) {
|
|
95
|
-
throw new Error("Non-zero carry");
|
|
96
|
-
}
|
|
97
|
-
length = i2;
|
|
98
|
-
pbegin++;
|
|
99
|
-
}
|
|
100
|
-
var it2 = size - length;
|
|
101
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
102
|
-
it2++;
|
|
103
|
-
}
|
|
104
|
-
var str = LEADER.repeat(zeroes);
|
|
105
|
-
for (; it2 < size; ++it2) {
|
|
106
|
-
str += ALPHABET.charAt(b58[it2]);
|
|
107
|
-
}
|
|
108
|
-
return str;
|
|
34
|
+
if (value === "")
|
|
35
|
+
return new Uint8Array();
|
|
36
|
+
const chars = [...value];
|
|
37
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
|
|
38
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
39
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
40
|
+
if (trailIndex === chars.length)
|
|
41
|
+
return Uint8Array.from(leadingZeroes);
|
|
42
|
+
const tailChars = chars.slice(trailIndex);
|
|
43
|
+
let base10Number = 0n;
|
|
44
|
+
let baseXPower = 1n;
|
|
45
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
46
|
+
base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
|
|
47
|
+
baseXPower *= baseBigInt;
|
|
109
48
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (source.length === 0) {
|
|
115
|
-
return new Uint8Array();
|
|
116
|
-
}
|
|
117
|
-
var psz = 0;
|
|
118
|
-
var zeroes = 0;
|
|
119
|
-
var length = 0;
|
|
120
|
-
while (source[psz] === LEADER) {
|
|
121
|
-
zeroes++;
|
|
122
|
-
psz++;
|
|
123
|
-
}
|
|
124
|
-
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
125
|
-
var b256 = new Uint8Array(size);
|
|
126
|
-
while (source[psz]) {
|
|
127
|
-
var carry = BASE_MAP[source.charCodeAt(psz)];
|
|
128
|
-
if (carry === 255) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
var i2 = 0;
|
|
132
|
-
for (var it3 = size - 1; (carry !== 0 || i2 < length) && it3 !== -1; it3--, i2++) {
|
|
133
|
-
carry += BASE * b256[it3] >>> 0;
|
|
134
|
-
b256[it3] = carry % 256 >>> 0;
|
|
135
|
-
carry = carry / 256 >>> 0;
|
|
136
|
-
}
|
|
137
|
-
if (carry !== 0) {
|
|
138
|
-
throw new Error("Non-zero carry");
|
|
139
|
-
}
|
|
140
|
-
length = i2;
|
|
141
|
-
psz++;
|
|
142
|
-
}
|
|
143
|
-
var it4 = size - length;
|
|
144
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
145
|
-
it4++;
|
|
146
|
-
}
|
|
147
|
-
var vch = new Uint8Array(zeroes + (size - it4));
|
|
148
|
-
var j2 = zeroes;
|
|
149
|
-
while (it4 !== size) {
|
|
150
|
-
vch[j2++] = b256[it4++];
|
|
151
|
-
}
|
|
152
|
-
return vch;
|
|
49
|
+
const tailBytes = [];
|
|
50
|
+
while (base10Number > 0n) {
|
|
51
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
52
|
+
base10Number /= 256n;
|
|
153
53
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
54
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
55
|
+
},
|
|
56
|
+
deserialize(buffer, offset = 0) {
|
|
57
|
+
if (buffer.length === 0)
|
|
58
|
+
return ["", 0];
|
|
59
|
+
const bytes = buffer.slice(offset);
|
|
60
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
61
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
62
|
+
const leadingZeroes = alphabet[0].repeat(trailIndex);
|
|
63
|
+
if (trailIndex === bytes.length)
|
|
64
|
+
return [leadingZeroes, buffer.length];
|
|
65
|
+
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
66
|
+
const tailChars = [];
|
|
67
|
+
while (base10Number > 0n) {
|
|
68
|
+
tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
|
|
69
|
+
base10Number /= baseBigInt;
|
|
160
70
|
}
|
|
161
|
-
return
|
|
162
|
-
encode,
|
|
163
|
-
decodeUnsafe,
|
|
164
|
-
decode
|
|
165
|
-
};
|
|
71
|
+
return [leadingZeroes + tailChars.join(""), buffer.length];
|
|
166
72
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// ../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js
|
|
172
|
-
var require_bs58 = __commonJS({
|
|
173
|
-
"../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js"(exports, module) {
|
|
174
|
-
init_env_shim();
|
|
175
|
-
var basex = require_src();
|
|
176
|
-
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
177
|
-
module.exports = basex(ALPHABET);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
73
|
+
};
|
|
74
|
+
};
|
|
180
75
|
|
|
181
|
-
//
|
|
182
|
-
|
|
76
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
77
|
+
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
183
78
|
|
|
184
79
|
// src/base58.ts
|
|
185
|
-
init_env_shim();
|
|
186
|
-
var import_bs58 = __toESM(require_bs58(), 1);
|
|
187
80
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
188
81
|
try {
|
|
189
82
|
if (
|
|
@@ -193,7 +86,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
193
86
|
) {
|
|
194
87
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
195
88
|
}
|
|
196
|
-
const bytes =
|
|
89
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
197
90
|
const numBytes = bytes.byteLength;
|
|
198
91
|
if (numBytes !== 32) {
|
|
199
92
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -204,8 +97,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
204
97
|
});
|
|
205
98
|
}
|
|
206
99
|
}
|
|
100
|
+
function getBase58EncodedAddressComparator() {
|
|
101
|
+
return new Intl.Collator("en", {
|
|
102
|
+
caseFirst: "lower",
|
|
103
|
+
ignorePunctuation: false,
|
|
104
|
+
localeMatcher: "best fit",
|
|
105
|
+
numeric: false,
|
|
106
|
+
sensitivity: "variant",
|
|
107
|
+
usage: "sort"
|
|
108
|
+
}).compare;
|
|
109
|
+
}
|
|
207
110
|
|
|
208
111
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
112
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
209
113
|
|
|
210
114
|
return exports;
|
|
211
115
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/errors.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/baseX.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/base58.ts","../src/base58.ts"],"names":["InvalidBaseStringError","Error","constructor","value","base","cause","message","name","baseX","alphabet","length","baseBigInt","BigInt","description","fixedSize","maxSize","serialize","match","RegExp","Uint8Array","chars","trailIndex","findIndex","c","leadingZeroes","Array","fill","from","tailChars","slice","base10Number","baseXPower","i","indexOf","tailBytes","unshift","Number","concat","deserialize","buffer","offset","bytes","n","repeat","reduce","sum","byte","join","base58"],"mappings":"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","sourcesContent":["/** @category Errors */\nexport class InvalidBaseStringError extends Error {\n readonly name: string = 'InvalidBaseStringError';\n\n readonly cause?: Error;\n\n constructor(value: string, base: number, cause?: Error) {\n const message = `Expected a string of base ${base}, got [${value}].`;\n super(message);\n this.cause = cause;\n }\n}\n","import type { Serializer } from '@metaplex-foundation/umi-serializers-core';\nimport { InvalidBaseStringError } from './errors';\n\n/**\n * A string serializer that uses a custom alphabet.\n * This can be used to create serializers for base58, base64, etc.\n * @category Serializers\n */\nexport const baseX = (alphabet: string): Serializer<string> => {\n const base = alphabet.length;\n const baseBigInt = BigInt(base);\n return {\n description: `base${base}`,\n fixedSize: null,\n maxSize: null,\n serialize(value: string): Uint8Array {\n // Check if the value is valid.\n if (!value.match(new RegExp(`^[${alphabet}]*$`))) {\n throw new InvalidBaseStringError(value, base);\n }\n if (value === '') return new Uint8Array();\n\n // Handle leading zeroes.\n const chars = [...value];\n let trailIndex = chars.findIndex((c) => c !== alphabet[0]);\n trailIndex = trailIndex === -1 ? chars.length : trailIndex;\n const leadingZeroes = Array(trailIndex).fill(0);\n if (trailIndex === chars.length) return Uint8Array.from(leadingZeroes);\n\n // From baseX to base10.\n const tailChars = chars.slice(trailIndex);\n let base10Number = 0n;\n let baseXPower = 1n;\n for (let i = tailChars.length - 1; i >= 0; i -= 1) {\n base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));\n baseXPower *= baseBigInt;\n }\n\n // From base10 to bytes.\n const tailBytes = [];\n while (base10Number > 0n) {\n tailBytes.unshift(Number(base10Number % 256n));\n base10Number /= 256n;\n }\n return Uint8Array.from(leadingZeroes.concat(tailBytes));\n },\n deserialize(buffer, offset = 0): [string, number] {\n if (buffer.length === 0) return ['', 0];\n\n // Handle leading zeroes.\n const bytes = buffer.slice(offset);\n let trailIndex = bytes.findIndex((n) => n !== 0);\n trailIndex = trailIndex === -1 ? bytes.length : trailIndex;\n const leadingZeroes = alphabet[0].repeat(trailIndex);\n if (trailIndex === bytes.length) return [leadingZeroes, buffer.length];\n\n // From bytes to base10.\n let base10Number = bytes\n .slice(trailIndex)\n .reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);\n\n // From base10 to baseX.\n const tailChars = [];\n while (base10Number > 0n) {\n tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);\n base10Number /= baseBigInt;\n }\n\n return [leadingZeroes + tailChars.join(''), buffer.length];\n },\n };\n};\n","import type { Serializer } from '@metaplex-foundation/umi-serializers-core';\nimport { baseX } from './baseX';\n\n/**\n * A string serializer that uses base58 encoding.\n * @category Serializers\n */\nexport const base58: Serializer<string> = baseX(\n '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n);\n","import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
|
package/dist/index.native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { base58 } from '@metaplex-foundation/umi-serializers-encodings';
|
|
2
2
|
|
|
3
3
|
// src/base58.ts
|
|
4
4
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
@@ -10,7 +10,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
10
10
|
) {
|
|
11
11
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
12
12
|
}
|
|
13
|
-
const bytes =
|
|
13
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
14
14
|
const numBytes = bytes.byteLength;
|
|
15
15
|
if (numBytes !== 32) {
|
|
16
16
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -21,7 +21,17 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
function getBase58EncodedAddressComparator() {
|
|
25
|
+
return new Intl.Collator("en", {
|
|
26
|
+
caseFirst: "lower",
|
|
27
|
+
ignorePunctuation: false,
|
|
28
|
+
localeMatcher: "best fit",
|
|
29
|
+
numeric: false,
|
|
30
|
+
sensitivity: "variant",
|
|
31
|
+
usage: "sort"
|
|
32
|
+
}).compare;
|
|
33
|
+
}
|
|
24
34
|
|
|
25
|
-
export { assertIsBase58EncodedAddress };
|
|
35
|
+
export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
|
|
26
36
|
//# sourceMappingURL=out.js.map
|
|
27
37
|
//# sourceMappingURL=index.native.js.map
|
package/dist/index.native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
|
package/dist/index.node.cjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
-
|
|
7
|
-
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
3
|
+
var umiSerializersEncodings = require('@metaplex-foundation/umi-serializers-encodings');
|
|
8
4
|
|
|
9
5
|
// src/base58.ts
|
|
10
6
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
@@ -16,7 +12,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
16
12
|
) {
|
|
17
13
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
18
14
|
}
|
|
19
|
-
const bytes =
|
|
15
|
+
const bytes = umiSerializersEncodings.base58.serialize(putativeBase58EncodedAddress);
|
|
20
16
|
const numBytes = bytes.byteLength;
|
|
21
17
|
if (numBytes !== 32) {
|
|
22
18
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -27,7 +23,18 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
27
23
|
});
|
|
28
24
|
}
|
|
29
25
|
}
|
|
26
|
+
function getBase58EncodedAddressComparator() {
|
|
27
|
+
return new Intl.Collator("en", {
|
|
28
|
+
caseFirst: "lower",
|
|
29
|
+
ignorePunctuation: false,
|
|
30
|
+
localeMatcher: "best fit",
|
|
31
|
+
numeric: false,
|
|
32
|
+
sensitivity: "variant",
|
|
33
|
+
usage: "sort"
|
|
34
|
+
}).compare;
|
|
35
|
+
}
|
|
30
36
|
|
|
31
37
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
38
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
32
39
|
//# sourceMappingURL=out.js.map
|
|
33
40
|
//# sourceMappingURL=index.node.cjs.map
|
package/dist/index.node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
|
package/dist/index.node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { base58 } from '@metaplex-foundation/umi-serializers-encodings';
|
|
2
2
|
|
|
3
3
|
// src/base58.ts
|
|
4
4
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
@@ -10,7 +10,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
10
10
|
) {
|
|
11
11
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
12
12
|
}
|
|
13
|
-
const bytes =
|
|
13
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
14
14
|
const numBytes = bytes.byteLength;
|
|
15
15
|
if (numBytes !== 32) {
|
|
16
16
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -21,7 +21,17 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
function getBase58EncodedAddressComparator() {
|
|
25
|
+
return new Intl.Collator("en", {
|
|
26
|
+
caseFirst: "lower",
|
|
27
|
+
ignorePunctuation: false,
|
|
28
|
+
localeMatcher: "best fit",
|
|
29
|
+
numeric: false,
|
|
30
|
+
sensitivity: "variant",
|
|
31
|
+
usage: "sort"
|
|
32
|
+
}).compare;
|
|
33
|
+
}
|
|
24
34
|
|
|
25
|
-
export { assertIsBase58EncodedAddress };
|
|
35
|
+
export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
|
|
26
36
|
//# sourceMappingURL=out.js.map
|
|
27
37
|
//# sourceMappingURL=index.node.js.map
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
|
|
@@ -2,9 +2,10 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var h=Object.defineProperty;var b=(e,r,t)=>r in e?h(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var x=(e,r,t)=>(b(e,typeof r!="symbol"?r+"":r,t),t);var m=class extends Error{constructor(t,s,i){let n=`Expected a string of base ${s}, got [${t}].`;super(n);x(this,"name","InvalidBaseStringError");this.cause=i;}};var p=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(s){if(!s.match(new RegExp(`^[${e}]*$`)))throw new m(s,r);if(s==="")return new Uint8Array;let i=[...s],n=i.findIndex(c=>c!==e[0]);n=n===-1?i.length:n;let o=Array(n).fill(0);if(n===i.length)return Uint8Array.from(o);let l=i.slice(n),a=0n,g=1n;for(let c=l.length-1;c>=0;c-=1)a+=g*BigInt(e.indexOf(l[c])),g*=t;let d=[];for(;a>0n;)d.unshift(Number(a%256n)),a/=256n;return Uint8Array.from(o.concat(d))},deserialize(s,i=0){if(s.length===0)return ["",0];let n=s.slice(i),o=n.findIndex(d=>d!==0);o=o===-1?n.length:o;let l=e[0].repeat(o);if(o===n.length)return [l,s.length];let a=n.slice(o).reduce((d,c)=>d*256n+BigInt(c),0n),g=[];for(;a>0n;)g.unshift(e[Number(a%t)]),a/=t;return [l+g.join(""),s.length]}}};var u=p("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function D(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=u.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 P(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}
|
|
6
6
|
|
|
7
|
-
exports.assertIsBase58EncodedAddress =
|
|
7
|
+
exports.assertIsBase58EncodedAddress = D;
|
|
8
|
+
exports.getBase58EncodedAddressComparator = P;
|
|
8
9
|
|
|
9
10
|
return exports;
|
|
10
11
|
|
package/dist/types/base58.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export type Base58EncodedAddress<TAddress extends string = string> = TAddress &
|
|
|
2
2
|
readonly __base58EncodedAddress: unique symbol;
|
|
3
3
|
};
|
|
4
4
|
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
|
|
5
|
+
export declare function getBase58EncodedAddressComparator(): (x: string, y: string) => number;
|
|
5
6
|
//# sourceMappingURL=base58.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/base58.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,GAAG;IAC5E,QAAQ,CAAC,sBAAsB,EAAE,OAAO,MAAM,CAAC;CAClD,CAAC;AAEF,wBAAgB,4BAA4B,CACxC,4BAA4B,EAAE,MAAM,GACrC,OAAO,CAAC,4BAA4B,IAAI,oBAAoB,CAAC,OAAO,4BAA4B,CAAC,CAsBnG"}
|
|
1
|
+
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/base58.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,GAAG;IAC5E,QAAQ,CAAC,sBAAsB,EAAE,OAAO,MAAM,CAAC;CAClD,CAAC;AAEF,wBAAgB,4BAA4B,CACxC,4BAA4B,EAAE,MAAM,GACrC,OAAO,CAAC,4BAA4B,IAAI,oBAAoB,CAAC,OAAO,4BAA4B,CAAC,CAsBnG;AAED,wBAAgB,iCAAiC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CASpF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/keys",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.7b06723",
|
|
4
4
|
"description": "Helpers for generating and transforming key material",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -45,11 +45,14 @@
|
|
|
45
45
|
"supports bigint and not dead",
|
|
46
46
|
"maintained node versions"
|
|
47
47
|
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@metaplex-foundation/umi-serializers-encodings": "^0.8.2"
|
|
50
|
+
},
|
|
48
51
|
"devDependencies": {
|
|
49
52
|
"@solana/eslint-config-solana": "^1.0.1",
|
|
50
53
|
"@swc/core": "^1.3.18",
|
|
51
|
-
"@swc/jest": "^0.2.
|
|
52
|
-
"@types/jest": "^29.5.
|
|
54
|
+
"@swc/jest": "^0.2.26",
|
|
55
|
+
"@types/jest": "^29.5.1",
|
|
53
56
|
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
54
57
|
"@typescript-eslint/parser": "^5.57.1",
|
|
55
58
|
"agadoo": "^3.0.0",
|
|
@@ -59,13 +62,13 @@
|
|
|
59
62
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
60
63
|
"jest": "^29.5.0",
|
|
61
64
|
"jest-environment-jsdom": "^29.5.0",
|
|
62
|
-
"jest-runner-eslint": "^2.
|
|
65
|
+
"jest-runner-eslint": "^2.1.0",
|
|
63
66
|
"jest-runner-prettier": "^1.0.0",
|
|
64
67
|
"postcss": "^8.4.12",
|
|
65
68
|
"prettier": "^2.8.8",
|
|
66
69
|
"ts-node": "^10.9.1",
|
|
67
70
|
"tsup": "6.7.0",
|
|
68
|
-
"typescript": "^5.0.
|
|
71
|
+
"typescript": "^5.0.4",
|
|
69
72
|
"version-from-git": "^1.1.1",
|
|
70
73
|
"build-scripts": "0.0.0",
|
|
71
74
|
"test-config": "0.0.0",
|
|
@@ -79,9 +82,6 @@
|
|
|
79
82
|
}
|
|
80
83
|
]
|
|
81
84
|
},
|
|
82
|
-
"dependencies": {
|
|
83
|
-
"bs58": "^5.0.0"
|
|
84
|
-
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"compile:js": "tsup --config build-scripts/tsup.config.library.ts",
|
|
87
87
|
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|