Skip to content
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
12 changes: 6 additions & 6 deletions bindings/go/iota_sdk/iota_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -37336,21 +37336,21 @@ func (e TransactionArgumentGasCoin) Destroy() {
}
// An input to the programmable transaction block.
type TransactionArgumentInput struct {
Ix uint32
Index uint32
}

func (e TransactionArgumentInput) Destroy() {
FfiDestroyerUint32{}.Destroy(e.Ix);
FfiDestroyerUint32{}.Destroy(e.Index);
}
// The result of another transaction command.
type TransactionArgumentResult struct {
Cmd uint32
Ix *uint32
Index *uint32
}

func (e TransactionArgumentResult) Destroy() {
FfiDestroyerUint32{}.Destroy(e.Cmd);
FfiDestroyerOptionalUint32{}.Destroy(e.Ix);
FfiDestroyerOptionalUint32{}.Destroy(e.Index);
}

type FfiConverterTransactionArgument struct {}
Expand Down Expand Up @@ -37390,11 +37390,11 @@ func (FfiConverterTransactionArgument) Write(writer io.Writer, value Transaction
writeInt32(writer, 1)
case TransactionArgumentInput:
writeInt32(writer, 2)
FfiConverterUint32INSTANCE.Write(writer, variant_value.Ix)
FfiConverterUint32INSTANCE.Write(writer, variant_value.Index)
case TransactionArgumentResult:
writeInt32(writer, 3)
FfiConverterUint32INSTANCE.Write(writer, variant_value.Cmd)
FfiConverterOptionalUint32INSTANCE.Write(writer, variant_value.Ix)
FfiConverterOptionalUint32INSTANCE.Write(writer, variant_value.Index)
default:
_ = variant_value
panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterTransactionArgument.Write", value))
Expand Down
12 changes: 6 additions & 6 deletions bindings/kotlin/lib/iota_sdk/iota_sdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60944,7 +60944,7 @@ sealed class TransactionArgument {
/**
* Index of the programmable transaction block input (0-indexed).
*/
val `ix`: kotlin.UInt) : TransactionArgument() {
val `index`: kotlin.UInt) : TransactionArgument() {
companion object
}

Expand All @@ -60962,7 +60962,7 @@ sealed class TransactionArgument {
* of the individual result among the multiple results from
* that command (also 0-indexed).
*/
val `ix`: kotlin.UInt?) : TransactionArgument() {
val `index`: kotlin.UInt?) : TransactionArgument() {
companion object
}

Expand Down Expand Up @@ -61000,15 +61000,15 @@ public object FfiConverterTypeTransactionArgument : FfiConverterRustBuffer<Trans
// Add the size for the Int that specifies the variant plus the size needed for all fields
(
4UL
+ FfiConverterUInt.allocationSize(value.`ix`)
+ FfiConverterUInt.allocationSize(value.`index`)
)
}
is TransactionArgument.Result -> {
// Add the size for the Int that specifies the variant plus the size needed for all fields
(
4UL
+ FfiConverterUInt.allocationSize(value.`cmd`)
+ FfiConverterOptionalUInt.allocationSize(value.`ix`)
+ FfiConverterOptionalUInt.allocationSize(value.`index`)
)
}
}
Expand All @@ -61021,13 +61021,13 @@ public object FfiConverterTypeTransactionArgument : FfiConverterRustBuffer<Trans
}
is TransactionArgument.Input -> {
buf.putInt(2)
FfiConverterUInt.write(value.`ix`, buf)
FfiConverterUInt.write(value.`index`, buf)
Unit
}
is TransactionArgument.Result -> {
buf.putInt(3)
FfiConverterUInt.write(value.`cmd`, buf)
FfiConverterOptionalUInt.write(value.`ix`, buf)
FfiConverterOptionalUInt.write(value.`index`, buf)
Unit
}
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
Expand Down
28 changes: 14 additions & 14 deletions bindings/python/lib/iota_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -22462,22 +22462,22 @@ class INPUT:
An input to the programmable transaction block.
"""

ix: "int"
index: "int"
"""
Index of the programmable transaction block input (0-indexed).
"""


def __init__(self,ix: "int"):
self.ix = ix
def __init__(self,index: "int"):
self.index = index

def __str__(self):
return "TransactionArgument.INPUT(ix={})".format(self.ix)
return "TransactionArgument.INPUT(index={})".format(self.index)

def __eq__(self, other):
if not other.is_INPUT():
return False
if self.ix != other.ix:
if self.index != other.index:
return False
return True

Expand All @@ -22492,27 +22492,27 @@ class RESULT:
result.
"""

ix: "typing.Optional[int]"
index: "typing.Optional[int]"
"""
If the previous command returns multiple values, this is the index
of the individual result among the multiple results from
that command (also 0-indexed).
"""


def __init__(self,cmd: "int", ix: "typing.Optional[int]"):
def __init__(self,cmd: "int", index: "typing.Optional[int]"):
self.cmd = cmd
self.ix = ix
self.index = index

def __str__(self):
return "TransactionArgument.RESULT(cmd={}, ix={})".format(self.cmd, self.ix)
return "TransactionArgument.RESULT(cmd={}, index={})".format(self.cmd, self.index)

def __eq__(self, other):
if not other.is_RESULT():
return False
if self.cmd != other.cmd:
return False
if self.ix != other.ix:
if self.index != other.index:
return False
return True

Expand Down Expand Up @@ -22567,11 +22567,11 @@ def check_lower(value):
if value.is_GAS_COIN():
return
if value.is_INPUT():
_UniffiConverterUInt32.check_lower(value.ix)
_UniffiConverterUInt32.check_lower(value.index)
return
if value.is_RESULT():
_UniffiConverterUInt32.check_lower(value.cmd)
_UniffiConverterOptionalUInt32.check_lower(value.ix)
_UniffiConverterOptionalUInt32.check_lower(value.index)
return
raise ValueError(value)

Expand All @@ -22581,11 +22581,11 @@ def write(value, buf):
buf.write_i32(1)
if value.is_INPUT():
buf.write_i32(2)
_UniffiConverterUInt32.write(value.ix, buf)
_UniffiConverterUInt32.write(value.index, buf)
if value.is_RESULT():
buf.write_i32(3)
_UniffiConverterUInt32.write(value.cmd, buf)
_UniffiConverterOptionalUInt32.write(value.ix, buf)
_UniffiConverterOptionalUInt32.write(value.index, buf)



Expand Down
190 changes: 186 additions & 4 deletions crates/iota-sdk-ffi/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ use crate::{
object::{MovePackage, Object, ObjectId},
signature::UserSignature,
struct_tag::StructTag,
transaction::{
DryRunResult, SignedTransaction, Transaction, TransactionEffects, TransactionKind,
},
transaction::{SignedTransaction, Transaction, TransactionEffects, TransactionKind},
type_tag::TypeTag,
},
uniffi_helpers::{
Expand Down Expand Up @@ -984,9 +982,193 @@ pub struct Query {
pub variables: Option<serde_json::Value>,
}

/// A transaction argument used in programmable transactions.
#[derive(uniffi::Enum)]
pub enum TransactionArgument {
/// Reference to the gas coin.
GasCoin,
/// An input to the programmable transaction block.
Input {
/// Index of the programmable transaction block input (0-indexed).
index: u32,
},
/// The result of another transaction command.
Result {
/// The index of the previous command (0-indexed) that returned this
/// result.
cmd: u32,
/// If the previous command returns multiple values, this is the index
/// of the individual result among the multiple results from
/// that command (also 0-indexed).
index: Option<u32>,
},
}

impl From<iota_sdk::graphql_client::TransactionArgument> for TransactionArgument {
fn from(value: iota_sdk::graphql_client::TransactionArgument) -> Self {
match value {
iota_sdk::graphql_client::TransactionArgument::GasCoin => TransactionArgument::GasCoin,
iota_sdk::graphql_client::TransactionArgument::Input { index } => {
TransactionArgument::Input { index }
}
iota_sdk::graphql_client::TransactionArgument::Result { cmd, index } => {
TransactionArgument::Result { cmd, index }
}
_ => unimplemented!("a new enum variant was added and needs to be handled"),
}
}
}

impl From<TransactionArgument> for iota_sdk::graphql_client::TransactionArgument {
fn from(value: TransactionArgument) -> Self {
match value {
TransactionArgument::GasCoin => iota_sdk::graphql_client::TransactionArgument::GasCoin,
TransactionArgument::Input { index } => {
iota_sdk::graphql_client::TransactionArgument::Input { index }
}
TransactionArgument::Result { cmd, index } => {
iota_sdk::graphql_client::TransactionArgument::Result { cmd, index }
}
}
}
}

/// A return value from a command in the dry run.
#[derive(uniffi::Record)]
pub struct DryRunReturn {
/// The Move type of the return value.
pub type_tag: Arc<TypeTag>,
/// The BCS representation of the return value.
pub bcs: Vec<u8>,
}

impl From<iota_sdk::graphql_client::DryRunReturn> for DryRunReturn {
fn from(value: iota_sdk::graphql_client::DryRunReturn) -> Self {
DryRunReturn {
type_tag: Arc::new(value.type_tag.into()),
bcs: value.bcs,
}
}
}

impl From<DryRunReturn> for iota_sdk::graphql_client::DryRunReturn {
fn from(value: DryRunReturn) -> Self {
iota_sdk::graphql_client::DryRunReturn {
type_tag: value.type_tag.0.clone(),
bcs: value.bcs,
}
}
}

/// A mutation to an argument that was mutably borrowed by a command.
#[derive(uniffi::Record)]
pub struct DryRunMutation {
/// The transaction argument that was mutated.
pub input: TransactionArgument,
/// The Move type of the mutated value.
pub type_tag: Arc<TypeTag>,
/// The BCS representation of the mutated value.
pub bcs: Vec<u8>,
}

impl From<iota_sdk::graphql_client::DryRunMutation> for DryRunMutation {
fn from(value: iota_sdk::graphql_client::DryRunMutation) -> Self {
DryRunMutation {
input: value.input.into(),
type_tag: Arc::new(value.type_tag.into()),
bcs: value.bcs,
}
}
}

impl From<DryRunMutation> for iota_sdk::graphql_client::DryRunMutation {
fn from(value: DryRunMutation) -> Self {
iota_sdk::graphql_client::DryRunMutation {
input: value.input.into(),
type_tag: value.type_tag.0.clone(),
bcs: value.bcs,
}
}
}

/// Effects of a single command in the dry run, including mutated references
/// and return values.
#[derive(uniffi::Record)]
pub struct DryRunEffect {
/// Changes made to arguments that were mutably borrowed by this command.
pub mutated_references: Vec<DryRunMutation>,
/// Return results of this command.
pub return_values: Vec<DryRunReturn>,
}

impl From<iota_sdk::graphql_client::DryRunEffect> for DryRunEffect {
fn from(value: iota_sdk::graphql_client::DryRunEffect) -> Self {
DryRunEffect {
mutated_references: value
.mutated_references
.into_iter()
.map(Into::into)
.collect(),
return_values: value.return_values.into_iter().map(Into::into).collect(),
}
}
}

impl From<DryRunEffect> for iota_sdk::graphql_client::DryRunEffect {
fn from(value: DryRunEffect) -> Self {
iota_sdk::graphql_client::DryRunEffect {
mutated_references: value
.mutated_references
.into_iter()
.map(Into::into)
.collect(),
return_values: value.return_values.into_iter().map(Into::into).collect(),
}
}
}

/// The result of a simulation (dry run), which includes the effects of the
/// transaction, any errors that may have occurred, and intermediate results for
/// each command.
#[derive(uniffi::Record)]
pub struct DryRunResult {
/// The error that occurred during dry run execution, if any.
pub error: Option<String>,
/// The intermediate results for each command of the dry run execution,
/// including contents of mutated references and return values.
pub results: Vec<DryRunEffect>,
/// The transaction block representing the dry run execution.
pub transaction: Option<SignedTransaction>,
/// The effects of the transaction execution.
pub effects: Option<Arc<TransactionEffects>>,
}

impl From<iota_sdk::graphql_client::DryRunResult> for DryRunResult {
fn from(value: iota_sdk::graphql_client::DryRunResult) -> Self {
DryRunResult {
error: value.error,
results: value.results.into_iter().map(Into::into).collect(),
transaction: value.transaction.map(Into::into),
effects: value.effects.map(Into::into).map(Arc::new),
}
}
}

impl From<DryRunResult> for iota_sdk::graphql_client::DryRunResult {
fn from(value: DryRunResult) -> Self {
iota_sdk::graphql_client::DryRunResult {
error: value.error,
results: value.results.into_iter().map(Into::into).collect(),
transaction: value.transaction.map(Into::into),
effects: value.effects.map(|v| v.0.clone()),
}
}
}

impl iota_sdk::transaction_builder::ClientMethods for GraphQLClient {
type Error =
<iota_sdk::graphql_client::Client as iota_sdk::transaction_builder::ClientMethods>::Error;
type DryRunResult = iota_sdk::graphql_client::DryRunResult;

async fn object(
&self,
Expand Down Expand Up @@ -1064,7 +1246,7 @@ impl iota_sdk::transaction_builder::ClientMethods for GraphQLClient {
&self,
tx: &iota_sdk::types::Transaction,
skip_checks: bool,
) -> Result<iota_sdk::types::DryRunResult, Self::Error> {
) -> Result<Self::DryRunResult, Self::Error> {
iota_sdk::transaction_builder::ClientMethods::dry_run_tx(
&*self.0.read().await,
tx,
Expand Down
Loading