@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.
- package/README.md +10 -55
- package/lib/index.browser.esm.js +48 -24
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +101 -56
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +88 -64
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +42 -25
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +27 -45
- package/src/message.ts +9 -12
- package/src/transaction.ts +2 -2
- package/src/util/guarded-array-utils.ts +37 -0
- package/src/validator-info.ts +5 -4
- package/bin/bpf-sdk-install.sh +0 -38
- package/bin/localnet.sh +0 -161
- package/bpf-sdk/LICENSE +0 -13
- package/bpf-sdk/c/README.md +0 -44
- package/bpf-sdk/c/bpf.ld +0 -20
- package/bpf-sdk/c/bpf.mk +0 -249
- package/bpf-sdk/c/inc/deserialize_deprecated.h +0 -115
- package/bpf-sdk/c/inc/solana_sdk.h +0 -669
- package/bpf-sdk/c/inc/stdio.h +0 -4
- package/bpf-sdk/c/inc/stdlib.h +0 -2
- package/bpf-sdk/c/inc/string.h +0 -7
- package/bpf-sdk/c/inc/sys/param.h +0 -1
- package/bpf-sdk/c/inc/wchar.h +0 -1
- package/bpf-sdk/env.sh +0 -39
- package/bpf-sdk/rust/bpf.ld +0 -20
- package/bpf-sdk/rust/build.sh +0 -21
- package/bpf-sdk/rust/clean.sh +0 -17
- package/bpf-sdk/rust/xargo-build.sh +0 -29
- package/bpf-sdk/scripts/dump.sh +0 -45
- package/bpf-sdk/scripts/install.sh +0 -178
- package/bpf-sdk/scripts/objcopy.sh +0 -6
- package/bpf-sdk/scripts/package.sh +0 -19
- package/bpf-sdk/scripts/strip.sh +0 -23
- package/bpf-sdk/version.txt +0 -2
- package/doc/assets/css/main.css +0 -2660
- package/doc/assets/images/icons.png +0 -0
- package/doc/assets/images/icons@2x.png +0 -0
- package/doc/assets/images/widgets.png +0 -0
- package/doc/assets/images/widgets@2x.png +0 -0
- package/doc/assets/js/main.js +0 -248
- package/doc/assets/js/search.js +0 -1
- package/doc/classes/account.html +0 -244
- package/doc/classes/authorized.html +0 -234
- package/doc/classes/bpfloader.html +0 -267
- package/doc/classes/connection.html +0 -2354
- package/doc/classes/loader.html +0 -275
- package/doc/classes/lockup.html +0 -250
- package/doc/classes/message.html +0 -326
- package/doc/classes/nonceaccount.html +0 -233
- package/doc/classes/publickey.html +0 -411
- package/doc/classes/secp256k1program.html +0 -308
- package/doc/classes/stakeinstruction.html +0 -403
- package/doc/classes/stakeprogram.html +0 -503
- package/doc/classes/systeminstruction.html +0 -563
- package/doc/classes/systemprogram.html +0 -503
- package/doc/classes/transaction.html +0 -688
- package/doc/classes/transactioninstruction.html +0 -240
- package/doc/classes/validatorinfo.html +0 -279
- package/doc/classes/voteaccount.html +0 -331
- package/doc/index.html +0 -640
- package/doc/interfaces/feecalculator.html +0 -166
- package/doc/modules.html +0 -4682
- package/examples/README.md +0 -10
- package/examples/account.html +0 -24
- package/examples/account.js +0 -10
- package/examples/bpf-c-noop/.gitignore +0 -1
- package/examples/bpf-c-noop/makefile +0 -1
- package/examples/bpf-c-noop/src/noop/noop.c +0 -19
- package/examples/bpf-rust-noop/.gitignore +0 -3
- package/examples/bpf-rust-noop/Cargo.toml +0 -23
- package/examples/bpf-rust-noop/Xargo.toml +0 -2
- package/examples/bpf-rust-noop/src/lib.rs +0 -70
- package/examples/get-balance.html +0 -37
- package/examples/get-balance.js +0 -18
package/examples/README.md
DELETED
|
@@ -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
|
-
```
|
package/examples/account.html
DELETED
|
@@ -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>
|
package/examples/account.js
DELETED
|
@@ -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, ¶ms, SOL_ARRAY_SIZE(ka))) {
|
|
15
|
-
return ERROR_INVALID_ARGUMENT;
|
|
16
|
-
}
|
|
17
|
-
sol_log_params(¶ms);
|
|
18
|
-
return SUCCESS;
|
|
19
|
-
}
|
|
@@ -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,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>
|
package/examples/get-balance.js
DELETED
|
@@ -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
|
-
});
|