diff --git a/web3.js/.gitignore b/web3.js/.gitignore
index ea4d0032d0..c158f7d504 100644
--- a/web3.js/.gitignore
+++ b/web3.js/.gitignore
@@ -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/
diff --git a/web3.js/.releaserc.json b/web3.js/.releaserc.json
new file mode 100644
index 0000000000..ee4be420db
--- /dev/null
+++ b/web3.js/.releaserc.json
@@ -0,0 +1,7 @@
+{
+ "repositoryUrl": "git@github.com:solana-labs/solana-web3.js.git",
+ "preset": "conventionalcommits",
+ "presetConfig": {
+ "issueUrlFormat": "{{host}}/{{owner}}/solana/issues/{{id}}"
+ }
+}
diff --git a/web3.js/.travis/before_install.sh b/web3.js/.travis/before_install.sh
index 6c5a4dd074..80dfc5b814 100644
--- a/web3.js/.travis/before_install.sh
+++ b/web3.js/.travis/before_install.sh
@@ -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
diff --git a/web3.js/.travis/script.sh b/web3.js/.travis/script.sh
index dde7004a72..15ee14b3d6 100644
--- a/web3.js/.travis/script.sh
+++ b/web3.js/.travis/script.sh
@@ -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
diff --git a/web3.js/README.md b/web3.js/README.md
index c5822423f6..0ec29a85f6 100644
--- a/web3.js/README.md
+++ b/web3.js/README.md
@@ -47,11 +47,17 @@ $ npm install --save @solana/web3.js
```
+## 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.
diff --git a/web3.js/bin/bpf-sdk-install.sh b/web3.js/bin/bpf-sdk-install.sh
deleted file mode 100755
index 0e5ce5302e..0000000000
--- a/web3.js/bin/bpf-sdk-install.sh
+++ /dev/null
@@ -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
diff --git a/web3.js/bin/localnet.sh b/web3.js/bin/localnet.sh
deleted file mode 100755
index a5e050ca24..0000000000
--- a/web3.js/bin/localnet.sh
+++ /dev/null
@@ -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 < - Optional Docker image tag to use
-
- up-specific options:
- - 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
diff --git a/web3.js/examples/README.md b/web3.js/examples/README.md
deleted file mode 100644
index 466afb2c31..0000000000
--- a/web3.js/examples/README.md
+++ /dev/null
@@ -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
-```
diff --git a/web3.js/examples/account.html b/web3.js/examples/account.html
deleted file mode 100644
index c25d2c22c6..0000000000
--- a/web3.js/examples/account.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- Create a new account
-
-
- Account Public Key:
- ?
-
-
-
-
-
-
-
diff --git a/web3.js/examples/account.js b/web3.js/examples/account.js
deleted file mode 100644
index 707bf13c83..0000000000
--- a/web3.js/examples/account.js
+++ /dev/null
@@ -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());
diff --git a/web3.js/examples/bpf-c-noop/.gitignore b/web3.js/examples/bpf-c-noop/.gitignore
deleted file mode 100644
index 6a3417b8d9..0000000000
--- a/web3.js/examples/bpf-c-noop/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/out/
diff --git a/web3.js/examples/bpf-c-noop/makefile b/web3.js/examples/bpf-c-noop/makefile
deleted file mode 100644
index 467f9a6bbc..0000000000
--- a/web3.js/examples/bpf-c-noop/makefile
+++ /dev/null
@@ -1 +0,0 @@
-include ../../bpf-sdk/c/bpf.mk
diff --git a/web3.js/examples/bpf-c-noop/src/noop/noop.c b/web3.js/examples/bpf-c-noop/src/noop/noop.c
deleted file mode 100644
index 5685ba9d61..0000000000
--- a/web3.js/examples/bpf-c-noop/src/noop/noop.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * @brief Example C-based BPF program that prints out the parameters
- * passed to it
- */
-
-#include
-
-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;
-}
diff --git a/web3.js/examples/get-balance.html b/web3.js/examples/get-balance.html
deleted file mode 100644
index 9e64915506..0000000000
--- a/web3.js/examples/get-balance.html
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
- Get account balance
-
-
- Account
- ?
- has a balance of
- ?
-
-
-
-
-
-
-
diff --git a/web3.js/examples/get-balance.js b/web3.js/examples/get-balance.js
deleted file mode 100644
index f03351f912..0000000000
--- a/web3.js/examples/get-balance.js
+++ /dev/null
@@ -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}`);
-});
diff --git a/web3.js/package.json b/web3.js/package.json
index 05ee18fe9c..f92ed93cc0 100644
--- a/web3.js/package.json
+++ b/web3.js/package.json
@@ -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",
diff --git a/web3.js/test/bpf-loader.test.ts b/web3.js/test/bpf-loader.test.ts
index 4fb8c7eb8f..7fb58324e0 100644
--- a/web3.js/test/bpf-loader.test.ts
+++ b/web3.js/test/bpf-loader.test.ts
@@ -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();
diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts
index 2e81e7d30a..36e19174a4 100644
--- a/web3.js/test/connection.test.ts
+++ b/web3.js/test/connection.test.ts
@@ -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);
diff --git a/web3.js/test/fixtures/noop-c/build.sh b/web3.js/test/fixtures/noop-c/build.sh
deleted file mode 100755
index 0043703b15..0000000000
--- a/web3.js/test/fixtures/noop-c/build.sh
+++ /dev/null
@@ -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 .
diff --git a/web3.js/examples/bpf-rust-noop/.gitignore b/web3.js/test/fixtures/noop-program/.gitignore
similarity index 100%
rename from web3.js/examples/bpf-rust-noop/.gitignore
rename to web3.js/test/fixtures/noop-program/.gitignore
diff --git a/web3.js/examples/bpf-rust-noop/Cargo.toml b/web3.js/test/fixtures/noop-program/Cargo.toml
similarity index 100%
rename from web3.js/examples/bpf-rust-noop/Cargo.toml
rename to web3.js/test/fixtures/noop-program/Cargo.toml
diff --git a/web3.js/examples/bpf-rust-noop/Xargo.toml b/web3.js/test/fixtures/noop-program/Xargo.toml
similarity index 100%
rename from web3.js/examples/bpf-rust-noop/Xargo.toml
rename to web3.js/test/fixtures/noop-program/Xargo.toml
diff --git a/web3.js/test/fixtures/noop-program/build.sh b/web3.js/test/fixtures/noop-program/build.sh
new file mode 100755
index 0000000000..d2d4ae8386
--- /dev/null
+++ b/web3.js/test/fixtures/noop-program/build.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+set -ex
+
+cd "$(dirname "$0")"
+
+cargo build-bpf
+cp ./target/deploy/solana_bpf_rust_noop.so .
diff --git a/web3.js/test/fixtures/noop-program/solana_bpf_rust_noop.so b/web3.js/test/fixtures/noop-program/solana_bpf_rust_noop.so
new file mode 100755
index 0000000000..c9ccefa7a3
Binary files /dev/null and b/web3.js/test/fixtures/noop-program/solana_bpf_rust_noop.so differ
diff --git a/web3.js/examples/bpf-rust-noop/src/lib.rs b/web3.js/test/fixtures/noop-program/src/lib.rs
similarity index 100%
rename from web3.js/examples/bpf-rust-noop/src/lib.rs
rename to web3.js/test/fixtures/noop-program/src/lib.rs
diff --git a/web3.js/test/fixtures/noop-rust/build.sh b/web3.js/test/fixtures/noop-rust/build.sh
deleted file mode 100755
index 622775f783..0000000000
--- a/web3.js/test/fixtures/noop-rust/build.sh
+++ /dev/null
@@ -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 .