fix(aquavm-air-cli): NEAR mode fixes (#679)

1. Correct default contract path.
2. More informative error messages.
3. Deserialize contract result correctly.
This commit is contained in:
Ivan Boldyrev 2023-08-19 00:41:50 +07:00 committed by GitHub
parent 27a99fcca0
commit 6978603c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 15 deletions

12
Cargo.lock generated
View File

@ -113,7 +113,7 @@ dependencies = [
"newtype_derive",
"num-traits",
"once_cell",
"polyplets 0.4.1",
"polyplets 0.5.0",
"semver 1.0.18",
"serde",
"serde_json",
@ -216,7 +216,7 @@ dependencies = [
"bimap",
"log",
"num-traits",
"polyplets 0.4.1",
"polyplets 0.5.0",
"serde_json",
"thiserror",
"tracing",
@ -345,7 +345,7 @@ dependencies = [
"marine-rs-sdk",
"non-empty-vec",
"once_cell",
"polyplets 0.4.1",
"polyplets 0.5.0",
"pretty_assertions 0.6.1",
"semver 1.0.18",
"serde",
@ -573,7 +573,7 @@ dependencies = [
"air-utils",
"log",
"maplit",
"polyplets 0.4.1",
"polyplets 0.5.0",
"serde",
"serde_json",
"thiserror",
@ -594,7 +594,7 @@ dependencies = [
"maplit",
"marine-runtime",
"parking_lot 0.12.1",
"polyplets 0.4.1",
"polyplets 0.5.0",
"serde",
"serde_json",
"thiserror",
@ -4101,7 +4101,7 @@ dependencies = [
[[package]]
name = "polyplets"
version = "0.5.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b579a79a461ca50abb202eac61c76d8782fdf091a91775c9e181352e7cd30a8b"
dependencies = [

View File

@ -61,7 +61,7 @@ pub(crate) struct Args {
#[clap(
long = "near-contract",
env = "AIR_NEAR_CONTRACT_PATH",
default_value = "tools/wasm/air-near-contract/target/wasm32-unknown-unknown/release/aqua_vm.wasm"
default_value = "tools/wasm/air-near-contract/target/wasm32-unknown-unknown/release/air-near-contract.wasm"
)]
air_near_contract_path: PathBuf,

View File

@ -16,7 +16,9 @@
use super::runner::AirRunner;
use air_interpreter_interface::InterpreterOutcome;
use air_interpreter_interface::RunParameters;
use anyhow::Context;
use avm_interface::raw_outcome::RawAVMOutcome;
use fluence_keypair::KeyPair;
@ -112,11 +114,16 @@ fn execute_on_near(
))
.transact()
.await
})?;
})
.context("failed to execute contract")?;
eprintln!("total gas: {:e}", result.total_gas_burnt);
eprintln!("transaction gas: {:e}", result.outcome().gas_burnt);
let data: String = result.borsh()?;
serde_json::from_str(&data).map_err(Into::into)
let data: String = result
.borsh()
.context("failed to deserialize contract result")?;
let outcome: InterpreterOutcome =
serde_json::from_str(&data).context("failed to parse JSON data")?;
Ok(RawAVMOutcome::from_interpreter_outcome(outcome)?)
}

View File

@ -56,7 +56,7 @@ dependencies = [
"newtype_derive",
"num-traits",
"once_cell",
"polyplets 0.4.1",
"polyplets 0.5.0",
"semver 1.0.18",
"serde",
"serde_json",
@ -65,7 +65,7 @@ dependencies = [
[[package]]
name = "air-interpreter-interface"
version = "0.14.0"
version = "0.15.0"
dependencies = [
"fluence-it-types",
"marine-rs-sdk",
@ -133,7 +133,7 @@ dependencies = [
"bimap",
"log",
"num-traits",
"polyplets 0.4.1",
"polyplets 0.5.0",
"serde_json",
"thiserror",
"tracing",
@ -179,7 +179,7 @@ dependencies = [
"maplit",
"non-empty-vec",
"once_cell",
"polyplets 0.4.1",
"polyplets 0.5.0",
"semver 1.0.18",
"serde",
"serde_json",
@ -1627,7 +1627,7 @@ dependencies = [
[[package]]
name = "polyplets"
version = "0.4.1"
version = "0.5.0"
dependencies = [
"marine-rs-sdk",
"serde",