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

Separate types for UserApplicationId and ApplicationId. #3582

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

deuszx
Copy link
Contributor

@deuszx deuszx commented Mar 17, 2025

Motivation

We want to fix and expand our notion of Address (currently Owner, GenericApplicationId, etc.) to different type of addresses (32-byte Linera/Solana, 20-byte EVM). In order to do that we need to prepare the code for the introduction of new variants.

Proposal

Add a separate type for UserApplicationId(hash) vs ApplicationId (a hash + type-safe ABI). Previously the presence of A type parameter in "address" enum made it more difficult to refactor. After this PR we have separate types for application's address and application with ABI (used mostly in tests and CLI now).

Note: This is an alternative to #3570 . Where I kept the UserApplicationId name but promoted it to a newtype.

Test Plan

CI should catch regressions.

Release Plan

  • Nothing to do / These changes follow the usual release cycle.

Links

@deuszx deuszx marked this pull request as ready for review March 17, 2025 11:09
@deuszx deuszx requested review from afck and ma2bd March 17, 2025 11:13
Copy link
Contributor

@afck afck left a comment

Choose a reason for hiding this comment

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

Will we need both types in the long run?

UserApplicationId,
"A unique identifier for a user application"
);
// bcs_scalar!(UserApplicationId, "A unique identifier for a user application");
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Must have forgotten to remove it.

@@ -304,7 +304,45 @@ pub struct ApplicationId<A = ()> {

/// Alias for `ApplicationId`. Use this alias in the core
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not an alias anymore.

@deuszx
Copy link
Contributor Author

deuszx commented Mar 17, 2025

Will we need both types in the long run?

They are used in different contexts:

  • UserApplicationId is just a wrapper around the address
  • Application carries the type-safe ABI that's useful in calls and queries

Maybe we will be able to get rid of UserApplicationId at some point and replace it with generic Address type (see #3576 for work in that direction).

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