diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 308e83ff..d85ca464 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,4 +1,8 @@
-name: Workspace Checks & Tests
+name: Test & Release
+
+permissions:
+ pull-requests: write
+ contents: write
on:
push:
@@ -7,33 +11,46 @@ on:
env:
CARGO_TERM_COLOR: always
+ RUSTFLAGS: '-D warnings'
+ CARGO_INCREMENTAL: 0
+ RUST_BACKTRACE: short
jobs:
- check:
- name: Clippy and fmt
- runs-on: ubuntu-latest
+ clippy:
+ runs-on: ubuntu-20.04
+
steps:
- - uses: actions/checkout@v2
- - name: Install stable toolchain
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: stable
- components: rustfmt, clippy
- - uses: Swatinem/rust-cache@v1
- - name: Check Formatting
- run: cargo fmt -- --check
- - name: Check Clippy
- run: cargo clippy --tests -- -Dclippy::all
+ - uses: actions/checkout@v4
+ - name: Run clippy
+ run: cargo clippy --benches -- -D clippy::all
+
+ cargo-fmt:
+ runs-on: ubuntu-20.04
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Run cargo fmt
+ run: cargo fmt --check
+
+ # there're sometimes warnings, which signal, that the generated doc
+ # won't look as expected, when rendered, and sometimes errors, which will prevent doc from being
+ # generated at release time altogether.
+ cargo-doc:
+ runs-on: ubuntu-20.04
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: run cargo doc
+ run: RUSTDOCFLAGS="-D warnings" cargo doc
test:
- needs: check
+ needs: cargo-fmt
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
toolchain: [stable]
-
runs-on: ${{ matrix.platform }}
+
steps:
- uses: actions/checkout@v2
- name: "${{ matrix.toolchain }}"
@@ -49,3 +66,22 @@ jobs:
run: cargo check --verbose
- name: Run tests with unstable features
run: NEAR_RPC_TIMEOUT_SECS=100 cargo test --verbose --features unstable
+
+ release-plz:
+ runs-on: ubuntu-latest
+ needs: [clippy, cargo-fmt, cargo-doc, test]
+ if: github.ref == 'refs/heads/main'
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ token: ${{ secrets.MY_GITHUB_TOKEN }}
+ - name: Install Rust toolchain
+ uses: dtolnay/rust-toolchain@stable
+ - name: Run release-plz
+ uses: MarcoIeni/release-plz-action@v0.5
+ env:
+ # https://release-plz.ieni.dev/docs/github/trigger
+ GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
+ CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
diff --git a/Cargo.toml b/Cargo.toml
index ba6193d5..299a6464 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,4 +2,4 @@
members = [
"workspaces",
"examples",
-]
\ No newline at end of file
+]
diff --git a/README.md b/README.md
index 28738799..fa807724 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
-
-
-
+
+
+
@@ -24,11 +24,11 @@
### WASM compilation not supported
-`workspaces-rs`, the library itself, does not currently compile to WASM. Best to put this dependency in `[dev-dependencies]` section of `Cargo.toml` if we were trying to run this library alongside something that already does compile to WASM, such as `near-sdk-rs`.
+`near-workspaces-rs`, the library itself, does not currently compile to WASM. Best to put this dependency in `[dev-dependencies]` section of `Cargo.toml` if we were trying to run this library alongside something that already does compile to WASM, such as `near-sdk-rs`.
## Simple Testing Case
-A simple test to get us going and familiar with `workspaces` framework. Here, we will be going through the NFT contract and how we can test it with `workspaces-rs`.
+A simple test to get us going and familiar with `near-workspaces` framework. Here, we will be going through the NFT contract and how we can test it with `near-workspaces-rs`.
### Setup -- Imports
@@ -60,7 +60,7 @@ This includes launching our sandbox, loading our wasm file and deploying that wa
#[tokio::test]
async fn test_nft_contract() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(NFT_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
```
@@ -129,7 +129,7 @@ Then later on, we can view our minted NFT's metadata via our `view` call into `n
### Updating Contract Afterwards
-Note that if our contract code changes, `workspaces-rs` does nothing about it since we are utilizing `deploy`/`dev_deploy` to merely send the contract bytes to the network. So if it does change, we will have to recompile the contract as usual, and point `deploy`/`dev_deploy` again to the right WASM files. However, there is a workspaces feature that will recompile contract changes for us: refer to the experimental/unstable [`compile_project`](#compiling-contracts-during-test-time) function for telling workspaces to compile a _Rust_ project for us.
+Note that if our contract code changes, `near-workspaces-rs` does nothing about it since we are utilizing `deploy`/`dev_deploy` to merely send the contract bytes to the network. So if it does change, we will have to recompile the contract as usual, and point `deploy`/`dev_deploy` again to the right WASM files. However, there is a feature that will recompile contract changes for us: refer to the experimental/unstable [`compile_project`](#compiling-contracts-during-test-time) function for telling near-workspaces to compile a _Rust_ project for us.
## Examples
@@ -150,9 +150,9 @@ cargo run --example nft
async fn main() -> anyhow::Result<()> {
// Create a sandboxed environment.
// NOTE: Each call will create a new sandboxed environment
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
// or for testnet:
- let worker = workspaces::testnet().await?;
+ let worker = near_workspaces::testnet().await?;
}
```
@@ -161,7 +161,7 @@ async fn main() -> anyhow::Result<()> {
Need to make a helper functions utilizing contracts? Just import it and pass it around:
```rust
-use workspaces::Contract;
+use near_workspaces::Contract;
// Helper function that calls into a contract we give it
async fn call_my_func(contract: &Contract) -> anyhow::Result<()> {
@@ -179,7 +179,7 @@ async fn call_my_func(contract: &Contract) -> anyhow::Result<()> {
Or to pass around workers regardless of networks:
```rust
-use workspaces::{DevNetwork, Worker};
+use near_workspaces::{DevNetwork, Worker};
const CONTRACT_BYTES: &[u8] = include_bytes!("./relative/path/to/file.wasm");
@@ -198,7 +198,7 @@ We can check the balance of our accounts like so:
#[test(tokio::test)]
async fn test_contract_transfer() -> anyhow::Result<()> {
let transfer_amount = near_units::parse_near!("0.1");
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker
.dev_deploy(include_bytes!("../target/res/your_project_name.wasm"))
@@ -227,7 +227,7 @@ async fn test_contract_transfer() -> anyhow::Result<()> {
}
```
-For viewing other chain related details, look at the docs for [Worker](https://docs.rs/workspaces/0.4.1/workspaces/struct.Worker.html), [Account](https://docs.rs/workspaces/0.4.1/workspaces/struct.Account.html) and [Contract](https://docs.rs/workspaces/0.4.1/workspaces/struct.Contract.html)
+For viewing other chain related details, look at the docs for [Worker](https://docs.rs/near-workspaces/latest/near_workspaces/struct.Worker.html), [Account](https://docs.rs/near-workspaces/latest/near_workspaces/struct.Account.html) and [Contract](https://docs.rs/near-workspaces/latest/near_workspaces/struct.Contract.html)
### Spooning - Pulling Existing State and Contracts from Mainnet/Testnet
@@ -237,8 +237,8 @@ We will first start with the usual imports:
```rust
use near_units::{parse_gas, parse_near};
-use workspaces::network::Sandbox;
-use workspaces::{Account, AccountId, BlockHeight, Contract, Worker};
+use near_workspaces::network::Sandbox;
+use near_workspaces::{Account, AccountId, BlockHeight, Contract, Worker};
```
Then specify the contract name from testnet we want to be pulling:
@@ -257,7 +257,7 @@ Create a function called `pull_contract` which will pull the contract's `.wasm`
```rust
async fn pull_contract(owner: &Account, worker: &Worker) -> anyhow::Result {
- let testnet = workspaces::testnet_archival().await?;
+ let testnet = near_workspaces::testnet_archival().await?;
let contract_id: AccountId = CONTRACT_ACCOUNT.parse()?;
```
@@ -295,7 +295,7 @@ Note: This is not to be confused with speeding up the current in-flight transact
```rust
#[tokio::test]
async fn test_contract() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(WASM_BYTES).await?;
let blocks_to_advance = 10000;
@@ -308,7 +308,7 @@ async fn test_contract() -> anyhow::Result<()> {
}
```
-For a full example, take a look at [examples/src/fast_forward.rs](https://github.com/near/workspaces-rs/blob/main/examples/src/fast_forward.rs).
+For a full example, take a look at [examples/src/fast_forward.rs](https://github.com/near/near-workspaces-rs/blob/main/examples/src/fast_forward.rs).
### Compiling Contracts During Test Time
@@ -316,7 +316,7 @@ Note, this is an unstable feature and will very likely change. To enable it, add
```toml
[dependencies]
-workspaces = { version = "...", features = ["unstable"] }
+near-workspaces = { version = "...", features = ["unstable"] }
```
Then, in our tests right before we call into `deploy` or `dev_deploy`, we can compile our projects:
@@ -324,7 +324,7 @@ Then, in our tests right before we call into `deploy` or `dev_deploy`, we can co
```rust
#[tokio::test]
async fn test_contract() -> anyhow::Result<()> {
- let wasm = workspaces::compile_project("path/to/contract-rs-project").await?;
+ let wasm = near_workspaces::compile_project("path/to/contract-rs-project").await?;
let worker = workspaces::sandbox().await?;
let contract = worker.dev_deploy(&wasm).await?;
@@ -332,7 +332,7 @@ async fn test_contract() -> anyhow::Result<()> {
}
```
-For a full example, take a look at [workspaces/tests/deploy_project.rs](https://github.com/near/workspaces-rs/blob/main/workspaces/tests/deploy_project.rs).
+For a full example, take a look at [workspaces/tests/deploy_project.rs](https://github.com/near/near-workspaces-rs/blob/main/workspaces/tests/deploy_project.rs).
### Other Features
@@ -343,7 +343,7 @@ Other features can be directly found in the `examples/` folder, with some docume
These environment variables will be useful if there was ever a snag hit:
- `NEAR_RPC_TIMEOUT_SECS`: The default is 10 seconds, but this is the amount of time before timing out waiting for a RPC service when talking to the sandbox or any other network such as testnet.
-- `NEAR_SANDBOX_BIN_PATH`: Set this to our own prebuilt `neard-sandbox` bin path if we want to use a non-default version of the sandbox or configure nearcore with our own custom features that we want to test in workspaces.
+- `NEAR_SANDBOX_BIN_PATH`: Set this to our own prebuilt `neard-sandbox` bin path if we want to use a non-default version of the sandbox or configure nearcore with our own custom features that we want to test in near-workspaces.
- `NEAR_SANDBOX_MAX_PAYLOAD_SIZE`: Sets the max payload size for sending transaction commits to sandbox. The default is 1gb and is necessary for patching large states.
- `NEAR_SANDBOX_MAX_FILES`: Set the max amount of files that can be opened at a time in the sandbox. If none is specified, the default size of 4096 will be used. The actual near chain will use over 10,000 in practice, but for testing this should be much lower since we do not have a constantly running blockchain unless our tests take up that much time.
- `NEAR_RPC_API_KEY`: This is the API key necessary for communicating with RPC nodes. This is useful when interacting with services such as Pagoda Console or a service that can access RPC metrics. This is not a **hard** requirement, but it is recommended to running the Pagoda example in the examples folder.
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 88cb726f..74d61a17 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -18,7 +18,7 @@ serde_json = { version = "1.0" }
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3.5", features = ["env-filter"] }
-workspaces = { path = "../workspaces", features = ["experimental", "unstable"] }
+near-workspaces = { path = "../workspaces", features = ["experimental", "unstable"] }
[[example]]
name = "async_transaction"
diff --git a/examples/src/async_transaction.rs b/examples/src/async_transaction.rs
index a384ea51..82a3a096 100644
--- a/examples/src/async_transaction.rs
+++ b/examples/src/async_transaction.rs
@@ -2,7 +2,7 @@ const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(STATUS_MSG_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/changes.rs b/examples/src/changes.rs
index edd8b3d7..247013ac 100644
--- a/examples/src/changes.rs
+++ b/examples/src/changes.rs
@@ -5,7 +5,7 @@ const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(STATUS_MSG_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/changes_in_block.rs b/examples/src/changes_in_block.rs
index f2adb074..d026b8f5 100644
--- a/examples/src/changes_in_block.rs
+++ b/examples/src/changes_in_block.rs
@@ -5,7 +5,7 @@ const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(STATUS_MSG_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/croncat.rs b/examples/src/croncat.rs
index 7f551fb9..a7530d5f 100644
--- a/examples/src/croncat.rs
+++ b/examples/src/croncat.rs
@@ -7,12 +7,11 @@
use near_gas::NearGas;
use near_units::parse_near;
+use near_workspaces::network::Sandbox;
+use near_workspaces::{Account, AccountId, Contract, Worker};
use serde::Deserialize;
use serde_json::json;
-use workspaces::network::Sandbox;
-use workspaces::{Account, AccountId, Contract, Worker};
-
const MANAGER_CONTRACT: &[u8] = include_bytes!("../res/manager.wasm");
const COUNTER_CONTRACT: &[u8] = include_bytes!("../res/counter.wasm");
@@ -47,7 +46,7 @@ pub struct Agent {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Spawn sandbox as normal and get us a local blockchain for us to interact and toy with:
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
// Initialize counter contract, which will be pointed to in the manager contract to schedule
// a task later to increment the counter, inside counter contract.
diff --git a/examples/src/custom_network.rs b/examples/src/custom_network.rs
index 0811f0ce..41fc0f1c 100644
--- a/examples/src/custom_network.rs
+++ b/examples/src/custom_network.rs
@@ -6,7 +6,7 @@ async fn main() -> anyhow::Result<()> {
// `NEAR_RPC_API_KEY="xxx" cargo run --package examples --example custom_network`
if let Ok(val) = std::env::var("NEAR_RPC_API_KEY") {
// Reference to what can be called by this network: https://docs.pagoda.co/endpoints
- let worker = workspaces::custom(PAGODA_TESTNET_RPC_URL)
+ let worker = near_workspaces::custom(PAGODA_TESTNET_RPC_URL)
.api_key(&val)
.await?;
let res = worker.view_block().await?;
diff --git a/examples/src/fast_forward.rs b/examples/src/fast_forward.rs
index 091d90e8..3b5baa11 100644
--- a/examples/src/fast_forward.rs
+++ b/examples/src/fast_forward.rs
@@ -9,7 +9,7 @@ const SIMPLE_WASM_FILEPATH: &str = "./examples/res/simple_contract.wasm";
/// to be produced, which could take hours with the default genesis configuration.
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker
.dev_deploy(&std::fs::read(SIMPLE_WASM_FILEPATH)?)
.await?;
diff --git a/examples/src/genesis_config.rs b/examples/src/genesis_config.rs
index f3b81ad8..68e2061d 100644
--- a/examples/src/genesis_config.rs
+++ b/examples/src/genesis_config.rs
@@ -1,6 +1,6 @@
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
// NOTE: this API is under the "experimental" flag and no guarantees are given.
let genesis_config = worker.genesis_config().await?;
diff --git a/examples/src/nft.rs b/examples/src/nft.rs
index 24ab636f..0e91d835 100644
--- a/examples/src/nft.rs
+++ b/examples/src/nft.rs
@@ -4,7 +4,7 @@ const NFT_WASM_FILEPATH: &str = "./examples/res/non_fungible_token.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(NFT_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/noop.rs b/examples/src/noop.rs
index d7cb4fec..c4481576 100644
--- a/examples/src/noop.rs
+++ b/examples/src/noop.rs
@@ -3,7 +3,7 @@ const NOOP_CONTRACT_WASM_FILEPATH: &str = "./examples/res/noop_contract.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(NOOP_CONTRACT_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
@@ -12,7 +12,7 @@ async fn main() -> anyhow::Result<()> {
// Ok to error for call with no return value
assert_eq!(
*res.unwrap_err().kind(),
- workspaces::error::ErrorKind::DataConversion,
+ near_workspaces::error::ErrorKind::DataConversion,
"the function call returned an empty value, which cannot be parsed as JSON"
);
Ok(())
diff --git a/examples/src/protocol_config.rs b/examples/src/protocol_config.rs
index ca555d9c..785c9ce9 100644
--- a/examples/src/protocol_config.rs
+++ b/examples/src/protocol_config.rs
@@ -2,7 +2,7 @@ const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(STATUS_MSG_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/receipt.rs b/examples/src/receipt.rs
index c838982c..450fb872 100644
--- a/examples/src/receipt.rs
+++ b/examples/src/receipt.rs
@@ -4,7 +4,7 @@ const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(STATUS_MSG_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/ref_finance.rs b/examples/src/ref_finance.rs
index 26f90141..ca2d0657 100644
--- a/examples/src/ref_finance.rs
+++ b/examples/src/ref_finance.rs
@@ -3,10 +3,10 @@ use std::convert::TryInto;
use near_gas::NearGas;
use near_units::parse_near;
+use near_workspaces::network::Sandbox;
+use near_workspaces::{Account, AccountId, Contract, Worker};
+use near_workspaces::{BlockHeight, DevNetwork};
use serde_json::json;
-use workspaces::network::Sandbox;
-use workspaces::{Account, AccountId, Contract, Worker};
-use workspaces::{BlockHeight, DevNetwork};
const FT_CONTRACT_FILEPATH: &str = "./examples/res/fungible_token.wasm";
@@ -20,7 +20,7 @@ const BLOCK_HEIGHT: BlockHeight = 50_000_000;
/// Pull down the ref-finance contract and deploy it to the sandbox network,
/// initializing it with all data required to run the tests.
async fn create_ref(owner: &Account, worker: &Worker) -> anyhow::Result {
- let mainnet = workspaces::mainnet_archival().await?;
+ let mainnet = near_workspaces::mainnet_archival().await?;
let ref_finance_id: AccountId = REF_FINANCE_ACCOUNT_ID.parse()?;
// This will pull down the relevant ref-finance contract from mainnet. We're going
@@ -60,7 +60,7 @@ async fn create_ref(owner: &Account, worker: &Worker) -> anyhow::Result
/// Pull down the WNear contract from mainnet and initilize it with our own metadata.
async fn create_wnear(owner: &Account, worker: &Worker) -> anyhow::Result {
- let mainnet = workspaces::mainnet_archival().await?;
+ let mainnet = near_workspaces::mainnet_archival().await?;
let wnear_id: AccountId = "wrap.near".to_string().try_into()?;
let wnear = worker
.import_contract(&wnear_id, &mainnet)
@@ -210,7 +210,7 @@ async fn create_custom_ft(
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let owner = worker.root_account()?;
///////////////////////////////////////////////////////////////////////////
diff --git a/examples/src/spooning.rs b/examples/src/spooning.rs
index f7a1b4ed..1b0e36f2 100644
--- a/examples/src/spooning.rs
+++ b/examples/src/spooning.rs
@@ -1,11 +1,11 @@
use std::env;
use borsh::{self, BorshDeserialize, BorshSerialize};
+use near_workspaces::{AccountId, Contract, DevNetwork, Worker};
use serde_json::json;
use tracing::info;
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::EnvFilter;
-use workspaces::{AccountId, Contract, DevNetwork, Worker};
const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
@@ -76,7 +76,7 @@ async fn main() -> anyhow::Result<()> {
// Grab STATE from the testnet status_message contract. This contract contains the following data:
// get_status(dev-20211013002148-59466083160385) => "hello from testnet"
let (testnet_contract_id, status_msg) = {
- let worker = workspaces::testnet().await?;
+ let worker = near_workspaces::testnet().await?;
let contract_id: AccountId = TESTNET_PREDEPLOYED_CONTRACT_ID
.parse()
.map_err(anyhow::Error::msg)?;
@@ -92,7 +92,7 @@ async fn main() -> anyhow::Result<()> {
info!(target: "spooning", "Testnet: {:?}", status_msg);
// Create our sandboxed environment and grab a worker to do stuff in it:
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
// Deploy with the following status_message state: sandbox_contract_id => "hello from sandbox"
let sandbox_contract = deploy_status_contract(&worker, "hello from sandbox").await?;
diff --git a/examples/src/status_message.rs b/examples/src/status_message.rs
index 746a0cfb..b790e745 100644
--- a/examples/src/status_message.rs
+++ b/examples/src/status_message.rs
@@ -4,7 +4,7 @@ const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(STATUS_MSG_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/tx_status.rs b/examples/src/tx_status.rs
index 756c7f2c..ace5791d 100644
--- a/examples/src/tx_status.rs
+++ b/examples/src/tx_status.rs
@@ -6,7 +6,7 @@ const STATUS_MSG_WASM_FILEPATH: &str = "./examples/res/status_message.wasm";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let wasm = std::fs::read(STATUS_MSG_WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;
diff --git a/examples/src/validators_ordered.rs b/examples/src/validators_ordered.rs
index bb9e6b5e..58965516 100644
--- a/examples/src/validators_ordered.rs
+++ b/examples/src/validators_ordered.rs
@@ -1,6 +1,6 @@
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
// NOTE: this API is under the "experimental" flag and no guarantees are given.
let validators = worker.validators_ordered(None).await?;
diff --git a/examples/src/various_queries.rs b/examples/src/various_queries.rs
index 1bcefa70..c5550013 100644
--- a/examples/src/various_queries.rs
+++ b/examples/src/various_queries.rs
@@ -4,7 +4,7 @@ use serde_json::json;
/// to what was on the chain prior to modifying state.
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
// Fetch the latest block produced from the network.
let block = worker.view_block().await?;
diff --git a/release-plz.toml b/release-plz.toml
new file mode 100644
index 00000000..8aa770d0
--- /dev/null
+++ b/release-plz.toml
@@ -0,0 +1,8 @@
+[workspace]
+# Use `workspaces` crate CHANGELOG as top-level one
+changelog_update = false
+
+[[package]]
+name = "near-workspaces"
+changelog_update = true
+changelog_path = "./CHANGELOG.md"
diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml
index 92abc4cd..ead7a9ca 100644
--- a/workspaces/Cargo.toml
+++ b/workspaces/Cargo.toml
@@ -1,10 +1,10 @@
[package]
-name = "workspaces"
+name = "near-workspaces"
version = "0.7.0"
edition = "2018"
license = "MIT OR Apache-2.0"
readme = "README.md"
-repository = "https://github.com/near/workspaces-rs"
+repository = "https://github.com/near/near-workspaces-rs"
description = """
Library for automating workflows and testing NEAR smart contracts.
"""
diff --git a/workspaces/src/rpc/patch.rs b/workspaces/src/rpc/patch.rs
index 82e8bed1..5d23feb9 100644
--- a/workspaces/src/rpc/patch.rs
+++ b/workspaces/src/rpc/patch.rs
@@ -174,13 +174,13 @@ impl PatchTransaction {
}
}
- /// Patch and overwrite the info contained inside an [`Account`] in sandbox.
+ /// Patch and overwrite the info contained inside an [`crate::Account`] in sandbox.
pub fn account(mut self, account: AccountDetailsPatch) -> Self {
self.account_updates.push(AccountUpdate::Update(account));
self
}
- /// Patch and overwrite the info contained inside an [`Account`] in sandbox. This
+ /// Patch and overwrite the info contained inside an [`crate::Account`] in sandbox. This
/// will allow us to fetch the current details on the chain and allow us to update
/// the account details w.r.t to them.
pub fn account_from_current(mut self, f: F) -> Self
@@ -230,7 +230,7 @@ impl PatchTransaction {
}
/// Sets the code for this account. This will overwrite the current code contained in the account.
- /// Note that if a patch for [`account`] or [`account_from_current`] is specified, the code hash
+ /// Note that if a patch for [`Self::account`] or [`Self::account_from_current`] is specified, the code hash
/// in those will be overwritten with the code hash of the code we specify here.
pub fn code(mut self, wasm_bytes: &[u8]) -> Self {
self.code_hash_update = Some(CryptoHash::hash_bytes(wasm_bytes));
diff --git a/workspaces/src/rpc/query.rs b/workspaces/src/rpc/query.rs
index 1bada9b6..2adefbe9 100644
--- a/workspaces/src/rpc/query.rs
+++ b/workspaces/src/rpc/query.rs
@@ -6,8 +6,8 @@
//!
//! For example, to query into downloading contract state:
//! ```
-//! use workspaces::{AccountId, Network, Worker};
-//! use workspaces::rpc::query::{Query, ViewState};
+//! use near_workspaces::{AccountId, Network, Worker};
+//! use near_workspaces::rpc::query::{Query, ViewState};
//!
//! async fn my_func(worker: &Worker) -> anyhow::Result<()> {
//! let contract_id: AccountId = "some-contract.near".parse()?;
diff --git a/workspaces/tests/account.rs b/workspaces/tests/account.rs
index 8b86baae..0ff963a2 100644
--- a/workspaces/tests/account.rs
+++ b/workspaces/tests/account.rs
@@ -7,7 +7,7 @@ use std::path::Path;
#[test(tokio::test)]
async fn test_subaccount_creation() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let account = worker.dev_create_account().await?;
let sub = account
@@ -37,7 +37,7 @@ async fn test_subaccount_creation() -> anyhow::Result<()> {
#[test(tokio::test)]
async fn test_transfer_near() -> anyhow::Result<()> {
const INITIAL_BALANCE: u128 = 100 * 1_000_000_000_000_000_000_000_000;
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let (alice, bob) = (
worker.dev_create_account().await?,
worker.dev_create_account().await?,
@@ -65,7 +65,7 @@ async fn test_transfer_near() -> anyhow::Result<()> {
#[test(tokio::test)]
async fn test_delete_account() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let (alice, bob) = (
worker.dev_create_account().await?,
diff --git a/workspaces/tests/batch_tx.rs b/workspaces/tests/batch_tx.rs
index 3969c9e1..c3477e9b 100644
--- a/workspaces/tests/batch_tx.rs
+++ b/workspaces/tests/batch_tx.rs
@@ -1,10 +1,10 @@
+use near_workspaces::operations::Function;
use serde_json::json;
use test_log::test;
-use workspaces::operations::Function;
#[test(tokio::test)]
async fn test_batch_tx() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker
.dev_deploy(include_bytes!("../../examples/res/status_message.wasm"))
.await?;
diff --git a/workspaces/tests/cross_contract.rs b/workspaces/tests/cross_contract.rs
index ca3e2d92..e895508d 100644
--- a/workspaces/tests/cross_contract.rs
+++ b/workspaces/tests/cross_contract.rs
@@ -1,7 +1,7 @@
use near_sdk::json_types::U128;
use near_units::parse_near;
-use workspaces::result::ExecutionFinalResult;
-use workspaces::{AccountId, Contract};
+use near_workspaces::result::ExecutionFinalResult;
+use near_workspaces::{AccountId, Contract};
/// The factory contract used in these tests can be found in
/// [near-sdk/examples/factory-contract](https://github.com/near/near-sdk-rs/tree/master/examples/factory-contract/high-level).
@@ -26,7 +26,7 @@ async fn cross_contract_create_contract(
#[tokio::test]
async fn test_cross_contract_create_contract() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(FACTORY_CONTRACT).await?;
let status_amt = U128::from(parse_near!("35 N"));
@@ -57,7 +57,7 @@ async fn test_cross_contract_create_contract() -> anyhow::Result<()> {
#[tokio::test]
async fn test_cross_contract_calls() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(FACTORY_CONTRACT).await?;
let status_amt = U128::from(parse_near!("35 N"));
diff --git a/workspaces/tests/deploy.rs b/workspaces/tests/deploy.rs
index 930457dd..2088c061 100644
--- a/workspaces/tests/deploy.rs
+++ b/workspaces/tests/deploy.rs
@@ -2,8 +2,8 @@
use serde::{Deserialize, Serialize};
use test_log::test;
-use workspaces::network::{Sandbox, ValidatorKey};
-use workspaces::{pick_unused_port, Worker};
+use near_workspaces::network::{Sandbox, ValidatorKey};
+use near_workspaces::{pick_unused_port, Worker};
const NFT_WASM_FILEPATH: &str = "../examples/res/non_fungible_token.wasm";
const EXPECTED_NFT_METADATA: &str = r#"{
@@ -52,7 +52,7 @@ async fn deploy_and_assert(worker: Worker) -> anyhow::Result<()> {
#[test(tokio::test)]
async fn test_dev_deploy() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
deploy_and_assert(worker).await?;
Ok(())
}
@@ -74,7 +74,7 @@ async fn test_manually_spawned_deploy() -> anyhow::Result<()> {
let mut child = near_sandbox_utils::run(&home_dir, rpc_port, net_port)?;
// connect to local sandbox node
- let worker = workspaces::sandbox()
+ let worker = near_workspaces::sandbox()
.rpc_addr(&format!("http://localhost:{}", rpc_port))
.validator_key(ValidatorKey::HomeDir(home_dir))
.await?;
diff --git a/workspaces/tests/deploy_project.rs b/workspaces/tests/deploy_project.rs
index 7321250d..30b37573 100644
--- a/workspaces/tests/deploy_project.rs
+++ b/workspaces/tests/deploy_project.rs
@@ -4,8 +4,8 @@ use test_log::test;
#[test(tokio::test)]
async fn test_dev_deploy_project() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
- let wasm = workspaces::compile_project("./tests/test-contracts/status-message").await?;
+ let worker = near_workspaces::sandbox().await?;
+ let wasm = near_workspaces::compile_project("./tests/test-contracts/status-message").await?;
let contract = worker.dev_deploy(&wasm).await?;
contract
diff --git a/workspaces/tests/optional_args.rs b/workspaces/tests/optional_args.rs
index a5de362d..6945795a 100644
--- a/workspaces/tests/optional_args.rs
+++ b/workspaces/tests/optional_args.rs
@@ -1,8 +1,8 @@
#![recursion_limit = "256"]
use near_gas::NearGas;
use near_units::parse_near;
+use near_workspaces::{Contract, DevNetwork, Worker};
use test_log::test;
-use workspaces::{Contract, DevNetwork, Worker};
async fn init(worker: &Worker) -> anyhow::Result {
let contract = worker
@@ -24,7 +24,7 @@ async fn init(worker: &Worker) -> anyhow::Result {
#[test(tokio::test)]
async fn test_empty_args_error() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = init(&worker).await?;
let res = contract
@@ -50,7 +50,7 @@ async fn test_empty_args_error() -> anyhow::Result<()> {
#[test(tokio::test)]
async fn test_optional_args_present() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = init(&worker).await?;
let res = contract
diff --git a/workspaces/tests/parallel_transactions.rs b/workspaces/tests/parallel_transactions.rs
index d12240e7..6d8697a1 100644
--- a/workspaces/tests/parallel_transactions.rs
+++ b/workspaces/tests/parallel_transactions.rs
@@ -6,7 +6,7 @@ const STATUS_MSG_CONTRACT: &[u8] = include_bytes!("../../examples/res/status_mes
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_parallel() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(STATUS_MSG_CONTRACT).await?;
let account = worker.dev_create_account().await?;
@@ -43,7 +43,7 @@ async fn test_parallel() -> anyhow::Result<()> {
#[tokio::test]
async fn test_parallel_async() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(STATUS_MSG_CONTRACT).await?;
let account = worker.dev_create_account().await?;
diff --git a/workspaces/tests/patch_state.rs b/workspaces/tests/patch_state.rs
index 97131f08..70fc197e 100644
--- a/workspaces/tests/patch_state.rs
+++ b/workspaces/tests/patch_state.rs
@@ -5,8 +5,8 @@ use borsh::{self, BorshDeserialize, BorshSerialize};
use serde_json::json;
use test_log::test;
-use workspaces::types::{KeyType, SecretKey};
-use workspaces::{AccessKey, AccountDetailsPatch, AccountId, Contract, DevNetwork, Worker};
+use near_workspaces::types::{KeyType, SecretKey};
+use near_workspaces::{AccessKey, AccountDetailsPatch, AccountId, Contract, DevNetwork, Worker};
const STATUS_MSG_WASM_FILEPATH: &str = "../examples/res/status_message.wasm";
@@ -47,7 +47,7 @@ async fn view_status_state(
#[test(tokio::test)]
async fn test_view_state() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let (contract_id, status_msg) = view_status_state(&worker).await?;
assert_eq!(
@@ -65,7 +65,7 @@ async fn test_view_state() -> anyhow::Result<()> {
#[test(tokio::test)]
async fn test_patch_state() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let (contract_id, mut status_msg) = view_status_state(&worker).await?;
status_msg.records.push(Record {
k: "alice.near".to_string(),
@@ -91,7 +91,7 @@ async fn test_patch_state() -> anyhow::Result<()> {
#[test(tokio::test)]
async fn test_patch() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let (contract_id, mut status_msg) = view_status_state(&worker).await?;
status_msg.records.push(Record {
k: "alice.near".to_string(),
@@ -119,7 +119,7 @@ async fn test_patch() -> anyhow::Result<()> {
#[test(tokio::test)]
async fn test_patch_full() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let (contract_id, status_msg) = view_status_state(&worker).await?;
let status_msg_acc = worker.view_account(&contract_id).await?;
let status_msg_code = worker.view_code(&contract_id).await?;
@@ -161,7 +161,7 @@ async fn test_patch_full() -> anyhow::Result<()> {
#[tokio::test]
async fn test_patch_code_hash() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let (contract_id, _) = view_status_state(&worker).await?;
let status_msg_acc = worker.view_account(&contract_id).await?;
let status_msg_code = worker.view_code(&contract_id).await?;
@@ -185,13 +185,13 @@ async fn test_patch_code_hash() -> anyhow::Result<()> {
// account_from_current
#[tokio::test]
async fn test_patch_account_from_current() -> anyhow::Result<()> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let bob = worker.dev_create_account().await?;
const NEW_BALANCE: u128 = 10_u128.pow(16);
- let f = |mut acc: workspaces::types::AccountDetails| {
+ let f = |mut acc: near_workspaces::types::AccountDetails| {
acc.balance = NEW_BALANCE;
AccountDetailsPatch::from(acc)
};
diff --git a/workspaces/tests/query.rs b/workspaces/tests/query.rs
index bff45b75..7ced61dc 100644
--- a/workspaces/tests/query.rs
+++ b/workspaces/tests/query.rs
@@ -1,7 +1,7 @@
-use workspaces::{network::Sandbox, Contract, Worker};
+use near_workspaces::{network::Sandbox, Contract, Worker};
async fn init() -> anyhow::Result<(Worker, Contract)> {
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let status_msg = worker
.dev_deploy(include_bytes!("../../examples/res/status_message.wasm"))
.await?;
diff --git a/workspaces/tests/types.rs b/workspaces/tests/types.rs
index 9f9c1174..d90e54e3 100644
--- a/workspaces/tests/types.rs
+++ b/workspaces/tests/types.rs
@@ -2,8 +2,8 @@ use std::str::FromStr;
use borsh::{BorshDeserialize, BorshSerialize};
-use workspaces::types::{KeyType, PublicKey, SecretKey};
-use workspaces::AccountId;
+use near_workspaces::types::{KeyType, PublicKey, SecretKey};
+use near_workspaces::AccountId;
fn default_workspaces_pubkey() -> anyhow::Result {
let data = bs58::decode("279Zpep9MBBg4nKsVmTQE7NbXZkWdxti6HS1yzhp8qnc1ExS7gU").into_vec()?;
@@ -62,7 +62,7 @@ fn test_pubkey_serialization() -> anyhow::Result<()> {
async fn test_pubkey_from_sdk_ser() -> anyhow::Result<()> {
const TYPE_SER_BYTES: &[u8] =
include_bytes!("test-contracts/type-serialize/res/test_contract_type_serialization.wasm");
- let worker = workspaces::sandbox().await?;
+ let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(TYPE_SER_BYTES).await?;
// Test out serde serialization and deserialization for PublicKey