-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sui-graphql-client: add dry run query (#23)
- Loading branch information
1 parent
112bfb3
commit 2699101
Showing
4 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use sui_types::types::ObjectReference; | ||
|
||
use crate::query_types::schema; | ||
use crate::query_types::Address; | ||
use crate::query_types::TransactionBlock; | ||
|
||
#[derive(cynic::QueryFragment, Debug)] | ||
#[cynic(schema = "rpc", graphql_type = "Query", variables = "DryRunArgs")] | ||
pub struct DryRunQuery { | ||
#[arguments(txBytes: $tx_bytes, skipChecks: $skip_checks, txMeta: $tx_meta)] | ||
pub dry_run_transaction_block: DryRunResult, | ||
} | ||
|
||
#[derive(cynic::QueryFragment, Debug)] | ||
#[cynic(schema = "rpc", graphql_type = "DryRunResult")] | ||
pub struct DryRunResult { | ||
pub error: Option<String>, | ||
pub transaction: Option<TransactionBlock>, | ||
} | ||
|
||
#[derive(cynic::QueryVariables, Debug)] | ||
pub struct DryRunArgs { | ||
pub tx_bytes: String, | ||
pub skip_checks: bool, | ||
pub tx_meta: Option<TransactionMetadata>, | ||
} | ||
|
||
#[derive(cynic::InputObject, Debug)] | ||
#[cynic(schema = "rpc", graphql_type = "TransactionMetadata")] | ||
pub struct TransactionMetadata { | ||
pub gas_budget: Option<u64>, | ||
pub gas_objects: Option<Vec<ObjectRef>>, | ||
pub gas_price: Option<u64>, | ||
pub gas_sponsor: Option<Address>, | ||
pub sender: Option<Address>, | ||
} | ||
|
||
#[derive(cynic::InputObject, Debug)] | ||
#[cynic(schema = "rpc", graphql_type = "ObjectRef")] | ||
pub struct ObjectRef { | ||
pub address: Address, | ||
pub digest: String, | ||
pub version: u64, | ||
} | ||
|
||
impl From<ObjectReference> for ObjectRef { | ||
fn from(value: ObjectReference) -> Self { | ||
let address: Address = (*value.object_id()).into(); | ||
ObjectRef { | ||
address, | ||
version: value.version(), | ||
digest: value.digest().to_string(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters