@solana/web3.js 0.98.0 → 1.0.1

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 (81) hide show
  1. package/README.md +10 -55
  2. package/lib/index.browser.esm.js +48 -24
  3. package/lib/index.browser.esm.js.map +1 -1
  4. package/lib/index.cjs.js +101 -56
  5. package/lib/index.cjs.js.map +1 -1
  6. package/lib/index.esm.js +88 -64
  7. package/lib/index.esm.js.map +1 -1
  8. package/lib/index.iife.js +42 -25
  9. package/lib/index.iife.js.map +1 -1
  10. package/lib/index.iife.min.js +2 -2
  11. package/lib/index.iife.min.js.map +1 -1
  12. package/lib/types/index.d.ts.map +1 -1
  13. package/package.json +27 -45
  14. package/src/message.ts +9 -12
  15. package/src/transaction.ts +2 -2
  16. package/src/util/guarded-array-utils.ts +37 -0
  17. package/src/validator-info.ts +5 -4
  18. package/bin/bpf-sdk-install.sh +0 -38
  19. package/bin/localnet.sh +0 -161
  20. package/bpf-sdk/LICENSE +0 -13
  21. package/bpf-sdk/c/README.md +0 -44
  22. package/bpf-sdk/c/bpf.ld +0 -20
  23. package/bpf-sdk/c/bpf.mk +0 -249
  24. package/bpf-sdk/c/inc/deserialize_deprecated.h +0 -115
  25. package/bpf-sdk/c/inc/solana_sdk.h +0 -669
  26. package/bpf-sdk/c/inc/stdio.h +0 -4
  27. package/bpf-sdk/c/inc/stdlib.h +0 -2
  28. package/bpf-sdk/c/inc/string.h +0 -7
  29. package/bpf-sdk/c/inc/sys/param.h +0 -1
  30. package/bpf-sdk/c/inc/wchar.h +0 -1
  31. package/bpf-sdk/env.sh +0 -39
  32. package/bpf-sdk/rust/bpf.ld +0 -20
  33. package/bpf-sdk/rust/build.sh +0 -21
  34. package/bpf-sdk/rust/clean.sh +0 -17
  35. package/bpf-sdk/rust/xargo-build.sh +0 -29
  36. package/bpf-sdk/scripts/dump.sh +0 -45
  37. package/bpf-sdk/scripts/install.sh +0 -178
  38. package/bpf-sdk/scripts/objcopy.sh +0 -6
  39. package/bpf-sdk/scripts/package.sh +0 -19
  40. package/bpf-sdk/scripts/strip.sh +0 -23
  41. package/bpf-sdk/version.txt +0 -2
  42. package/doc/assets/css/main.css +0 -2660
  43. package/doc/assets/images/icons.png +0 -0
  44. package/doc/assets/images/icons@2x.png +0 -0
  45. package/doc/assets/images/widgets.png +0 -0
  46. package/doc/assets/images/widgets@2x.png +0 -0
  47. package/doc/assets/js/main.js +0 -248
  48. package/doc/assets/js/search.js +0 -1
  49. package/doc/classes/account.html +0 -244
  50. package/doc/classes/authorized.html +0 -234
  51. package/doc/classes/bpfloader.html +0 -267
  52. package/doc/classes/connection.html +0 -2354
  53. package/doc/classes/loader.html +0 -275
  54. package/doc/classes/lockup.html +0 -250
  55. package/doc/classes/message.html +0 -326
  56. package/doc/classes/nonceaccount.html +0 -233
  57. package/doc/classes/publickey.html +0 -411
  58. package/doc/classes/secp256k1program.html +0 -308
  59. package/doc/classes/stakeinstruction.html +0 -403
  60. package/doc/classes/stakeprogram.html +0 -503
  61. package/doc/classes/systeminstruction.html +0 -563
  62. package/doc/classes/systemprogram.html +0 -503
  63. package/doc/classes/transaction.html +0 -688
  64. package/doc/classes/transactioninstruction.html +0 -240
  65. package/doc/classes/validatorinfo.html +0 -279
  66. package/doc/classes/voteaccount.html +0 -331
  67. package/doc/index.html +0 -640
  68. package/doc/interfaces/feecalculator.html +0 -166
  69. package/doc/modules.html +0 -4682
  70. package/examples/README.md +0 -10
  71. package/examples/account.html +0 -24
  72. package/examples/account.js +0 -10
  73. package/examples/bpf-c-noop/.gitignore +0 -1
  74. package/examples/bpf-c-noop/makefile +0 -1
  75. package/examples/bpf-c-noop/src/noop/noop.c +0 -19
  76. package/examples/bpf-rust-noop/.gitignore +0 -3
  77. package/examples/bpf-rust-noop/Cargo.toml +0 -23
  78. package/examples/bpf-rust-noop/Xargo.toml +0 -2
  79. package/examples/bpf-rust-noop/src/lib.rs +0 -70
  80. package/examples/get-balance.html +0 -37
  81. package/examples/get-balance.js +0 -18
@@ -1,10 +0,0 @@
1
- ## Examples
2
- Before trying any of the examples in this directory please populate the `lib/`
3
- directory by running `npm install`.
4
-
5
- Additionally most of the examples attempt to connect to a local cluster. Start
6
- your local cluster first by running:
7
- ```bash
8
- $ npx solana-localnet update
9
- $ npx solana-localnet up
10
- ```
@@ -1,24 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Create a new account</title>
5
- </head>
6
- <body>
7
- <b>Account Public Key:</b>
8
- <div id="accountPublicKey">?</div>
9
-
10
- <script src="../lib/index.iife.js"></script>
11
- <!--
12
- <script src="https://github.com/solana-labs/solana-web3.js/releases/download/v0.11.10/solanaWeb3.min.js"></script>
13
- -->
14
-
15
- <script>
16
- // Create a new account
17
- const account = new solanaWeb3.Account();
18
-
19
- // Display the account's public key
20
- const accountPublicKey = document.getElementById('accountPublicKey');
21
- accountPublicKey.innerHTML = account.publicKey;
22
- </script>
23
- </body>
24
- </html>
@@ -1,10 +0,0 @@
1
- /*
2
- Create a new account
3
- */
4
-
5
- //eslint-disable-next-line import/no-commonjs
6
- const solanaWeb3 = require('..');
7
- //const solanaWeb3 = require('@solana/web3.js');
8
-
9
- const account = new solanaWeb3.Account();
10
- console.log(account.publicKey.toString());
@@ -1 +0,0 @@
1
- /out/
@@ -1 +0,0 @@
1
- include ../../bpf-sdk/c/bpf.mk
@@ -1,19 +0,0 @@
1
- /**
2
- * @brief Example C-based BPF program that prints out the parameters
3
- * passed to it
4
- */
5
-
6
- #include <solana_sdk.h>
7
-
8
- extern uint64_t entrypoint(const uint8_t *input) {
9
- SolAccountInfo ka[1];
10
- SolParameters params = (SolParameters) { .ka = ka };
11
-
12
- sol_log("Hello World");
13
-
14
- if (!sol_deserialize(input, &params, SOL_ARRAY_SIZE(ka))) {
15
- return ERROR_INVALID_ARGUMENT;
16
- }
17
- sol_log_params(&params);
18
- return SUCCESS;
19
- }
@@ -1,3 +0,0 @@
1
- /target/
2
-
3
- Cargo.lock
@@ -1,23 +0,0 @@
1
- [package]
2
- name = "solana-bpf-rust-noop"
3
- version = "0.1.0"
4
- description = "Solana BPF noop program written in Rust"
5
- authors = ["Solana Maintainers <maintainers@solana.com>"]
6
- repository = "https://github.com/solana-labs/solana"
7
- license = "Apache-2.0"
8
- homepage = "https://solana.com/"
9
- documentation = "https://docs.rs/solana-bpf-rust-noop"
10
- edition = "2018"
11
-
12
- [dependencies]
13
- num-derive = "0.2"
14
- num-traits = "0.2"
15
- solana-program = "1.4.16"
16
- thiserror = "1.0"
17
-
18
- [workspace]
19
- members = []
20
-
21
- [lib]
22
- name = "solana_bpf_rust_noop"
23
- crate-type = ["cdylib"]
@@ -1,2 +0,0 @@
1
- [target.bpfel-unknown-unknown.dependencies.std]
2
- features = []
@@ -1,70 +0,0 @@
1
- //! @brief Example Rust-based BPF program that prints out the parameters passed to it
2
-
3
-
4
- use solana_program::{
5
- account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, log::*, pubkey::Pubkey,
6
- };
7
-
8
- #[derive(Debug, PartialEq)]
9
- struct SStruct {
10
- x: u64,
11
- y: u64,
12
- z: u64,
13
- }
14
-
15
- #[inline(never)]
16
- fn return_sstruct() -> SStruct {
17
- SStruct { x: 1, y: 2, z: 3 }
18
- }
19
-
20
- entrypoint!(process_instruction);
21
- fn process_instruction(
22
- program_id: &Pubkey,
23
- accounts: &[AccountInfo],
24
- instruction_data: &[u8],
25
- ) -> ProgramResult {
26
- msg!("Program identifier:");
27
- program_id.log();
28
-
29
- // Log the provided account keys and instruction input data. In the case of
30
- // the no-op program, no account keys or input data are expected but real
31
- // programs will have specific requirements so they can do their work.
32
- msg!("Account keys and instruction input data:");
33
- sol_log_params(accounts, instruction_data);
34
-
35
- {
36
- // Test - use std methods, unwrap
37
-
38
- // valid bytes, in a stack-allocated array
39
- let sparkle_heart = [240, 159, 146, 150];
40
- let result_str = std::str::from_utf8(&sparkle_heart).unwrap();
41
- assert_eq!(4, result_str.len());
42
- assert_eq!("💖", result_str);
43
- msg!(result_str);
44
- }
45
-
46
- {
47
- // Test - struct return
48
-
49
- let s = return_sstruct();
50
- assert_eq!(s.x + s.y + s.z, 6);
51
- }
52
-
53
- {
54
- // Test - arch config
55
- #[cfg(not(target_arch = "bpf"))]
56
- panic!();
57
- }
58
-
59
- Ok(())
60
- }
61
-
62
- #[cfg(test)]
63
- mod test {
64
- use super::*;
65
-
66
- #[test]
67
- fn test_return_sstruct() {
68
- assert_eq!(SStruct { x: 1, y: 2, z: 3 }, return_sstruct());
69
- }
70
- }
@@ -1,37 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Get account balance</title>
5
- </head>
6
- <body>
7
- <b>Account</b>
8
- <div id="accountPublicKey">?</div>
9
- has a balance of
10
- <div id="accountBalance">?</div>
11
-
12
- <script src="../lib/index.iife.js"></script>
13
- <!--
14
- <script src="https://github.com/solana-labs/solana-web3.js/releases/download/v0.11.10/solanaWeb3.min.js"></script>
15
- -->
16
-
17
- <script>
18
- // Create a new account
19
- const account = new solanaWeb3.Account();
20
-
21
- // Display the account's public key
22
- const accountPublicKey = document.getElementById('accountPublicKey');
23
- accountPublicKey.innerHTML = account.publicKey;
24
-
25
- // Fetch account balance
26
- let url = 'http://localhost:8899';
27
- const connection = new solanaWeb3.Connection(url);
28
-
29
- connection.getBalance(account.publicKey)
30
- .then((balance) => {
31
- const accountBalance = document.getElementById('accountBalance');
32
- accountBalance.innerHTML = balance;
33
- console.log(`${account.publicKey} has a balance of ${balance}`);
34
- });
35
- </script>
36
- </body>
37
- </html>
@@ -1,18 +0,0 @@
1
- /*
2
- Fetch the balance of an account
3
- */
4
-
5
- //eslint-disable-next-line import/no-commonjs
6
- const solanaWeb3 = require('..');
7
- //const solanaWeb3 = require('@solana/web3.js');
8
-
9
- const account = new solanaWeb3.Account();
10
-
11
- let url;
12
- url = 'http://devnet.solana.com';
13
- //url = 'http://localhost:8899';
14
- const connection = new solanaWeb3.Connection(url);
15
-
16
- connection.getBalance(account.publicKey).then(balance => {
17
- console.log(`${account.publicKey} has a balance of ${balance}`);
18
- });