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

Transaction Builder #41

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Transaction Builder #41

wants to merge 29 commits into from

Conversation

stefan-mysten
Copy link
Collaborator

This is the first iteration on the transaction builder. I expect that it is not 100% correct as there are some areas that I am not sure about, thus I decided to push a PR to get some feedback.

Might be easier to go over it in a call, so we can also do that.

crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/lib.rs Show resolved Hide resolved
crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/lib.rs Show resolved Hide resolved
crates/sui-transaction-builder/src/object.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/object.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/object.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/object.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/object.rs Outdated Show resolved Hide resolved
@stefan-mysten
Copy link
Collaborator Author

Thanks so much for the review @amnn 🚀

@stefan-mysten
Copy link
Collaborator Author

Bring in the macros for identifier, function, objectId, typetag.

@stefan-mysten
Copy link
Collaborator Author

stefan-mysten commented Nov 25, 2024

@amnn @bmwill I added a basic Move project and changed the CI and Makefile to build it and get the modules, dependencies, and digest from the build instead of hard coding them.
It's unfortunate that sui move build --dump requires a client.yaml file...

I think I've addressed most comments and the only thing that's left is errors.

@stefan-mysten
Copy link
Collaborator Author

I can't figure out why the CI fails on PR but not on push.

@bmwill
Copy link
Collaborator

bmwill commented Nov 25, 2024

Have you rebased on the latest tip of master?

@stefan-mysten
Copy link
Collaborator Author

Have you rebased on the latest tip of master?

I did, unless I messed something up. I will retry.

@stefan-mysten
Copy link
Collaborator Author

Have you rebased on the latest tip of master?

Double checked, it's rebased on master branch. 😢

scripts/cli/client.yaml Outdated Show resolved Hide resolved
crates/sui-transaction-builder/Makefile Outdated Show resolved Hide resolved
Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small issue with IntoInput and in particular the way it's implemented for Object, but otherwise this is good to go in my book! 🚀 well done @stefan-mysten

Makefile Outdated Show resolved Hide resolved
crates/sui-transaction-builder/Cargo.toml Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/error.rs Show resolved Hide resolved
scripts/cli/client.yaml Outdated Show resolved Hide resolved
/// A trait to convert a type into an [`unresolved::Input`]. This is mostly used for gas objects,
/// to pass them either as literals, as an object id, as a reference to an object, or as a
/// [`unresolved::Input`] object.
pub trait IntoInput {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why its own trait, vs Into<unresolved::Input>?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unresolved::Input is not defined into this crate, so I cannot do Into<unresolved::Input>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the rule -- you can't implement From<X> for unresolved::Input because it's from a different crate. You're fine to implement Into<unresolved::Input> for X.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I am doing something wrong or maybe it's a new rule in Rust 1.81?

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
   --> crates/sui-transaction-builder/src/lib.rs:402:1
    |
402 | impl Into<unresolved::Input> for &Object {
    | ^^^^^-----------------------^^^^^-------
    | |    |                           |
    | |    |                           `sui_sdk_types::types::Object` is not defined in the current crate
    | |    `sui_sdk_types::types::unresolved::Input` is not defined in the current crate
    | impl doesn't use only types from inside the current crate
    |
    = note: define and implement a trait or new type instead

Copy link
Collaborator Author

@stefan-mysten stefan-mysten Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this into unresolved module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We spoke about this offline, but for posterity the issue here is that Object is from a different crate, not Input)

crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
objects: self
.gas
.into_iter()
.map(try_from_gas_unresolved_input_to_unresolved_obj_ref)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is a gas payment we know up front that it has to be an object reference so we should on the client side be able to take a literal and make it an object id.

That works too!

crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final round of comments from me, I think -- the latest round of changes opened a Pandora's box around unresolved::Input (IntoInput + the builder API mainly).

Makefile Outdated
@@ -24,9 +24,12 @@ test:
cargo nextest run --all-features -p sui-sdk-types -p sui-crypto
cargo test --doc

package_%.json:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule needs to depend on the contents of the test package (its Move.toml and source files), otherwise it won't rebuild when you change them.

Copy link
Collaborator Author

@stefan-mysten stefan-mysten Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to add something but not sure how to test it. Also, because test-with-localnet is phony, I think this rule will always be called?

https://www.math.utah.edu/docs/info/make_toc.html#SEC34

crates/sui-sdk-types/src/types/transaction/unresolved.rs Outdated Show resolved Hide resolved
crates/sui-transaction-builder/src/lib.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants