Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dependecy bumps #338

Merged
merged 5 commits into from Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ edition = "2018"

[dev-dependencies]
anyhow = "1.0"
borsh = "0.10"
borsh = "1.2.0"
maplit = "1.0"
near-units = "0.2.0"
near-gas = { version = "0.2.3", features = ["serde", "borsh", "schemars"] }
near-jsonrpc-primitives = "0.17"
near-primitives = "0.17"
serde = "1.0"
serde_with = "1"
serde_with = "3.4"
serde_json = { version = "1.0" }
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3.5", features = ["env-filter"] }
near-workspaces = { path = "../workspaces", features = ["experimental", "unstable"] }
near-workspaces = { path = "../workspaces", features = [
"experimental",
"unstable",
] }

[[example]]
name = "async_transaction"
Expand Down
6 changes: 4 additions & 2 deletions examples/src/croncat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use near_workspaces::types::NearToken;
use near_workspaces::{Account, AccountId, Contract, Worker};
use serde::Deserialize;
use serde_json::json;
use serde_with::{serde_as, DisplayFromStr};

const MANAGER_CONTRACT: &[u8] = include_bytes!("../res/manager.wasm");
const COUNTER_CONTRACT: &[u8] = include_bytes!("../res/counter.wasm");
Expand All @@ -30,14 +31,15 @@ pub enum AgentStatus {
/// look at what an `Agent` is all about, refer to the [croncat docs](https://docs.cron.cat/docs/)
/// to understand further, but for this example all we care about is that an Agent is something
/// that can run scheduled tasks once it is time and collect rewards thereafter.
#[serde_as]
#[derive(Debug, Deserialize)]
pub struct Agent {
pub status: AgentStatus,
pub payable_account_id: AccountId,
// NOTE: display_fromstr is used to deserialize from a U128 type returned from the contract
// NOTE: DisplayFromStr is used to deserialize from a U128 type returned from the contract
// which is represented as a string there, and then converted into a rust u128 here.
pub balance: NearToken,
#[serde(with = "serde_with::rust::display_fromstr")]
#[serde_as(as = "DisplayFromStr")]
pub total_tasks_executed: u128,
pub last_missed_slot: u128,
}
Expand Down
15 changes: 8 additions & 7 deletions examples/src/spooning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ async fn main() -> anyhow::Result<()> {
.parse()
.map_err(anyhow::Error::msg)?;

let mut state_items = worker.view_state(&contract_id).await?;
let state = worker
.view_state(&contract_id)
.await?
.remove(b"STATE".as_slice())
.unwrap();

let state = state_items.remove(b"STATE".as_slice()).unwrap();
let status_msg = StatusMessage::try_from_slice(&state)?;

(contract_id, status_msg)
(contract_id, state)
};

info!(target: "spooning", "Testnet: {:?}", status_msg);
info!(target: "spooning", "Testnet: {:?}", StatusMessage::try_from_slice(&status_msg)?);

// Create our sandboxed environment and grab a worker to do stuff in it:
let worker = near_workspaces::sandbox().await?;
Expand All @@ -99,7 +100,7 @@ async fn main() -> anyhow::Result<()> {

// Patch our testnet STATE into our local sandbox:
worker
.patch_state(sandbox_contract.id(), b"STATE", &status_msg.try_to_vec()?)
.patch_state(sandbox_contract.id(), b"STATE", &status_msg)
.await?;

// Now grab the state to see that it has indeed been patched:
Expand Down
2 changes: 2 additions & 0 deletions workspaces/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
)),
_ => ErrorKind::Io.custom(e),
})?;

let cargo_near_build_command = cargo_near::BuildCommand {
release: true,
embed_abi: true,
Expand All @@ -28,6 +29,7 @@ pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
.map_err(|e| ErrorKind::Io.custom(e))?,
),
};

let compile_artifact =
cargo_near::build::run(cargo_near_build_command).map_err(|e| ErrorKind::Io.custom(e))?;

Expand Down
2 changes: 1 addition & 1 deletion workspaces/src/types/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Account {
let outcome = self
.worker
.client()
.deploy(&self.signer, self.id(), wasm.as_ref().into())
.deploy(&self.signer, self.id(), wasm.into())
.await?;

Ok(Execution {
Expand Down
Loading