@solana/keys 2.0.0-experimental.dccb97c → 2.0.0-experimental.edfcbdc

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.
Files changed (2) hide show
  1. package/README.md +52 -0
  2. package/package.json +1 -2
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/keys",
3
- "version": "2.0.0-experimental.dccb97c",
3
+ "version": "2.0.0-experimental.edfcbdc",
4
4
  "description": "Helpers for generating and transforming key material",
5
5
  "exports": {
6
6
  "browser": {
@@ -65,7 +65,6 @@
65
65
  "prettier": "^2.7.1",
66
66
  "ts-node": "^10.9.1",
67
67
  "tsup": "6.7.0",
68
- "turbo": "^1.6.3",
69
68
  "typescript": "^5.0.3",
70
69
  "version-from-git": "^1.1.1",
71
70
  "build-scripts": "0.0.0",