Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion bindings/go/examples/generic_move_function/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
nil,
)

builder.Gas(gas_coin_id)
builder.Gas(gas_coin_id).GasBudget(1000000000)

res, err := builder.DryRun(false)
if err.(*sdk.SdkFfiError) != nil {
Expand Down
2 changes: 1 addition & 1 deletion bindings/kotlin/examples/GenericMoveFunction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fun main() = runBlocking {
)
)

builder.gas(gasCoinId)
builder.gas(gasCoinId).gasBudget(1000000000uL)

val res = builder.dryRun()

Expand Down
2 changes: 1 addition & 1 deletion bindings/python/examples/generic_move_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def main():
[TypeTag.new_address(), TypeTag.new_u64()],
)

builder.gas(gas_coin_id)
builder.gas(gas_coin_id).gas_budget(1000000000)

res = await builder.dry_run()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async fn main() -> Result<()> {
.move_call(Address::TWO, "vec_map", "from_keys_values")
.generics::<(Address, u64)>()
.arguments((vec![address1, address2], vec![10000000u64, 20000000u64]))
.gas("0xa1d009e8dafe20b1cba05e08aea488aafae1f89d892c3eaef6c0994e155e441a".parse()?);
.gas("0xa1d009e8dafe20b1cba05e08aea488aafae1f89d892c3eaef6c0994e155e441a".parse()?)
.gas_budget(1000000000);

let res = builder.dry_run(false).await?;

Expand Down
33 changes: 31 additions & 2 deletions crates/iota-transaction-builder/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use std::{
};

use iota_crypto::IotaSigner;
use iota_graphql_client::{Client, DryRunResult};
use iota_graphql_client::{
Client, DryRunResult,
query_types::{ObjectRef, TransactionMetadata},
};
use iota_types::{
Address, GasPayment, Identifier, ObjectId, ObjectReference, Owner, ProgrammableTransaction,
Transaction, TransactionEffects, TransactionExpiration, TypeTag,
Expand Down Expand Up @@ -832,9 +835,35 @@ impl<L> TransactionBuilder<Client, L> {
/// Dry run the transaction.
pub async fn dry_run(mut self, skip_checks: bool) -> Result<DryRunResult, Error> {
let txn = self.resolve_ptb().await?;
if !txn.gas_payment.objects.is_empty() && txn.gas_payment.budget == 0 {
return Err(Error::DryRun(format!(
"gas coins were provided without a gas budget"
)));
}
let gas_objects = txn
.gas_payment
.objects
.iter()
.map(|r| ObjectRef {
address: r.object_id,
digest: r.digest.to_base58(),
version: r.version,
})
.collect::<Vec<_>>();
let res = self
.client
.dry_run_tx(&txn, skip_checks)
.dry_run_tx_kind(
&txn.kind,
skip_checks,
TransactionMetadata {
gas_objects: (!gas_objects.is_empty()).then_some(gas_objects),
gas_budget: (txn.gas_payment.budget != 0).then_some(txn.gas_payment.budget),
gas_price: Some(txn.gas_payment.price),
gas_sponsor: Some(txn.gas_payment.owner),
sender: Some(txn.sender),
..Default::default()
},
)
.await
.map_err(Error::Client)?;
Ok(res)
Expand Down
Loading