fix: remove deprecated bpf-sdk, localnet, and examples
BREAKING CHANGE: Removed binaries solana-localnet and solana-bpf-sdk-install. Please install the Solana CLI tools to download the BPF SDK and to install the solana-test-validator binary intead.
This commit is contained in:
		
				
					committed by
					
						
						Justin Starry
					
				
			
			
				
	
			
			
			
						parent
						
							f46f346710
						
					
				
				
					commit
					e9b08b5e7f
				
			
							
								
								
									
										7
									
								
								web3.js/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								web3.js/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -22,13 +22,6 @@ doc
 | 
			
		||||
# VIM swap files
 | 
			
		||||
*.sw*
 | 
			
		||||
 | 
			
		||||
# bpf-sdk
 | 
			
		||||
/bpf-sdk
 | 
			
		||||
/bpf-sdk.tar.bz2
 | 
			
		||||
 | 
			
		||||
# fixtures
 | 
			
		||||
/test/fixtures
 | 
			
		||||
 | 
			
		||||
# `solana-test-validator` ledger location
 | 
			
		||||
test-ledger/
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								web3.js/.releaserc.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								web3.js/.releaserc.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
    "repositoryUrl": "git@github.com:solana-labs/solana-web3.js.git",
 | 
			
		||||
    "preset": "conventionalcommits",
 | 
			
		||||
    "presetConfig": {
 | 
			
		||||
        "issueUrlFormat": "{{host}}/{{owner}}/solana/issues/{{id}}"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -9,10 +9,6 @@ sudo apt-get install -y libssl-dev --allow-unauthenticated
 | 
			
		||||
sudo apt-get install -y libssl1.1 --allow-unauthenticated
 | 
			
		||||
clang-7 --version
 | 
			
		||||
 | 
			
		||||
curl https://sh.rustup.rs -sSf | sh -s -- -y
 | 
			
		||||
PATH=$HOME/.cargo/bin:$PATH
 | 
			
		||||
rustup --version
 | 
			
		||||
 | 
			
		||||
sh -c "$(curl -sSfL https://release.solana.com/edge/install)"
 | 
			
		||||
PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
 | 
			
		||||
solana --version
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,5 @@ test -r lib/index.esm.js
 | 
			
		||||
npm run doc
 | 
			
		||||
npm run lint
 | 
			
		||||
npm run codecov
 | 
			
		||||
make -C examples/bpf-c-noop/
 | 
			
		||||
cargo build-bpf --manifest-path examples/bpf-rust-noop/Cargo.toml
 | 
			
		||||
npm run test:live-with-test-validator
 | 
			
		||||
npm run test:browser-with-test-validator
 | 
			
		||||
 
 | 
			
		||||
@@ -47,11 +47,17 @@ $ npm install --save @solana/web3.js
 | 
			
		||||
<script src="https://unpkg.com/@solana/web3.js@0.92.0/lib/index.iife.min.js"></script>
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Development Environment Setup
 | 
			
		||||
 | 
			
		||||
### Development Environment Setup
 | 
			
		||||
To build and run tests:
 | 
			
		||||
1. Install Rust from https://rustup.rs/
 | 
			
		||||
2. Install the latest Solana release from https://docs.solana.com/cli/install-solana-cli-tools
 | 
			
		||||
Install the latest Solana release from https://docs.solana.com/cli/install-solana-cli-tools
 | 
			
		||||
 | 
			
		||||
### Run test validator
 | 
			
		||||
 | 
			
		||||
**Use `solana-test-validator` from the latest Solana release**
 | 
			
		||||
 | 
			
		||||
### BPF program development
 | 
			
		||||
 | 
			
		||||
**Use `cargo build-bpf` from the latest Solana release**
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
@@ -84,14 +90,6 @@ activate it:
 | 
			
		||||
node_modules/@solana/web3.js/module.flow.js
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
See the [examples/](https://github.com/solana-labs/solana-web3.js/tree/master/examples) directory for small snippets.
 | 
			
		||||
 | 
			
		||||
Standalone examples:
 | 
			
		||||
* Message feed (BPF Rust and C): https://github.com/solana-labs/example-messagefeed
 | 
			
		||||
* Tic-tac-toe (BPF C): https://github.com/solana-labs/example-tictactoe
 | 
			
		||||
* Web wallet: https://github.com/solana-labs/example-webwallet
 | 
			
		||||
 | 
			
		||||
## Releases
 | 
			
		||||
Releases are available on [Github](https://github.com/solana-labs/solana-web3.js/releases)
 | 
			
		||||
and [npmjs.com](https://www.npmjs.com/package/@solana/web3.js)
 | 
			
		||||
@@ -99,46 +97,3 @@ and [npmjs.com](https://www.npmjs.com/package/@solana/web3.js)
 | 
			
		||||
Each Github release features a tarball containing API documentation and a
 | 
			
		||||
minified version of the module suitable for direct use in a browser environment
 | 
			
		||||
(<script> tag)
 | 
			
		||||
 | 
			
		||||
## Deprecated
 | 
			
		||||
 | 
			
		||||
### Local Network
 | 
			
		||||
 | 
			
		||||
**Please use `solana-test-validator` from the latest Solana release instead of the information in this section**
 | 
			
		||||
 | 
			
		||||
The `solana-localnet` program is provided to easily start a test Solana cluster
 | 
			
		||||
locally on your machine.  Docker must be installed.  The JSON RPC endpoint of
 | 
			
		||||
the local cluster is `http://localhost:8899`.
 | 
			
		||||
 | 
			
		||||
To start, first fetch the latest Docker image by running:
 | 
			
		||||
```bash
 | 
			
		||||
$ npx solana-localnet update
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Then run the following command to start the cluster
 | 
			
		||||
```bash
 | 
			
		||||
$ npx solana-localnet up
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
While the cluster is running logs are available with:
 | 
			
		||||
```bash
 | 
			
		||||
$ npx solana-localnet logs -f
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Stop the cluster with:
 | 
			
		||||
```bash
 | 
			
		||||
$ npx solana-localnet down
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### BPF program development
 | 
			
		||||
 | 
			
		||||
**Please use `cargo build-bpf` from the latest Solana release instead of the information in this section**
 | 
			
		||||
 | 
			
		||||
The Solana BPF SDK is located in the `bpf-sdk/` subdirectory if you installed
 | 
			
		||||
solana-web3.js from npmjs.com.
 | 
			
		||||
 | 
			
		||||
From a git clone, run `npm run bpf-sdk:install` to fetch the latest BPF SDK.
 | 
			
		||||
 | 
			
		||||
Additionally Rust must be installed to build Rust BPF programs such as
 | 
			
		||||
`examples/bpf-rust-noop/`.  See https://www.rust-lang.org/install.html for
 | 
			
		||||
installation details.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,38 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
installDir=$1
 | 
			
		||||
if [[ -z $installDir ]]; then
 | 
			
		||||
  installDir="$(cd "$(dirname "$0")"/..; pwd)"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
channel=$(
 | 
			
		||||
  cd "$(dirname "$0")";
 | 
			
		||||
  node -p '
 | 
			
		||||
    let p = [
 | 
			
		||||
      "../../package.json",
 | 
			
		||||
      "../lib/node_modules/@solana/web3.js/package.json",
 | 
			
		||||
      "../@solana/web3.js/package.json",
 | 
			
		||||
      "../package.json"
 | 
			
		||||
    ].find(require("fs").existsSync);
 | 
			
		||||
    if (!p) throw new Error("Unable to locate package.json");
 | 
			
		||||
    require(p)["testnetDefaultChannel"]
 | 
			
		||||
  '
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if [[ -n $2 ]]; then
 | 
			
		||||
  channel=$2
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "Installing $channel BPF SDK into $installDir"
 | 
			
		||||
 | 
			
		||||
set -x
 | 
			
		||||
cd "$installDir/"
 | 
			
		||||
curl -L  --retry 5 --retry-delay 2 -o bpf-sdk.tar.bz2 \
 | 
			
		||||
  https://solana-sdk.s3.amazonaws.com/"$channel"/bpf-sdk.tar.bz2
 | 
			
		||||
rm -rf bpf-sdk
 | 
			
		||||
mkdir -p bpf-sdk
 | 
			
		||||
tar jxf bpf-sdk.tar.bz2
 | 
			
		||||
rm -f bpf-sdk.tar.bz2
 | 
			
		||||
 | 
			
		||||
cat bpf-sdk/version.txt
 | 
			
		||||
@@ -1,161 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
channel=$(
 | 
			
		||||
  cd "$(dirname "$0")";
 | 
			
		||||
  node -p '
 | 
			
		||||
    let p = [
 | 
			
		||||
      "../../package.json",
 | 
			
		||||
      "../lib/node_modules/@solana/web3.js/package.json",
 | 
			
		||||
      "../@solana/web3.js/package.json",
 | 
			
		||||
      "../package.json"
 | 
			
		||||
    ].find(require("fs").existsSync);
 | 
			
		||||
    if (!p) throw new Error("Unable to locate package.json");
 | 
			
		||||
    require(p)["testnetDefaultChannel"]
 | 
			
		||||
  '
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
  exitcode=0
 | 
			
		||||
  if [[ -n "$1" ]]; then
 | 
			
		||||
    exitcode=1
 | 
			
		||||
    echo "Error: $*"
 | 
			
		||||
  fi
 | 
			
		||||
  cat <<EOF
 | 
			
		||||
usage: $0 [update|up|down|logs] [command-specific options]
 | 
			
		||||
 | 
			
		||||
Operate a local testnet
 | 
			
		||||
 | 
			
		||||
 update   - Update the image from dockerhub.com
 | 
			
		||||
 up       - Start the cluster
 | 
			
		||||
 down     - Stop the cluster
 | 
			
		||||
 logs     - Display cluster logging
 | 
			
		||||
 | 
			
		||||
 logs-specific options:
 | 
			
		||||
   -f    - Follow log output
 | 
			
		||||
 | 
			
		||||
 update-specific options:
 | 
			
		||||
   <tag> - Optional Docker image tag to use
 | 
			
		||||
 | 
			
		||||
 up-specific options:
 | 
			
		||||
   <tag> - Optional Docker image tag to use
 | 
			
		||||
   -n    - Optional Docker network to join
 | 
			
		||||
 | 
			
		||||
   Default channel: $channel
 | 
			
		||||
 | 
			
		||||
 down-specific options:
 | 
			
		||||
   none
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
  exit $exitcode
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[[ -n $1 ]] || usage
 | 
			
		||||
cmd="$1"
 | 
			
		||||
shift
 | 
			
		||||
 | 
			
		||||
docker --version || usage "It appears that docker is not installed"
 | 
			
		||||
case $cmd in
 | 
			
		||||
update)
 | 
			
		||||
  if [[ -n $1 ]]; then
 | 
			
		||||
    channel="$1"
 | 
			
		||||
  fi
 | 
			
		||||
  (
 | 
			
		||||
    set -x
 | 
			
		||||
    docker pull solanalabs/solana:"$channel"
 | 
			
		||||
  )
 | 
			
		||||
  ;;
 | 
			
		||||
up)
 | 
			
		||||
  while [[ -n $1 ]]; do
 | 
			
		||||
    if [[ $1 = -n ]]; then
 | 
			
		||||
      [[ -n $2 ]] || usage "Invalid $1 argument"
 | 
			
		||||
      network="$2"
 | 
			
		||||
      shift 2
 | 
			
		||||
    else
 | 
			
		||||
      channel=$1
 | 
			
		||||
      shift 1
 | 
			
		||||
    fi
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
  (
 | 
			
		||||
    set -x
 | 
			
		||||
    RUST_LOG=${RUST_LOG:-solana=info,solana_runtime::message_processor=debug}
 | 
			
		||||
    ARGS=(
 | 
			
		||||
      --detach
 | 
			
		||||
      --name solana-localnet
 | 
			
		||||
      --rm
 | 
			
		||||
      --publish 8001:8001/tcp # entrypoint
 | 
			
		||||
      --publish 8899:8899/tcp # rpc http
 | 
			
		||||
      --publish 8900:8900/tcp # rpc pubsub
 | 
			
		||||
      --publish 8901:8901/tcp # (future) bank service
 | 
			
		||||
      --publish 8902:8902/tcp # bank service
 | 
			
		||||
      --publish 9900:9900/tcp # faucet
 | 
			
		||||
      --publish 8000:8000/udp # tvu
 | 
			
		||||
      --publish 8001:8001/udp # gossip
 | 
			
		||||
      --publish 8002:8002/udp # tvu_forwards
 | 
			
		||||
      --publish 8003:8003/udp # tpu
 | 
			
		||||
      --publish 8004:8004/udp # tpu_forwards
 | 
			
		||||
      --publish 8005:8005/udp # retransmit
 | 
			
		||||
      --publish 8006:8006/udp # repair
 | 
			
		||||
      --publish 8007:8007/udp # serve_repair
 | 
			
		||||
      --publish 8008:8008/udp # broadcast
 | 
			
		||||
      --tty
 | 
			
		||||
      --ulimit "nofile=700000"
 | 
			
		||||
      --env "RUST_LOG=$RUST_LOG"
 | 
			
		||||
    )
 | 
			
		||||
    if [[ -n $network ]]; then
 | 
			
		||||
      ARGS+=(--network "$network")
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    docker run "${ARGS[@]}" solanalabs/solana:"$channel"
 | 
			
		||||
 | 
			
		||||
    for _ in 1 2 3 4 5; do
 | 
			
		||||
      if curl \
 | 
			
		||||
          -X POST \
 | 
			
		||||
          -H "Content-Type: application/json" \
 | 
			
		||||
          -d '{"jsonrpc":"2.0","id":1, "method":"getTransactionCount"}' \
 | 
			
		||||
          http://localhost:8899; then
 | 
			
		||||
        break;
 | 
			
		||||
      fi
 | 
			
		||||
      sleep 1
 | 
			
		||||
    done
 | 
			
		||||
  )
 | 
			
		||||
  ;;
 | 
			
		||||
down)
 | 
			
		||||
  (
 | 
			
		||||
    set -x
 | 
			
		||||
    if [[ $(docker ps --filter "name=^/solana-localnet$" -q) ]]; then
 | 
			
		||||
      docker stop --time 0 solana-localnet
 | 
			
		||||
    fi
 | 
			
		||||
  )
 | 
			
		||||
  ;;
 | 
			
		||||
logs)
 | 
			
		||||
  follow=false
 | 
			
		||||
  if [[ -n $1 ]]; then
 | 
			
		||||
    if [[ $1 = "-f" ]]; then
 | 
			
		||||
      follow=true
 | 
			
		||||
    else
 | 
			
		||||
      usage "Unknown argument: $1"
 | 
			
		||||
    fi
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  while $follow; do
 | 
			
		||||
    if [[ $(docker ps -q -f "name=^/solana-localnet$") ]]; then
 | 
			
		||||
      (
 | 
			
		||||
        set -x
 | 
			
		||||
        docker logs solana-localnet -f
 | 
			
		||||
      ) || true
 | 
			
		||||
    fi
 | 
			
		||||
    sleep 1
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
  (
 | 
			
		||||
    set -x
 | 
			
		||||
    docker logs solana-localnet
 | 
			
		||||
  )
 | 
			
		||||
  ;;
 | 
			
		||||
*)
 | 
			
		||||
  usage "Unknown command: $cmd"
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
exit 0
 | 
			
		||||
@@ -1,10 +0,0 @@
 | 
			
		||||
## Examples
 | 
			
		||||
Before trying any of the examples in this directory please populate the `lib/`
 | 
			
		||||
directory by running `npm install`.
 | 
			
		||||
 | 
			
		||||
Additionally most of the examples attempt to connect to a local cluster.  Start
 | 
			
		||||
your local cluster first by running:
 | 
			
		||||
```bash
 | 
			
		||||
$ npx solana-localnet update
 | 
			
		||||
$ npx solana-localnet up
 | 
			
		||||
```
 | 
			
		||||
@@ -1,24 +0,0 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
  <title>Create a new account</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <b>Account Public Key:</b>
 | 
			
		||||
  <div id="accountPublicKey">?</div>
 | 
			
		||||
 | 
			
		||||
  <script src="../lib/index.iife.js"></script>
 | 
			
		||||
  <!--
 | 
			
		||||
    <script src="https://github.com/solana-labs/solana-web3.js/releases/download/v0.11.10/solanaWeb3.min.js"></script>
 | 
			
		||||
  -->
 | 
			
		||||
 | 
			
		||||
  <script>
 | 
			
		||||
    // Create a new account
 | 
			
		||||
    const account = new solanaWeb3.Account();
 | 
			
		||||
 | 
			
		||||
    // Display the account's public key
 | 
			
		||||
    const accountPublicKey = document.getElementById('accountPublicKey');
 | 
			
		||||
    accountPublicKey.innerHTML = account.publicKey;
 | 
			
		||||
  </script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
@@ -1,10 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 Create a new account
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
//eslint-disable-next-line import/no-commonjs
 | 
			
		||||
const solanaWeb3 = require('..');
 | 
			
		||||
//const solanaWeb3 = require('@solana/web3.js');
 | 
			
		||||
 | 
			
		||||
const account = new solanaWeb3.Account();
 | 
			
		||||
console.log(account.publicKey.toString());
 | 
			
		||||
							
								
								
									
										1
									
								
								web3.js/examples/bpf-c-noop/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								web3.js/examples/bpf-c-noop/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1 +0,0 @@
 | 
			
		||||
/out/
 | 
			
		||||
@@ -1 +0,0 @@
 | 
			
		||||
include ../../bpf-sdk/c/bpf.mk
 | 
			
		||||
@@ -1,19 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Example C-based BPF program that prints out the parameters
 | 
			
		||||
 * passed to it
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <solana_sdk.h>
 | 
			
		||||
 | 
			
		||||
extern uint64_t entrypoint(const uint8_t *input) {
 | 
			
		||||
  SolAccountInfo ka[1];
 | 
			
		||||
  SolParameters params = (SolParameters) { .ka = ka };
 | 
			
		||||
 | 
			
		||||
  sol_log("Hello World");
 | 
			
		||||
 | 
			
		||||
  if (!sol_deserialize(input, ¶ms, SOL_ARRAY_SIZE(ka))) {
 | 
			
		||||
    return ERROR_INVALID_ARGUMENT;
 | 
			
		||||
  }
 | 
			
		||||
  sol_log_params(¶ms);
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
  <title>Get account balance</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <b>Account</b>
 | 
			
		||||
  <div id="accountPublicKey">?</div>
 | 
			
		||||
  has a balance of
 | 
			
		||||
  <div id="accountBalance">?</div>
 | 
			
		||||
 | 
			
		||||
  <script src="../lib/index.iife.js"></script>
 | 
			
		||||
  <!--
 | 
			
		||||
    <script src="https://github.com/solana-labs/solana-web3.js/releases/download/v0.11.10/solanaWeb3.min.js"></script>
 | 
			
		||||
  -->
 | 
			
		||||
 | 
			
		||||
  <script>
 | 
			
		||||
    // Create a new account
 | 
			
		||||
    const account = new solanaWeb3.Account();
 | 
			
		||||
 | 
			
		||||
    // Display the account's public key
 | 
			
		||||
    const accountPublicKey = document.getElementById('accountPublicKey');
 | 
			
		||||
    accountPublicKey.innerHTML = account.publicKey;
 | 
			
		||||
 | 
			
		||||
    // Fetch account balance
 | 
			
		||||
    let url = 'http://localhost:8899';
 | 
			
		||||
    const connection = new solanaWeb3.Connection(url);
 | 
			
		||||
 | 
			
		||||
    connection.getBalance(account.publicKey)
 | 
			
		||||
    .then((balance) => {
 | 
			
		||||
      const accountBalance = document.getElementById('accountBalance');
 | 
			
		||||
      accountBalance.innerHTML = balance;
 | 
			
		||||
      console.log(`${account.publicKey} has a balance of ${balance}`);
 | 
			
		||||
    });
 | 
			
		||||
  </script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 Fetch the balance of an account
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
//eslint-disable-next-line import/no-commonjs
 | 
			
		||||
const solanaWeb3 = require('..');
 | 
			
		||||
//const solanaWeb3 = require('@solana/web3.js');
 | 
			
		||||
 | 
			
		||||
const account = new solanaWeb3.Account();
 | 
			
		||||
 | 
			
		||||
let url;
 | 
			
		||||
url = 'http://devnet.solana.com';
 | 
			
		||||
//url = 'http://localhost:8899';
 | 
			
		||||
const connection = new solanaWeb3.Connection(url);
 | 
			
		||||
 | 
			
		||||
connection.getBalance(account.publicKey).then(balance => {
 | 
			
		||||
  console.log(`${account.publicKey} has a balance of ${balance}`);
 | 
			
		||||
});
 | 
			
		||||
@@ -31,48 +31,31 @@
 | 
			
		||||
    "not IE 11",
 | 
			
		||||
    "maintained node versions"
 | 
			
		||||
  ],
 | 
			
		||||
  "bin": {
 | 
			
		||||
    "solana-bpf-sdk-install": "bin/bpf-sdk-install.sh",
 | 
			
		||||
    "solana-localnet": "bin/localnet.sh"
 | 
			
		||||
  },
 | 
			
		||||
  "testnetDefaultChannel": "edge",
 | 
			
		||||
  "files": [
 | 
			
		||||
    "/bin",
 | 
			
		||||
    "/doc",
 | 
			
		||||
    "/examples",
 | 
			
		||||
    "/bpf-sdk",
 | 
			
		||||
    "/lib",
 | 
			
		||||
    "/module.flow.js",
 | 
			
		||||
    "/src"
 | 
			
		||||
  ],
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "bpf-sdk:install": "npm run clean:fixtures; bin/bpf-sdk-install.sh .",
 | 
			
		||||
    "bpf-sdk:remove-symlinks": "find bpf-sdk -type l -print -exec cp {} {}.tmp \\; -exec mv {}.tmp {} \\;",
 | 
			
		||||
    "build": "cross-env NODE_ENV=production rollup -c; npx flowgen lib/types/index.d.ts -o module.flow.js",
 | 
			
		||||
    "build:browser-test": "rollup -c test/rollup.config.js",
 | 
			
		||||
    "build:fixtures": "set -ex; ./test/fixtures/noop-c/build.sh; ./test/fixtures/noop-rust/build.sh",
 | 
			
		||||
    "clean:fixtures": "make -C examples/bpf-c-noop clean ",
 | 
			
		||||
    "build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
 | 
			
		||||
    "clean": "rimraf ./coverage ./lib",
 | 
			
		||||
    "codecov": "set -ex; npm run test:cover; cat ./coverage/lcov.info | codecov",
 | 
			
		||||
    "dev": "cross-env NODE_ENV=development rollup -c",
 | 
			
		||||
    "doc": "set -ex; typedoc",
 | 
			
		||||
    "doc:watch": "watch 'npm run doc' . --wait=1 --ignoreDirectoryPattern=/doc/",
 | 
			
		||||
    "examples": "set -ex; for example in examples/*.js; do node $example; done",
 | 
			
		||||
    "lint": "set -ex; npm run pretty; eslint . --ext .js,.ts",
 | 
			
		||||
    "lint:fix": "npm run pretty:fix && eslint . --fix",
 | 
			
		||||
    "lint:watch": "watch 'npm run lint:fix' . --wait=1 --ignoreDirectoryPattern=/doc/",
 | 
			
		||||
    "localnet:down": "bin/localnet.sh down",
 | 
			
		||||
    "localnet:logs": "bin/localnet.sh logs -f",
 | 
			
		||||
    "localnet:up": "bin/localnet.sh up",
 | 
			
		||||
    "localnet:update": "bin/localnet.sh update",
 | 
			
		||||
    "ok": "run-s lint test doc",
 | 
			
		||||
    "prepare": "run-s clean bpf-sdk:install bpf-sdk:remove-symlinks build",
 | 
			
		||||
    "pretty": "prettier --check '{,{examples,src,test}/**/}*.{j,t}s'",
 | 
			
		||||
    "pretty:fix": "prettier --write '{,{examples,src,test}/**/}*.{j,t}s'",
 | 
			
		||||
    "prepare": "run-s clean build",
 | 
			
		||||
    "pretty": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
 | 
			
		||||
    "pretty:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
 | 
			
		||||
    "re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
 | 
			
		||||
    "test": "npm run build:fixtures && mocha -r ts-node/register './test/**/*.test.ts'",
 | 
			
		||||
    "test": "mocha -r ts-node/register './test/**/*.test.ts'",
 | 
			
		||||
    "test:cover": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' nyc --reporter=lcov mocha -r ts-node/register './test/**/*.test.ts'",
 | 
			
		||||
    "test:browser": "TEST_LIVE=1 npm run build:fixtures && npm run build:browser-test && mocha-headless-chrome -f http://localhost:8080/mocha.html --timeout 180000",
 | 
			
		||||
    "test:browser": "TEST_LIVE=1 npm run build:browser-test && mocha-headless-chrome -f http://localhost:8080/mocha.html --timeout 180000",
 | 
			
		||||
    "test:browser-with-server": "start-server-and-test 'http-server -p 8080' 8080 test:browser",
 | 
			
		||||
    "test:browser-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:browser-with-server",
 | 
			
		||||
    "test:live": "TEST_LIVE=1 npm run test",
 | 
			
		||||
 
 | 
			
		||||
@@ -17,52 +17,7 @@ use(chaiAsPromised);
 | 
			
		||||
 | 
			
		||||
if (process.env.TEST_LIVE) {
 | 
			
		||||
  describe('BPF Loader', () => {
 | 
			
		||||
    it('load BPF C program', async () => {
 | 
			
		||||
      const data = await fs.readFile('test/fixtures/noop-c/noop.so');
 | 
			
		||||
 | 
			
		||||
      const connection = new Connection(url, 'confirmed');
 | 
			
		||||
      const {feeCalculator} = await connection.getRecentBlockhash();
 | 
			
		||||
      const fees =
 | 
			
		||||
        feeCalculator.lamportsPerSignature *
 | 
			
		||||
        BpfLoader.getMinNumSignatures(data.length);
 | 
			
		||||
      const payerBalance = await connection.getMinimumBalanceForRentExemption(
 | 
			
		||||
        0,
 | 
			
		||||
      );
 | 
			
		||||
      const executableBalance = await connection.getMinimumBalanceForRentExemption(
 | 
			
		||||
        data.length,
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      const from = new Account();
 | 
			
		||||
      await helpers.airdrop({
 | 
			
		||||
        connection,
 | 
			
		||||
        address: from.publicKey,
 | 
			
		||||
        amount: payerBalance + fees + executableBalance,
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      const program = new Account();
 | 
			
		||||
      await BpfLoader.load(
 | 
			
		||||
        connection,
 | 
			
		||||
        from,
 | 
			
		||||
        program,
 | 
			
		||||
        data,
 | 
			
		||||
        BPF_LOADER_PROGRAM_ID,
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // Check that program loading costed exactly `fees + executableBalance`
 | 
			
		||||
      const fromBalance = await connection.getBalance(from.publicKey);
 | 
			
		||||
      expect(fromBalance).to.eq(payerBalance);
 | 
			
		||||
 | 
			
		||||
      const transaction = new Transaction().add({
 | 
			
		||||
        keys: [{pubkey: from.publicKey, isSigner: true, isWritable: true}],
 | 
			
		||||
        programId: program.publicKey,
 | 
			
		||||
      });
 | 
			
		||||
      await sendAndConfirmTransaction(connection, transaction, [from], {
 | 
			
		||||
        commitment: 'confirmed',
 | 
			
		||||
        preflightCommitment: 'confirmed',
 | 
			
		||||
      });
 | 
			
		||||
    }).timeout(5000);
 | 
			
		||||
 | 
			
		||||
    describe('load BPF Rust program', () => {
 | 
			
		||||
    describe('load BPF program', () => {
 | 
			
		||||
      const connection = new Connection(url, 'confirmed');
 | 
			
		||||
 | 
			
		||||
      let program = new Account();
 | 
			
		||||
@@ -72,7 +27,7 @@ if (process.env.TEST_LIVE) {
 | 
			
		||||
      before(async function () {
 | 
			
		||||
        this.timeout(60_000);
 | 
			
		||||
        programData = await fs.readFile(
 | 
			
		||||
          'test/fixtures/noop-rust/solana_bpf_rust_noop.so',
 | 
			
		||||
          'test/fixtures/noop-program/solana_bpf_rust_noop.so',
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        const {feeCalculator} = await connection.getRecentBlockhash();
 | 
			
		||||
 
 | 
			
		||||
@@ -927,7 +927,7 @@ describe('Connection', () => {
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Block 0 never has any transactions in automation localnet
 | 
			
		||||
    // Block 0 never has any transactions in test validator
 | 
			
		||||
    const block0 = await connection.getConfirmedBlock(0);
 | 
			
		||||
    const blockhash0 = block0.blockhash;
 | 
			
		||||
    expect(block0.transactions).to.have.length(0);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								web3.js/test/fixtures/noop-c/build.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								web3.js/test/fixtures/noop-c/build.sh
									
									
									
									
										vendored
									
									
								
							@@ -1,7 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
set -ex
 | 
			
		||||
 | 
			
		||||
cd "$(dirname "$0")"
 | 
			
		||||
 | 
			
		||||
make -C ../../../examples/bpf-c-noop/
 | 
			
		||||
cp ../../../examples/bpf-c-noop/out/noop.so .
 | 
			
		||||
							
								
								
									
										7
									
								
								web3.js/test/fixtures/noop-program/build.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								web3.js/test/fixtures/noop-program/build.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
set -ex
 | 
			
		||||
 | 
			
		||||
cd "$(dirname "$0")"
 | 
			
		||||
 | 
			
		||||
cargo build-bpf
 | 
			
		||||
cp ./target/deploy/solana_bpf_rust_noop.so .
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								web3.js/test/fixtures/noop-program/solana_bpf_rust_noop.so
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								web3.js/test/fixtures/noop-program/solana_bpf_rust_noop.so
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										7
									
								
								web3.js/test/fixtures/noop-rust/build.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								web3.js/test/fixtures/noop-rust/build.sh
									
									
									
									
										vendored
									
									
								
							@@ -1,7 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
set -ex
 | 
			
		||||
 | 
			
		||||
cd "$(dirname "$0")"
 | 
			
		||||
 | 
			
		||||
cargo build-bpf --manifest-path=../../../examples/bpf-rust-noop/Cargo.toml
 | 
			
		||||
cp ../../../examples/bpf-rust-noop/target/deploy/solana_bpf_rust_noop.so .
 | 
			
		||||
		Reference in New Issue
	
	Block a user