@solana/keys 2.0.0-experimental.ca22964 → 2.0.0-experimental.ca5fcbd
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/README.md +52 -0
- package/dist/index.browser.cjs +23 -7
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +22 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +264 -162
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +22 -4
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +23 -7
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +22 -4
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +4 -2
- package/dist/types/base58.d.ts +7 -2
- package/package.json +12 -13
- package/dist/types/base58.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[![npm][npm-image]][npm-url]
|
|
2
|
+
[![npm-downloads][npm-downloads-image]][npm-url]
|
|
3
|
+
[![semantic-release][semantic-release-image]][semantic-release-url]
|
|
4
|
+
<br />
|
|
5
|
+
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
|
|
6
|
+
|
|
7
|
+
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
|
|
8
|
+
[code-style-prettier-url]: https://github.com/prettier/prettier
|
|
9
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/keys/experimental.svg?style=flat
|
|
10
|
+
[npm-image]: https://img.shields.io/npm/v/@solana/keys/experimental.svg?style=flat
|
|
11
|
+
[npm-url]: https://www.npmjs.com/package/@solana/keys/v/experimental
|
|
12
|
+
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
|
13
|
+
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
|
14
|
+
|
|
15
|
+
# @solana/keys
|
|
16
|
+
|
|
17
|
+
This package contains utilities for validating, generating, and manipulating addresses and key material. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@experimental`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).
|
|
18
|
+
|
|
19
|
+
## Types
|
|
20
|
+
|
|
21
|
+
### `Base58EncodedAddress`
|
|
22
|
+
|
|
23
|
+
This type represents a string that validates as a Solana address or public key. Functions that require well-formed addresses should specify their inputs in terms of this type.
|
|
24
|
+
|
|
25
|
+
Whenever you need to validate an arbitrary string as a base58-encoded address, use the `assertIsBase58EncodedAddress()` function in this package.
|
|
26
|
+
|
|
27
|
+
## Functions
|
|
28
|
+
|
|
29
|
+
### `assertIsBase58EncodedAddress()`
|
|
30
|
+
|
|
31
|
+
Client applications primarily deal with addresses and public keys in the form of base58-encoded strings. Addresses and public keys returned from the RPC API conform to the type `Base58EncodedAddress`. You can use a value of that type wherever a base58-encoded address or key is expected.
|
|
32
|
+
|
|
33
|
+
From time to time you might acquire a string, that you expect to validate as an address, from an untrusted network API or user input. To assert that such an arbitrary string is a base58-encoded address, use the `assertIsBase58EncodedAddress` function.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { assertIsBase58EncodedAddress } from '@solana/web3.js`;
|
|
37
|
+
|
|
38
|
+
// Imagine a function that fetches an account's balance when a user submits a form.
|
|
39
|
+
function handleSubmit() {
|
|
40
|
+
// We know only that what the user typed conforms to the `string` type.
|
|
41
|
+
const address: string = accountAddressInput.value;
|
|
42
|
+
try {
|
|
43
|
+
// If this type assertion function doesn't throw, then
|
|
44
|
+
// Typescript will upcast `address` to `Base58EncodedAddress`.
|
|
45
|
+
assertIsBase58EncodedAddress(address);
|
|
46
|
+
// At this point, `address` is a `Base58EncodedAddress` that can be used with the RPC.
|
|
47
|
+
const balanceInLamports = await rpc.getBalance(address).send();
|
|
48
|
+
} catch (e) {
|
|
49
|
+
// `address` turned out not to be a base58-encoded address
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
package/dist/index.browser.cjs
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var umiSerializers = require('@metaplex-foundation/umi-serializers');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
8
|
-
|
|
9
|
-
// src/base58.ts
|
|
5
|
+
// ../build-scripts/env-shim.ts
|
|
6
|
+
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
10
7
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
11
8
|
try {
|
|
12
9
|
if (
|
|
@@ -16,7 +13,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
16
13
|
) {
|
|
17
14
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
18
15
|
}
|
|
19
|
-
const bytes =
|
|
16
|
+
const bytes = umiSerializers.base58.serialize(putativeBase58EncodedAddress);
|
|
20
17
|
const numBytes = bytes.byteLength;
|
|
21
18
|
if (numBytes !== 32) {
|
|
22
19
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -27,7 +24,26 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
}
|
|
27
|
+
function getBase58EncodedAddressCodec(config) {
|
|
28
|
+
return umiSerializers.string({
|
|
29
|
+
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""),
|
|
30
|
+
encoding: umiSerializers.base58,
|
|
31
|
+
size: 32
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function getBase58EncodedAddressComparator() {
|
|
35
|
+
return new Intl.Collator("en", {
|
|
36
|
+
caseFirst: "lower",
|
|
37
|
+
ignorePunctuation: false,
|
|
38
|
+
localeMatcher: "best fit",
|
|
39
|
+
numeric: false,
|
|
40
|
+
sensitivity: "variant",
|
|
41
|
+
usage: "sort"
|
|
42
|
+
}).compare;
|
|
43
|
+
}
|
|
30
44
|
|
|
31
45
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
46
|
+
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
47
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
32
48
|
//# sourceMappingURL=out.js.map
|
|
33
49
|
//# sourceMappingURL=index.browser.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/base58.ts"],"names":[],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,QAAoB,cAAc;AAMpC,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,6BACZ,QAGgC;AAChC,SAAO,OAAO;AAAA,IACV,aAAa,QAAQ,gBAAgB,UAAU,8BAA8B;AAAA,IAC7E,UAAU;AAAA,IACV,MAAM;AAAA,EACV,CAAC;AACL;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":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58, Serializer, string } from '@metaplex-foundation/umi-serializers';\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 getBase58EncodedAddressCodec(\n config?: Readonly<{\n description: string;\n }>\n): Serializer<Base58EncodedAddress> {\n return string({\n description: config?.description ?? (__DEV__ ? 'A 32-byte account address' : ''),\n encoding: base58,\n size: 32,\n }) as unknown as Serializer<Base58EncodedAddress>;\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,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { base58, string } from '@metaplex-foundation/umi-serializers';
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// ../build-scripts/env-shim.ts
|
|
4
|
+
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
4
5
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
5
6
|
try {
|
|
6
7
|
if (
|
|
@@ -10,7 +11,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
10
11
|
) {
|
|
11
12
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
12
13
|
}
|
|
13
|
-
const bytes =
|
|
14
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
14
15
|
const numBytes = bytes.byteLength;
|
|
15
16
|
if (numBytes !== 32) {
|
|
16
17
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -21,7 +22,24 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
function getBase58EncodedAddressCodec(config) {
|
|
26
|
+
return string({
|
|
27
|
+
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""),
|
|
28
|
+
encoding: base58,
|
|
29
|
+
size: 32
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function getBase58EncodedAddressComparator() {
|
|
33
|
+
return new Intl.Collator("en", {
|
|
34
|
+
caseFirst: "lower",
|
|
35
|
+
ignorePunctuation: false,
|
|
36
|
+
localeMatcher: "best fit",
|
|
37
|
+
numeric: false,
|
|
38
|
+
sensitivity: "variant",
|
|
39
|
+
usage: "sort"
|
|
40
|
+
}).compare;
|
|
41
|
+
}
|
|
24
42
|
|
|
25
|
-
export { assertIsBase58EncodedAddress };
|
|
43
|
+
export { assertIsBase58EncodedAddress, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator };
|
|
26
44
|
//# sourceMappingURL=out.js.map
|
|
27
45
|
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/base58.ts"],"names":[],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,QAAoB,cAAc;AAMpC,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,6BACZ,QAGgC;AAChC,SAAO,OAAO;AAAA,IACV,aAAa,QAAQ,gBAAgB,UAAU,8BAA8B;AAAA,IAC7E,UAAU;AAAA,IACV,MAAM;AAAA,EACV,CAAC;AACL;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":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58, Serializer, string } from '@metaplex-foundation/umi-serializers';\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 getBase58EncodedAddressCodec(\n config?: Readonly<{\n description: string;\n }>\n): Serializer<Base58EncodedAddress> {\n return string({\n description: config?.description ?? (__DEV__ ? 'A 32-byte account address' : ''),\n encoding: base58,\n size: 32,\n }) as unknown as Serializer<Base58EncodedAddress>;\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,271 @@ 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
|
-
|
|
15
|
-
|
|
11
|
+
|
|
12
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
13
|
+
var mergeBytes = (bytesArr) => {
|
|
14
|
+
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
|
|
15
|
+
const result = new Uint8Array(totalLength);
|
|
16
|
+
let offset = 0;
|
|
17
|
+
bytesArr.forEach((arr) => {
|
|
18
|
+
result.set(arr, offset);
|
|
19
|
+
offset += arr.length;
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
var padBytes = (bytes, length) => {
|
|
24
|
+
if (bytes.length >= length)
|
|
25
|
+
return bytes;
|
|
26
|
+
const paddedBytes = new Uint8Array(length).fill(0);
|
|
27
|
+
paddedBytes.set(bytes);
|
|
28
|
+
return paddedBytes;
|
|
16
29
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
var fixBytes = (bytes, length) => padBytes(bytes.slice(0, length), length);
|
|
31
|
+
|
|
32
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
|
|
33
|
+
var DeserializingEmptyBufferError = class extends Error {
|
|
34
|
+
constructor(serializer) {
|
|
35
|
+
super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
|
|
36
|
+
__publicField(this, "name", "DeserializingEmptyBufferError");
|
|
22
37
|
}
|
|
23
|
-
return to;
|
|
24
38
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
34
|
-
// ../build-scripts/env-shim.ts
|
|
35
|
-
var init_env_shim = __esm({
|
|
36
|
-
"../build-scripts/env-shim.ts"() {
|
|
39
|
+
var NotEnoughBytesError = class extends Error {
|
|
40
|
+
constructor(serializer, expected, actual) {
|
|
41
|
+
super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`);
|
|
42
|
+
__publicField(this, "name", "NotEnoughBytesError");
|
|
37
43
|
}
|
|
38
|
-
}
|
|
44
|
+
};
|
|
39
45
|
|
|
40
|
-
// ../../node_modules/.pnpm
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
|
|
47
|
+
function fixSerializer(serializer, fixedBytes, description) {
|
|
48
|
+
return {
|
|
49
|
+
description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
|
|
50
|
+
fixedSize: fixedBytes,
|
|
51
|
+
maxSize: fixedBytes,
|
|
52
|
+
serialize: (value) => fixBytes(serializer.serialize(value), fixedBytes),
|
|
53
|
+
deserialize: (buffer, offset = 0) => {
|
|
54
|
+
buffer = buffer.slice(offset, offset + fixedBytes);
|
|
55
|
+
if (buffer.length < fixedBytes) {
|
|
56
|
+
throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length);
|
|
47
57
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
BASE_MAP[j] = 255;
|
|
58
|
+
if (serializer.fixedSize !== null) {
|
|
59
|
+
buffer = fixBytes(buffer, serializer.fixedSize);
|
|
51
60
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
const [value] = serializer.deserialize(buffer, 0);
|
|
62
|
+
return [value, offset + fixedBytes];
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
68
|
+
var InvalidBaseStringError = class extends Error {
|
|
69
|
+
constructor(value, base, cause) {
|
|
70
|
+
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
71
|
+
super(message);
|
|
72
|
+
__publicField(this, "name", "InvalidBaseStringError");
|
|
73
|
+
this.cause = cause;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
78
|
+
var baseX = (alphabet) => {
|
|
79
|
+
const base = alphabet.length;
|
|
80
|
+
const baseBigInt = BigInt(base);
|
|
81
|
+
return {
|
|
82
|
+
description: `base${base}`,
|
|
83
|
+
fixedSize: null,
|
|
84
|
+
maxSize: null,
|
|
85
|
+
serialize(value) {
|
|
86
|
+
if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
|
|
87
|
+
throw new InvalidBaseStringError(value, base);
|
|
59
88
|
}
|
|
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;
|
|
89
|
+
if (value === "")
|
|
90
|
+
return new Uint8Array();
|
|
91
|
+
const chars = [...value];
|
|
92
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
|
|
93
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
94
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
95
|
+
if (trailIndex === chars.length)
|
|
96
|
+
return Uint8Array.from(leadingZeroes);
|
|
97
|
+
const tailChars = chars.slice(trailIndex);
|
|
98
|
+
let base10Number = 0n;
|
|
99
|
+
let baseXPower = 1n;
|
|
100
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
101
|
+
base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
|
|
102
|
+
baseXPower *= baseBigInt;
|
|
109
103
|
}
|
|
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;
|
|
104
|
+
const tailBytes = [];
|
|
105
|
+
while (base10Number > 0n) {
|
|
106
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
107
|
+
base10Number /= 256n;
|
|
153
108
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
109
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
110
|
+
},
|
|
111
|
+
deserialize(buffer, offset = 0) {
|
|
112
|
+
if (buffer.length === 0)
|
|
113
|
+
return ["", 0];
|
|
114
|
+
const bytes = buffer.slice(offset);
|
|
115
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
116
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
117
|
+
const leadingZeroes = alphabet[0].repeat(trailIndex);
|
|
118
|
+
if (trailIndex === bytes.length)
|
|
119
|
+
return [leadingZeroes, buffer.length];
|
|
120
|
+
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
121
|
+
const tailChars = [];
|
|
122
|
+
while (base10Number > 0n) {
|
|
123
|
+
tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
|
|
124
|
+
base10Number /= baseBigInt;
|
|
160
125
|
}
|
|
161
|
-
return
|
|
162
|
-
encode,
|
|
163
|
-
decodeUnsafe,
|
|
164
|
-
decode
|
|
165
|
-
};
|
|
126
|
+
return [leadingZeroes + tailChars.join(""), buffer.length];
|
|
166
127
|
}
|
|
167
|
-
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
132
|
+
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
133
|
+
|
|
134
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
|
|
135
|
+
var removeNullCharacters = (value) => (
|
|
136
|
+
// eslint-disable-next-line no-control-regex
|
|
137
|
+
value.replace(/\u0000/g, "")
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
|
|
141
|
+
var utf8 = {
|
|
142
|
+
description: "utf8",
|
|
143
|
+
fixedSize: null,
|
|
144
|
+
maxSize: null,
|
|
145
|
+
serialize(value) {
|
|
146
|
+
return new TextEncoder().encode(value);
|
|
147
|
+
},
|
|
148
|
+
deserialize(buffer, offset = 0) {
|
|
149
|
+
const value = new TextDecoder().decode(buffer.slice(offset));
|
|
150
|
+
return [removeNullCharacters(value), buffer.length];
|
|
168
151
|
}
|
|
169
|
-
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
|
|
155
|
+
var Endian;
|
|
156
|
+
(function(Endian2) {
|
|
157
|
+
Endian2["Little"] = "le";
|
|
158
|
+
Endian2["Big"] = "be";
|
|
159
|
+
})(Endian || (Endian = {}));
|
|
160
|
+
|
|
161
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
|
|
162
|
+
var NumberOutOfRangeError = class extends RangeError {
|
|
163
|
+
constructor(serializer, min, max, actual) {
|
|
164
|
+
super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
|
|
165
|
+
__publicField(this, "name", "NumberOutOfRangeError");
|
|
166
|
+
}
|
|
167
|
+
};
|
|
170
168
|
|
|
171
|
-
// ../../node_modules/.pnpm
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
169
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
|
|
170
|
+
function numberFactory(input) {
|
|
171
|
+
let littleEndian;
|
|
172
|
+
let defaultDescription = input.name;
|
|
173
|
+
if (input.size > 1) {
|
|
174
|
+
littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little;
|
|
175
|
+
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
description: input.options.description ?? defaultDescription,
|
|
179
|
+
fixedSize: input.size,
|
|
180
|
+
maxSize: input.size,
|
|
181
|
+
serialize(value) {
|
|
182
|
+
if (input.range) {
|
|
183
|
+
assertRange(input.name, input.range[0], input.range[1], value);
|
|
184
|
+
}
|
|
185
|
+
const buffer = new ArrayBuffer(input.size);
|
|
186
|
+
input.set(new DataView(buffer), value, littleEndian);
|
|
187
|
+
return new Uint8Array(buffer);
|
|
188
|
+
},
|
|
189
|
+
deserialize(bytes, offset = 0) {
|
|
190
|
+
const slice = bytes.slice(offset, offset + input.size);
|
|
191
|
+
assertEnoughBytes("i8", slice, input.size);
|
|
192
|
+
const view = toDataView(slice);
|
|
193
|
+
return [input.get(view, littleEndian), offset + input.size];
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
var toArrayBuffer = (array) => array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
|
|
198
|
+
var toDataView = (array) => new DataView(toArrayBuffer(array));
|
|
199
|
+
var assertRange = (serializer, min, max, value) => {
|
|
200
|
+
if (value < min || value > max) {
|
|
201
|
+
throw new NumberOutOfRangeError(serializer, min, max, value);
|
|
178
202
|
}
|
|
203
|
+
};
|
|
204
|
+
var assertEnoughBytes = (serializer, bytes, expected) => {
|
|
205
|
+
if (bytes.length === 0) {
|
|
206
|
+
throw new DeserializingEmptyBufferError(serializer);
|
|
207
|
+
}
|
|
208
|
+
if (bytes.length < expected) {
|
|
209
|
+
throw new NotEnoughBytesError(serializer, expected, bytes.length);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
214
|
+
var u32 = (options = {}) => numberFactory({
|
|
215
|
+
name: "u32",
|
|
216
|
+
size: 4,
|
|
217
|
+
range: [0, Number("0xffffffff")],
|
|
218
|
+
set: (view, value, le) => view.setUint32(0, Number(value), le),
|
|
219
|
+
get: (view, le) => view.getUint32(0, le),
|
|
220
|
+
options
|
|
179
221
|
});
|
|
180
222
|
|
|
181
|
-
//
|
|
182
|
-
|
|
223
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
224
|
+
function getSizeDescription(size) {
|
|
225
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
229
|
+
function string(options = {}) {
|
|
230
|
+
const size = options.size ?? u32();
|
|
231
|
+
const encoding = options.encoding ?? utf8;
|
|
232
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
233
|
+
if (size === "variable") {
|
|
234
|
+
return {
|
|
235
|
+
...encoding,
|
|
236
|
+
description
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (typeof size === "number") {
|
|
240
|
+
return fixSerializer(encoding, size, description);
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
description,
|
|
244
|
+
fixedSize: null,
|
|
245
|
+
maxSize: null,
|
|
246
|
+
serialize: (value) => {
|
|
247
|
+
const contentBytes = encoding.serialize(value);
|
|
248
|
+
const lengthBytes = size.serialize(contentBytes.length);
|
|
249
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
250
|
+
},
|
|
251
|
+
deserialize: (buffer, offset = 0) => {
|
|
252
|
+
if (buffer.slice(offset).length === 0) {
|
|
253
|
+
throw new DeserializingEmptyBufferError("string");
|
|
254
|
+
}
|
|
255
|
+
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
256
|
+
const length = Number(lengthBigInt);
|
|
257
|
+
offset = lengthOffset;
|
|
258
|
+
const contentBuffer = buffer.slice(offset, offset + length);
|
|
259
|
+
if (contentBuffer.length < length) {
|
|
260
|
+
throw new NotEnoughBytesError("string", length, contentBuffer.length);
|
|
261
|
+
}
|
|
262
|
+
const [value, contentOffset] = encoding.deserialize(contentBuffer);
|
|
263
|
+
offset += contentOffset;
|
|
264
|
+
return [value, offset];
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
183
268
|
|
|
184
269
|
// src/base58.ts
|
|
185
|
-
init_env_shim();
|
|
186
|
-
var import_bs58 = __toESM(require_bs58(), 1);
|
|
187
270
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
188
271
|
try {
|
|
189
272
|
if (
|
|
@@ -193,7 +276,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
193
276
|
) {
|
|
194
277
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
195
278
|
}
|
|
196
|
-
const bytes =
|
|
279
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
197
280
|
const numBytes = bytes.byteLength;
|
|
198
281
|
if (numBytes !== 32) {
|
|
199
282
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -204,8 +287,27 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
204
287
|
});
|
|
205
288
|
}
|
|
206
289
|
}
|
|
290
|
+
function getBase58EncodedAddressCodec(config) {
|
|
291
|
+
return string({
|
|
292
|
+
description: config?.description ?? ("A 32-byte account address" ),
|
|
293
|
+
encoding: base58,
|
|
294
|
+
size: 32
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function getBase58EncodedAddressComparator() {
|
|
298
|
+
return new Intl.Collator("en", {
|
|
299
|
+
caseFirst: "lower",
|
|
300
|
+
ignorePunctuation: false,
|
|
301
|
+
localeMatcher: "best fit",
|
|
302
|
+
numeric: false,
|
|
303
|
+
sensitivity: "variant",
|
|
304
|
+
usage: "sort"
|
|
305
|
+
}).compare;
|
|
306
|
+
}
|
|
207
307
|
|
|
208
308
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
309
|
+
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
310
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
209
311
|
|
|
210
312
|
return exports;
|
|
211
313
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../build-scripts/env-shim.ts","../../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js","../../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js","../src/index.ts","../src/base58.ts"],"names":["i","j","bs58"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAMA,aAAS,KAAM,UAAU;AACvB,UAAI,SAAS,UAAU,KAAK;AAAE,cAAM,IAAI,UAAU,mBAAmB;AAAA,MAAE;AACvE,UAAI,WAAW,IAAI,WAAW,GAAG;AACjC,eAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,iBAAS,CAAC,IAAI;AAAA,MAChB;AACA,eAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,YAAI,IAAI,SAAS,OAAO,CAAC;AACzB,YAAI,KAAK,EAAE,WAAW,CAAC;AACvB,YAAI,SAAS,EAAE,MAAM,KAAK;AAAE,gBAAM,IAAI,UAAU,IAAI,eAAe;AAAA,QAAE;AACrE,iBAAS,EAAE,IAAI;AAAA,MACjB;AACA,U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AAS,OAAQ,QAAQ;AACvB,YAAI,SAAS,aAAa,MAAM;AAChC,YAAI,QAAQ;AAAE,iBAAO;AAAA,QAAO;AAC5B,cAAM,IAAI,MAAM,aAAa,OAAO,YAAY;AAAA,MAClD;AACA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO,UAAU;AAAA;AAAA;;;ACxHjB;AAAA;AAAA;AAAA,QAAM,QAAQ;AACd,QAAM,WAAW;AAEjB,WAAO,UAAU,MAAM,QAAQ;AAAA;AAAA;;;ACH/B;;;ACAA;AAAA,kBAAiB;AAIV,SAAS,6BACZ,8BAC4D;AAC5D,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,YAAAC,QAAK,OAAO,4BAA4B;AACtD,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","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","'use strict'\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\nfunction base (ALPHABET) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n var BASE_MAP = new Uint8Array(256)\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i)\n var xc = x.charCodeAt(0)\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i\n }\n var BASE = ALPHABET.length\n var LEADER = ALPHABET.charAt(0)\n var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up\n function encode (source) {\n if (source instanceof Uint8Array) {\n } else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength)\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source)\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n var zeroes = 0\n var length = 0\n var pbegin = 0\n var pend = source.length\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++\n zeroes++\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0\n var b58 = new Uint8Array(size)\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin]\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0\n b58[it1] = (carry % BASE) >>> 0\n carry = (carry / BASE) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n pbegin++\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length\n while (it2 !== size && b58[it2] === 0) {\n it2++\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes)\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n var psz = 0\n // Skip and count leading '1's.\n var zeroes = 0\n var length = 0\n while (source[psz] === LEADER) {\n zeroes++\n psz++\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size)\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)]\n // Invalid character\n if (carry === 255) { return }\n var i = 0\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0\n b256[it3] = (carry % 256) >>> 0\n carry = (carry / 256) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n psz++\n }\n // Skip leading zeroes in b256.\n var it4 = size - length\n while (it4 !== size && b256[it4] === 0) {\n it4++\n }\n var vch = new Uint8Array(zeroes + (size - it4))\n var j = zeroes\n while (it4 !== size) {\n vch[j++] = b256[it4++]\n }\n return vch\n }\n function decode (string) {\n var buffer = decodeUnsafe(string)\n if (buffer) { return buffer }\n throw new Error('Non-base' + BASE + ' character')\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n }\n}\nmodule.exports = base\n","const basex = require('base-x')\nconst ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n\nmodule.exports = basex(ALPHABET)\n","export * from './base58';\n","import bs58 from 'bs58';\n\nexport type Base58EncodedAddress = string & { readonly __base58EncodedAddress: unique symbol };\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress {\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 = bs58.decode(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"]}
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/src/bytes.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/src/errors.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/src/fixSerializer.ts","../../../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","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/nullCharacters.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/utf8.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/src/common.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/src/errors.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/src/utils.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/src/u32.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/src/utils.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/src/string.ts","../src/base58.ts"],"names":["mergeBytes","bytesArr","totalLength","reduce","total","arr","length","result","Uint8Array","offset","forEach","set","padBytes","bytes","paddedBytes","fill","fixBytes","slice","DeserializingEmptyBufferError","Error","constructor","serializer","name","NotEnoughBytesError","expected","actual","fixSerializer","fixedBytes","description","fixedSize","maxSize","serialize","value","deserialize","buffer","InvalidBaseStringError","base","cause","message","baseX","alphabet","baseBigInt","BigInt","match","RegExp","chars","trailIndex","findIndex","c","leadingZeroes","Array","from","tailChars","base10Number","baseXPower","i","indexOf","tailBytes","unshift","Number","concat","n","repeat","sum","byte","join","base58","removeNullCharacters","replace","utf8","TextEncoder","encode","TextDecoder","decode","Endian","NumberOutOfRangeError","RangeError","min","max","numberFactory","input","littleEndian","defaultDescription","size","options","endian","Little","range","assertRange","ArrayBuffer","DataView","assertEnoughBytes","view","toDataView","get","toArrayBuffer","array","byteOffset","byteLength","u32","le","setUint32","getUint32","getSizeDescription","string","encoding","contentBytes","lengthBytes","lengthBigInt","lengthOffset","contentBuffer","contentOffset"],"mappings":";;;;;;;;AAIaA,IAAAA,aAAcC,cAAuC;AAChE,QAAMC,cAAcD,SAASE,OAAO,CAACC,OAAOC,QAAQD,QAAQC,IAAIC,QAAQ,CAAC;AACzE,QAAMC,SAAS,IAAIC,WAAWN,WAAW;AACzC,MAAIO,SAAS;AACbR,WAASS,QAASL,SAAQ;AACxBE,WAAOI,IAAIN,KAAKI,MAAM;AACtBA,cAAUJ,IAAIC;EAChB,CAAC;AACD,SAAOC;AACT;IAOaK,WAAW,CAACC,OAAmBP,WAA+B;AACzE,MAAIO,MAAMP,UAAUA;AAAQ,WAAOO;AACnC,QAAMC,cAAc,IAAIN,WAA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a single `Uint8Array`.\n * @category Utils\n */\nexport const mergeBytes = (bytesArr: Uint8Array[]): Uint8Array => {\n const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n bytesArr.forEach((arr) => {\n result.set(arr, offset);\n offset += arr.length;\n });\n return result;\n};\n\n/**\n * Pads a `Uint8Array` with zeroes to the specified length.\n * If the array is longer than the specified length, it is returned as-is.\n * @category Utils\n */\nexport const padBytes = (bytes: Uint8Array, length: number): Uint8Array => {\n if (bytes.length >= length) return bytes;\n const paddedBytes = new Uint8Array(length).fill(0);\n paddedBytes.set(bytes);\n return paddedBytes;\n};\n\n/**\n * Fixes a `Uint8Array` to the specified length.\n * If the array is longer than the specified length, it is truncated.\n * If the array is shorter than the specified length, it is padded with zeroes.\n * @category Utils\n */\nexport const fixBytes = (bytes: Uint8Array, length: number): Uint8Array =>\n padBytes(bytes.slice(0, length), length);\n","/** @category Errors */\nexport class DeserializingEmptyBufferError extends Error {\n readonly name: string = 'DeserializingEmptyBufferError';\n\n constructor(serializer: string) {\n super(`Serializer [${serializer}] cannot deserialize empty buffers.`);\n }\n}\n\n/** @category Errors */\nexport class NotEnoughBytesError extends Error {\n readonly name: string = 'NotEnoughBytesError';\n\n constructor(\n serializer: string,\n expected: bigint | number,\n actual: bigint | number\n ) {\n super(\n `Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`\n );\n }\n}\n\n/** @category Errors */\nexport class ExpectedFixedSizeSerializerError extends Error {\n readonly name: string = 'ExpectedFixedSizeSerializerError';\n\n constructor(message?: string) {\n message ??= 'Expected a fixed-size serializer, got a variable-size one.';\n super(message);\n }\n}\n","import { fixBytes } from './bytes';\nimport { Serializer } from './common';\nimport { NotEnoughBytesError } from './errors';\n\n/**\n * Creates a fixed-size serializer from a given serializer.\n *\n * @param serializer - The serializer to wrap into a fixed-size serializer.\n * @param fixedBytes - The fixed number of bytes to read.\n * @param description - A custom description for the serializer.\n *\n * @category Serializers\n */\nexport function fixSerializer<T, U extends T = T>(\n serializer: Serializer<T, U>,\n fixedBytes: number,\n description?: string\n): Serializer<T, U> {\n return {\n description:\n description ?? `fixed(${fixedBytes}, ${serializer.description})`,\n fixedSize: fixedBytes,\n maxSize: fixedBytes,\n serialize: (value: T) => fixBytes(serializer.serialize(value), fixedBytes),\n deserialize: (buffer: Uint8Array, offset = 0) => {\n // Slice the buffer to the fixed size.\n buffer = buffer.slice(offset, offset + fixedBytes);\n // Ensure we have enough bytes.\n if (buffer.length < fixedBytes) {\n throw new NotEnoughBytesError(\n 'fixSerializer',\n fixedBytes,\n buffer.length\n );\n }\n // If the nested serializer is fixed-size, pad and truncate the buffer accordingly.\n if (serializer.fixedSize !== null) {\n buffer = fixBytes(buffer, serializer.fixedSize);\n }\n // Deserialize the value using the nested serializer.\n const [value] = serializer.deserialize(buffer, 0);\n return [value, offset + fixedBytes];\n },\n };\n}\n","/** @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","/**\n * Removes null characters from a string.\n * @category Utils\n */\nexport const removeNullCharacters = (value: string) =>\n // eslint-disable-next-line no-control-regex\n value.replace(/\\u0000/g, '');\n\n/**\n * Pads a string with null characters at the end.\n * @category Utils\n */\nexport const padNullCharacters = (value: string, chars: number) =>\n value.padEnd(chars, '\\u0000');\n","import type { Serializer } from '@metaplex-foundation/umi-serializers-core';\nimport { removeNullCharacters } from './nullCharacters';\n\n/**\n * A string serializer that uses UTF-8 encoding\n * using the native `TextEncoder` API.\n * @category Serializers\n */\nexport const utf8: Serializer<string> = {\n description: 'utf8',\n fixedSize: null,\n maxSize: null,\n serialize(value: string) {\n return new TextEncoder().encode(value);\n },\n deserialize(buffer, offset = 0) {\n const value = new TextDecoder().decode(buffer.slice(offset));\n return [removeNullCharacters(value), buffer.length];\n },\n};\n","import {\n BaseSerializerOptions,\n Serializer,\n} from '@metaplex-foundation/umi-serializers-core';\n\n/**\n * Defines a serializer for numbers and bigints.\n * @category Serializers\n */\nexport type NumberSerializer =\n | Serializer<number>\n | Serializer<number | bigint, bigint>;\n\n/**\n * Defines the options for u8 and i8 serializers.\n * @category Serializers\n */\nexport type SingleByteNumberSerializerOptions = BaseSerializerOptions;\n\n/**\n * Defines the options for number serializers that use more than one byte.\n * @category Serializers\n */\nexport type NumberSerializerOptions = BaseSerializerOptions & {\n /**\n * Whether the serializer should use little-endian or big-endian encoding.\n * @defaultValue `Endian.Little`\n */\n endian?: Endian;\n};\n\n/**\n * Defines the endianness of a number serializer.\n * @category Serializers\n */\nexport enum Endian {\n Little = 'le',\n Big = 'be',\n}\n","/** @category Errors */\nexport class NumberOutOfRangeError extends RangeError {\n readonly name: string = 'NumberOutOfRangeError';\n\n constructor(\n serializer: string,\n min: number | bigint,\n max: number | bigint,\n actual: number | bigint\n ) {\n super(\n `Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`\n );\n }\n}\n","import {\n DeserializingEmptyBufferError,\n NotEnoughBytesError,\n Serializer,\n} from '@metaplex-foundation/umi-serializers-core';\nimport {\n Endian,\n NumberSerializer,\n NumberSerializerOptions,\n SingleByteNumberSerializerOptions,\n} from './common';\nimport { NumberOutOfRangeError } from './errors';\n\nexport function numberFactory(input: {\n name: string;\n size: number;\n range?: [number | bigint, number | bigint];\n set: (view: DataView, value: number | bigint, littleEndian?: boolean) => void;\n get: (view: DataView, littleEndian?: boolean) => number;\n options: SingleByteNumberSerializerOptions | NumberSerializerOptions;\n}): Serializer<number>;\nexport function numberFactory(input: {\n name: string;\n size: number;\n range?: [number | bigint, number | bigint];\n set: (view: DataView, value: number | bigint, littleEndian?: boolean) => void;\n get: (view: DataView, littleEndian?: boolean) => bigint;\n options: SingleByteNumberSerializerOptions | NumberSerializerOptions;\n}): Serializer<number | bigint, bigint>;\nexport function numberFactory(input: {\n name: string;\n size: number;\n range?: [number | bigint, number | bigint];\n set: (view: DataView, value: number | bigint, littleEndian?: boolean) => void;\n get: (view: DataView, littleEndian?: boolean) => number | bigint;\n options: SingleByteNumberSerializerOptions | NumberSerializerOptions;\n}): NumberSerializer {\n let littleEndian: boolean | undefined;\n let defaultDescription: string = input.name;\n\n if (input.size > 1) {\n littleEndian =\n !('endian' in input.options) || input.options.endian === Endian.Little;\n defaultDescription += littleEndian ? '(le)' : '(be)';\n }\n\n return {\n description: input.options.description ?? defaultDescription,\n fixedSize: input.size,\n maxSize: input.size,\n serialize(value: number | bigint): Uint8Array {\n if (input.range) {\n assertRange(input.name, input.range[0], input.range[1], value);\n }\n const buffer = new ArrayBuffer(input.size);\n input.set(new DataView(buffer), value, littleEndian);\n return new Uint8Array(buffer);\n },\n deserialize(bytes, offset = 0): [number | bigint, number] {\n const slice = bytes.slice(offset, offset + input.size);\n assertEnoughBytes('i8', slice, input.size);\n const view = toDataView(slice);\n return [input.get(view, littleEndian), offset + input.size];\n },\n } as NumberSerializer;\n}\n\n/**\n * Helper function to ensure that the array buffer is converted properly from a uint8array\n * Source: https://stackoverflow.com/questions/37228285/uint8array-to-arraybuffer\n * @param {Uint8Array} array Uint8array that's being converted into an array buffer\n * @returns {ArrayBuffer} An array buffer that's necessary to construct a data view\n */\nexport const toArrayBuffer = (array: Uint8Array): ArrayBuffer =>\n array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);\n\nexport const toDataView = (array: Uint8Array): DataView =>\n new DataView(toArrayBuffer(array));\n\nexport const assertRange = (\n serializer: string,\n min: number | bigint,\n max: number | bigint,\n value: number | bigint\n) => {\n if (value < min || value > max) {\n throw new NumberOutOfRangeError(serializer, min, max, value);\n }\n};\n\nexport const assertEnoughBytes = (\n serializer: string,\n bytes: Uint8Array,\n expected: number\n) => {\n if (bytes.length === 0) {\n throw new DeserializingEmptyBufferError(serializer);\n }\n if (bytes.length < expected) {\n throw new NotEnoughBytesError(serializer, expected, bytes.length);\n }\n};\n","import { Serializer } from '@metaplex-foundation/umi-serializers-core';\nimport { NumberSerializerOptions } from './common';\nimport { numberFactory } from './utils';\n\nexport const u32 = (\n options: NumberSerializerOptions = {}\n): Serializer<number> =>\n numberFactory({\n name: 'u32',\n size: 4,\n range: [0, Number('0xffffffff')],\n set: (view, value, le) => view.setUint32(0, Number(value), le),\n get: (view, le) => view.getUint32(0, le),\n options,\n });\n","import { ExpectedFixedSizeSerializerError } from '@metaplex-foundation/umi-serializers-core';\nimport { ArrayLikeSerializerSize } from './arrayLikeSerializerSize';\nimport {\n InvalidArrayLikeRemainderSizeError,\n UnrecognizedArrayLikeSerializerSizeError,\n} from './errors';\nimport { sumSerializerSizes } from './sumSerializerSizes';\n\nexport function getResolvedSize(\n size: ArrayLikeSerializerSize,\n childrenSizes: (number | null)[],\n bytes: Uint8Array,\n offset: number\n): [number | bigint, number] {\n if (typeof size === 'number') {\n return [size, offset];\n }\n\n if (typeof size === 'object') {\n return size.deserialize(bytes, offset);\n }\n\n if (size === 'remainder') {\n const childrenSize = sumSerializerSizes(childrenSizes);\n if (childrenSize === null) {\n throw new ExpectedFixedSizeSerializerError(\n 'Serializers of \"remainder\" size must have fixed-size items.'\n );\n }\n const remainder = bytes.slice(offset).length;\n if (remainder % childrenSize !== 0) {\n throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);\n }\n return [remainder / childrenSize, offset];\n }\n\n throw new UnrecognizedArrayLikeSerializerSizeError(size);\n}\n\nexport function getSizeDescription(\n size: ArrayLikeSerializerSize | string\n): string {\n return typeof size === 'object' ? size.description : `${size}`;\n}\n\nexport function getSizeFromChildren(\n size: ArrayLikeSerializerSize,\n childrenSizes: (number | null)[]\n): number | null {\n if (typeof size !== 'number') return null;\n if (size === 0) return 0;\n const childrenSize = sumSerializerSizes(childrenSizes);\n return childrenSize === null ? null : childrenSize * size;\n}\n\nexport function getSizePrefix(\n size: ArrayLikeSerializerSize,\n realSize: number\n): Uint8Array {\n return typeof size === 'object' ? size.serialize(realSize) : new Uint8Array();\n}\n","import {\n BaseSerializerOptions,\n DeserializingEmptyBufferError,\n NotEnoughBytesError,\n Serializer,\n fixSerializer,\n mergeBytes,\n} from '@metaplex-foundation/umi-serializers-core';\nimport { utf8 } from '@metaplex-foundation/umi-serializers-encodings';\nimport {\n NumberSerializer,\n u32,\n} from '@metaplex-foundation/umi-serializers-numbers';\nimport { getSizeDescription } from './utils';\n\n/**\n * Defines the options for string serializers.\n * @category Serializers\n */\nexport type StringSerializerOptions = BaseSerializerOptions & {\n /**\n * The size of the string. It can be one of the following:\n * - a {@link NumberSerializer} that prefixes the string with its size.\n * - a fixed number of bytes.\n * - or `'variable'` to use the rest of the buffer.\n * @defaultValue `u32()`\n */\n size?: NumberSerializer | number | 'variable';\n /**\n * The string serializer to use for encoding and decoding the content.\n * @defaultValue `utf8`\n */\n encoding?: Serializer<string>;\n};\n\n/**\n * Creates a string serializer.\n *\n * @param options - A set of options for the serializer.\n * @category Serializers\n */\nexport function string(\n options: StringSerializerOptions = {}\n): Serializer<string> {\n const size = options.size ?? u32();\n const encoding = options.encoding ?? utf8;\n const description =\n options.description ??\n `string(${encoding.description}; ${getSizeDescription(size)})`;\n\n if (size === 'variable') {\n return { ...encoding, description };\n }\n\n if (typeof size === 'number') {\n return fixSerializer(encoding, size, description);\n }\n\n return {\n description,\n fixedSize: null,\n maxSize: null,\n serialize: (value: string) => {\n const contentBytes = encoding.serialize(value);\n const lengthBytes = size.serialize(contentBytes.length);\n return mergeBytes([lengthBytes, contentBytes]);\n },\n deserialize: (buffer: Uint8Array, offset = 0) => {\n if (buffer.slice(offset).length === 0) {\n throw new DeserializingEmptyBufferError('string');\n }\n const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);\n const length = Number(lengthBigInt);\n offset = lengthOffset;\n const contentBuffer = buffer.slice(offset, offset + length);\n if (contentBuffer.length < length) {\n throw new NotEnoughBytesError('string', length, contentBuffer.length);\n }\n const [value, contentOffset] = encoding.deserialize(contentBuffer);\n offset += contentOffset;\n return [value, offset];\n },\n };\n}\n","import { base58, Serializer, string } from '@metaplex-foundation/umi-serializers';\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 getBase58EncodedAddressCodec(\n config?: Readonly<{\n description: string;\n }>\n): Serializer<Base58EncodedAddress> {\n return string({\n description: config?.description ?? (__DEV__ ? 'A 32-byte account address' : ''),\n encoding: base58,\n size: 32,\n }) as unknown as Serializer<Base58EncodedAddress>;\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,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { base58, string } from '@metaplex-foundation/umi-serializers';
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// ../build-scripts/env-shim.ts
|
|
4
|
+
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
4
5
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
5
6
|
try {
|
|
6
7
|
if (
|
|
@@ -10,7 +11,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
10
11
|
) {
|
|
11
12
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
12
13
|
}
|
|
13
|
-
const bytes =
|
|
14
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
14
15
|
const numBytes = bytes.byteLength;
|
|
15
16
|
if (numBytes !== 32) {
|
|
16
17
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -21,7 +22,24 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
function getBase58EncodedAddressCodec(config) {
|
|
26
|
+
return string({
|
|
27
|
+
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""),
|
|
28
|
+
encoding: base58,
|
|
29
|
+
size: 32
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function getBase58EncodedAddressComparator() {
|
|
33
|
+
return new Intl.Collator("en", {
|
|
34
|
+
caseFirst: "lower",
|
|
35
|
+
ignorePunctuation: false,
|
|
36
|
+
localeMatcher: "best fit",
|
|
37
|
+
numeric: false,
|
|
38
|
+
sensitivity: "variant",
|
|
39
|
+
usage: "sort"
|
|
40
|
+
}).compare;
|
|
41
|
+
}
|
|
24
42
|
|
|
25
|
-
export { assertIsBase58EncodedAddress };
|
|
43
|
+
export { assertIsBase58EncodedAddress, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator };
|
|
26
44
|
//# sourceMappingURL=out.js.map
|
|
27
45
|
//# sourceMappingURL=index.native.js.map
|
package/dist/index.native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/base58.ts"],"names":[],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,QAAoB,cAAc;AAMpC,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,6BACZ,QAGgC;AAChC,SAAO,OAAO;AAAA,IACV,aAAa,QAAQ,gBAAgB,UAAU,8BAA8B;AAAA,IAC7E,UAAU;AAAA,IACV,MAAM;AAAA,EACV,CAAC;AACL;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":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58, Serializer, string } from '@metaplex-foundation/umi-serializers';\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 getBase58EncodedAddressCodec(\n config?: Readonly<{\n description: string;\n }>\n): Serializer<Base58EncodedAddress> {\n return string({\n description: config?.description ?? (__DEV__ ? 'A 32-byte account address' : ''),\n encoding: base58,\n size: 32,\n }) as unknown as Serializer<Base58EncodedAddress>;\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,12 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var umiSerializers = require('@metaplex-foundation/umi-serializers');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
8
|
-
|
|
9
|
-
// src/base58.ts
|
|
5
|
+
// ../build-scripts/env-shim.ts
|
|
6
|
+
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
10
7
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
11
8
|
try {
|
|
12
9
|
if (
|
|
@@ -16,7 +13,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
16
13
|
) {
|
|
17
14
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
18
15
|
}
|
|
19
|
-
const bytes =
|
|
16
|
+
const bytes = umiSerializers.base58.serialize(putativeBase58EncodedAddress);
|
|
20
17
|
const numBytes = bytes.byteLength;
|
|
21
18
|
if (numBytes !== 32) {
|
|
22
19
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -27,7 +24,26 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
}
|
|
27
|
+
function getBase58EncodedAddressCodec(config) {
|
|
28
|
+
return umiSerializers.string({
|
|
29
|
+
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""),
|
|
30
|
+
encoding: umiSerializers.base58,
|
|
31
|
+
size: 32
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function getBase58EncodedAddressComparator() {
|
|
35
|
+
return new Intl.Collator("en", {
|
|
36
|
+
caseFirst: "lower",
|
|
37
|
+
ignorePunctuation: false,
|
|
38
|
+
localeMatcher: "best fit",
|
|
39
|
+
numeric: false,
|
|
40
|
+
sensitivity: "variant",
|
|
41
|
+
usage: "sort"
|
|
42
|
+
}).compare;
|
|
43
|
+
}
|
|
30
44
|
|
|
31
45
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
46
|
+
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
47
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
32
48
|
//# sourceMappingURL=out.js.map
|
|
33
49
|
//# sourceMappingURL=index.node.cjs.map
|
package/dist/index.node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/base58.ts"],"names":[],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,QAAoB,cAAc;AAMpC,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,6BACZ,QAGgC;AAChC,SAAO,OAAO;AAAA,IACV,aAAa,QAAQ,gBAAgB,UAAU,8BAA8B;AAAA,IAC7E,UAAU;AAAA,IACV,MAAM;AAAA,EACV,CAAC;AACL;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":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58, Serializer, string } from '@metaplex-foundation/umi-serializers';\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 getBase58EncodedAddressCodec(\n config?: Readonly<{\n description: string;\n }>\n): Serializer<Base58EncodedAddress> {\n return string({\n description: config?.description ?? (__DEV__ ? 'A 32-byte account address' : ''),\n encoding: base58,\n size: 32,\n }) as unknown as Serializer<Base58EncodedAddress>;\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,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { base58, string } from '@metaplex-foundation/umi-serializers';
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// ../build-scripts/env-shim.ts
|
|
4
|
+
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
4
5
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
5
6
|
try {
|
|
6
7
|
if (
|
|
@@ -10,7 +11,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
10
11
|
) {
|
|
11
12
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
12
13
|
}
|
|
13
|
-
const bytes =
|
|
14
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
14
15
|
const numBytes = bytes.byteLength;
|
|
15
16
|
if (numBytes !== 32) {
|
|
16
17
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -21,7 +22,24 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
function getBase58EncodedAddressCodec(config) {
|
|
26
|
+
return string({
|
|
27
|
+
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""),
|
|
28
|
+
encoding: base58,
|
|
29
|
+
size: 32
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function getBase58EncodedAddressComparator() {
|
|
33
|
+
return new Intl.Collator("en", {
|
|
34
|
+
caseFirst: "lower",
|
|
35
|
+
ignorePunctuation: false,
|
|
36
|
+
localeMatcher: "best fit",
|
|
37
|
+
numeric: false,
|
|
38
|
+
sensitivity: "variant",
|
|
39
|
+
usage: "sort"
|
|
40
|
+
}).compare;
|
|
41
|
+
}
|
|
24
42
|
|
|
25
|
-
export { assertIsBase58EncodedAddress };
|
|
43
|
+
export { assertIsBase58EncodedAddress, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator };
|
|
26
44
|
//# sourceMappingURL=out.js.map
|
|
27
45
|
//# sourceMappingURL=index.node.js.map
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/base58.ts"],"names":[],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,QAAoB,cAAc;AAMpC,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,6BACZ,QAGgC;AAChC,SAAO,OAAO;AAAA,IACV,aAAa,QAAQ,gBAAgB,UAAU,8BAA8B;AAAA,IAC7E,UAAU;AAAA,IACV,MAAM;AAAA,EACV,CAAC;AACL;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":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58, Serializer, string } from '@metaplex-foundation/umi-serializers';\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 getBase58EncodedAddressCodec(\n config?: Readonly<{\n description: string;\n }>\n): Serializer<Base58EncodedAddress> {\n return string({\n description: config?.description ?? (__DEV__ ? 'A 32-byte account address' : ''),\n encoding: base58,\n size: 32,\n }) as unknown as Serializer<Base58EncodedAddress>;\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,11 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var O=Object.defineProperty;var U=(e,r,t)=>r in e?O(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var u=(e,r,t)=>(U(e,typeof r!="symbol"?r+"":r,t),t);var S=e=>{let r=e.reduce((n,i)=>n+i.length,0),t=new Uint8Array(r),o=0;return e.forEach(n=>{t.set(n,o),o+=n.length;}),t},N=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},g=(e,r)=>N(e.slice(0,r),r);var x=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);u(this,"name","DeserializingEmptyBufferError");}},d=class extends Error{constructor(t,o,n){super(`Serializer [${t}] expected ${o} bytes, got ${n}.`);u(this,"name","NotEnoughBytesError");}};function w(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:o=>g(e.serialize(o),r),deserialize:(o,n=0)=>{if(o=o.slice(n,n+r),o.length<r)throw new d("fixSerializer",r,o.length);e.fixedSize!==null&&(o=g(o,e.fixedSize));let[i]=e.deserialize(o,0);return [i,n+r]}}}var z=class extends Error{constructor(t,o,n){let i=`Expected a string of base ${o}, got [${t}].`;super(i);u(this,"name","InvalidBaseStringError");this.cause=n;}};var $=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(o){if(!o.match(new RegExp(`^[${e}]*$`)))throw new z(o,r);if(o==="")return new Uint8Array;let n=[...o],i=n.findIndex(m=>m!==e[0]);i=i===-1?n.length:i;let a=Array(i).fill(0);if(i===n.length)return Uint8Array.from(a);let p=n.slice(i),l=0n,c=1n;for(let m=p.length-1;m>=0;m-=1)l+=c*BigInt(e.indexOf(p[m])),c*=t;let f=[];for(;l>0n;)f.unshift(Number(l%256n)),l/=256n;return Uint8Array.from(a.concat(f))},deserialize(o,n=0){if(o.length===0)return ["",0];let i=o.slice(n),a=i.findIndex(f=>f!==0);a=a===-1?i.length:a;let p=e[0].repeat(a);if(a===i.length)return [p,o.length];let l=i.slice(a).reduce((f,m)=>f*256n+BigInt(m),0n),c=[];for(;l>0n;)c.unshift(e[Number(l%t)]),l/=t;return [p+c.join(""),o.length]}}};var h=$("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var I=e=>e.replace(/\u0000/g,"");var b={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 [I(t),e.length]}};var E;(function(e){e.Little="le",e.Big="be";})(E||(E={}));var y=class extends RangeError{constructor(t,o,n,i){super(`Serializer [${t}] expected number to be between ${o} and ${n}, got ${i}.`);u(this,"name","NumberOutOfRangeError");}};function v(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===E.Little,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,maxSize:e.size,serialize(o){e.range&&_(e.name,e.range[0],e.range[1],o);let n=new ArrayBuffer(e.size);return e.set(new DataView(n),o,r),new Uint8Array(n)},deserialize(o,n=0){let i=o.slice(n,n+e.size);L("i8",i,e.size);let a=R(i);return [e.get(a,r),n+e.size]}}}var C=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),R=e=>new DataView(C(e)),_=(e,r,t,o)=>{if(o<r||o>t)throw new y(e,r,t,o)},L=(e,r,t)=>{if(r.length===0)throw new x(e);if(r.length<t)throw new d(e,t,r.length)};var B=(e={})=>v({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,t,o)=>r.setUint32(0,Number(t),o),get:(r,t)=>r.getUint32(0,t),options:e});function D(e){return typeof e=="object"?e.description:`${e}`}function A(e={}){let r=e.size??B(),t=e.encoding??b,o=e.description??`string(${t.description}; ${D(r)})`;return r==="variable"?{...t,description:o}:typeof r=="number"?w(t,r,o):{description:o,fixedSize:null,maxSize:null,serialize:n=>{let i=t.serialize(n),a=r.serialize(i.length);return S([a,i])},deserialize:(n,i=0)=>{if(n.slice(i).length===0)throw new x("string");let[a,p]=r.deserialize(n,i),l=Number(a);i=p;let c=n.slice(i,i+l);if(c.length<l)throw new d("string",l,c.length);let[f,m]=t.deserialize(c);return i+=m,[f,i]}}}function Je(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=h.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 Qe(e){return A({description:e?.description??"",encoding:h,size:32})}function We(){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 = Je;
|
|
8
|
+
exports.getBase58EncodedAddressCodec = Qe;
|
|
9
|
+
exports.getBase58EncodedAddressComparator = We;
|
|
8
10
|
|
|
9
11
|
return exports;
|
|
10
12
|
|
package/dist/types/base58.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { Serializer } from '@metaplex-foundation/umi-serializers';
|
|
2
|
+
export type Base58EncodedAddress<TAddress extends string = string> = TAddress & {
|
|
2
3
|
readonly __base58EncodedAddress: unique symbol;
|
|
3
4
|
};
|
|
4
|
-
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress
|
|
5
|
+
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
|
|
6
|
+
export declare function getBase58EncodedAddressCodec(config?: Readonly<{
|
|
7
|
+
description: string;
|
|
8
|
+
}>): Serializer<Base58EncodedAddress>;
|
|
9
|
+
export declare function getBase58EncodedAddressComparator(): (x: string, y: string) => number;
|
|
5
10
|
//# sourceMappingURL=base58.d.ts.map
|
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.ca5fcbd",
|
|
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": "^0.8.2"
|
|
50
|
+
},
|
|
48
51
|
"devDependencies": {
|
|
49
|
-
"@solana/eslint-config-solana": "^1.0.
|
|
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.2",
|
|
53
56
|
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
54
57
|
"@typescript-eslint/parser": "^5.57.1",
|
|
55
58
|
"agadoo": "^3.0.0",
|
|
@@ -57,16 +60,15 @@
|
|
|
57
60
|
"eslint-plugin-jest": "^27.1.5",
|
|
58
61
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
59
62
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
60
|
-
"jest": "^29.
|
|
61
|
-
"jest-environment-jsdom": "^29.
|
|
62
|
-
"jest-runner-eslint": "^2.
|
|
63
|
+
"jest": "^29.6.1",
|
|
64
|
+
"jest-environment-jsdom": "^29.6.0",
|
|
65
|
+
"jest-runner-eslint": "^2.1.0",
|
|
63
66
|
"jest-runner-prettier": "^1.0.0",
|
|
64
67
|
"postcss": "^8.4.12",
|
|
65
|
-
"prettier": "^2.
|
|
68
|
+
"prettier": "^2.8.8",
|
|
66
69
|
"ts-node": "^10.9.1",
|
|
67
70
|
"tsup": "6.7.0",
|
|
68
|
-
"
|
|
69
|
-
"typescript": "^5.0.3",
|
|
71
|
+
"typescript": "^5.0.4",
|
|
70
72
|
"version-from-git": "^1.1.1",
|
|
71
73
|
"build-scripts": "0.0.0",
|
|
72
74
|
"test-config": "0.0.0",
|
|
@@ -80,9 +82,6 @@
|
|
|
80
82
|
}
|
|
81
83
|
]
|
|
82
84
|
},
|
|
83
|
-
"dependencies": {
|
|
84
|
-
"bs58": "^5.0.0"
|
|
85
|
-
},
|
|
86
85
|
"scripts": {
|
|
87
86
|
"compile:js": "tsup --config build-scripts/tsup.config.library.ts",
|
|
88
87
|
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/base58.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,sBAAsB,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAE/F,wBAAgB,4BAA4B,CACxC,4BAA4B,EAAE,MAAM,GACrC,OAAO,CAAC,4BAA4B,IAAI,oBAAoB,CAsB9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|