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

Make cross-contract callee non-optional #1636

Merged
merged 12 commits into from
Feb 1, 2023

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Feb 1, 2023

Suggestion for how to enforce callee in #1255.

This breaks the CallBuilder API by introducing two new methods: call and delegate, which can
be used to streamline the CallBuilder set-up for the respective call types.

@ascjones ascjones marked this pull request as ready for review February 1, 2023 13:06
call_flags: self.call_flags,
exec_input: self.exec_input,
return_type: self.return_type,
_phantom: Default::default(),
}
}

/// Sets the `code_hash` for the current cross-contract delegate call.
pub fn code_hash(
Copy link
Contributor

Choose a reason for hiding this comment

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

So @ascjones I guess what you're suggesting is we rename this to delegate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes exactly, so by calling one method or the other we instantiate the builder type for the type of call we want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually maybe the choices are

  1. callee & code_hash
  2. call & delegate

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, but then we should rename the callee builder method to call

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🧠 🤝 🧠

Copy link
Contributor

Choose a reason for hiding this comment

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

More like 🥜 🤝 🥜

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deez nuts

@ascjones
Copy link
Collaborator Author

ascjones commented Feb 1, 2023

Not going to wait for examples test to run, tests run locally okay and it is hanging occasionally.

@ascjones ascjones merged commit c86692f into hc-remove-default-account-id Feb 1, 2023
@ascjones ascjones deleted the aj/remove-default-account-id branch February 1, 2023 18:33
ascjones added a commit that referenced this pull request Feb 1, 2023
* Remove `Default` bound on `AccountId` type

* Manually implement storage traits for AccountID

Since it doesn't implement `Default` we can't use the macro
implementations anymore.

* Update `Call` builder to not use default AccountId

* Use non-Default bound functions when reading AccountIds

* Remove unused `get_property_inplace` method

* Update `CallParams` to use `None` when no account ID is set

* Update examples to explicitly use zero address

* Remove unused environment function

* Manually implement `Default` in DNS example

* Fix spellcheck

* Correctly encode the `callee` account ID when calling `pallet-contracts`

* Update `CHANGELOG`

* Make cross-contract callee non-optional (#1636)

* Make cross-contract callee non-optional

* clippy

* Fmt

* Fix

* clippy

* clippy

* clippy

* Add a similar method for `code_hash`

* Fix doc tests

* RustFmt

* Rename top level methods to `call` and `delegate`

* Fix some renames

---------

Co-authored-by: Hernando Castano <hernando@hcastano.com>

---------

Co-authored-by: Andrew Jones <ascjones@gmail.com>
@ascjones ascjones mentioned this pull request Feb 15, 2023
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.

2 participants