-
Notifications
You must be signed in to change notification settings - Fork 628
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
feat(core): Defined AccountId to hold a contract of being valid #2831
Conversation
derive_more::AsRef, | ||
derive_more::Into, | ||
serde::Serialize, | ||
serde::Deserialize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Implement custom Deserialize with validation.
serde::Serialize, | ||
serde::Deserialize, | ||
borsh::BorshSerialize, | ||
borsh::BorshDeserialize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Implement custom BorshDeserialize with validation.
This PR has been automatically marked as stale because it has not had recent activity in the 2 weeks. |
Closing in favor of #4440 |
…4440) This PR introduces a strictly typed structure - `AccountId` that enforces account ID validation. This way, we can ensure validity and thereby fail fast before an invalid account name is used. This also, optionally, ensures validation on {,de}serialization so, yeah.. The structure is defined within its own self-contained crate `near-account-id` to allow for easy publishing. The extra dependencies - `borsh`, `serde` are made optional to allow the crate to be lightweight enough to be depended upon. Within `nearcore`, the structure is reexported via `near_primitives::AccountId` and the crate via `near_primitives{,_core}::account::id` with default features (`borsh`, `serde`) but you can opt-out of those by depending on it directly. Resolves #2074, supersedes #2831. # Testing Plan * [x] Existing unit tests pass with minor updates * [x] Nayduck tests pass without modifications * [x] Manually ensured that the protocol is not changed
…ear#4440) This PR introduces a strictly typed structure - `AccountId` that enforces account ID validation. This way, we can ensure validity and thereby fail fast before an invalid account name is used. This also, optionally, ensures validation on {,de}serialization so, yeah.. The structure is defined within its own self-contained crate `near-account-id` to allow for easy publishing. The extra dependencies - `borsh`, `serde` are made optional to allow the crate to be lightweight enough to be depended upon. Within `nearcore`, the structure is reexported via `near_primitives::AccountId` and the crate via `near_primitives{,_core}::account::id` with default features (`borsh`, `serde`) but you can opt-out of those by depending on it directly. Resolves near#2074, supersedes near#2831. # Testing Plan * [x] Existing unit tests pass with minor updates * [x] Nayduck tests pass without modifications * [x] Manually ensured that the protocol is not changed
…4440) This PR introduces a strictly typed structure - `AccountId` that enforces account ID validation. This way, we can ensure validity and thereby fail fast before an invalid account name is used. This also, optionally, ensures validation on {,de}serialization so, yeah.. The structure is defined within its own self-contained crate `near-account-id` to allow for easy publishing. The extra dependencies - `borsh`, `serde` are made optional to allow the crate to be lightweight enough to be depended upon. Within `nearcore`, the structure is reexported via `near_primitives::AccountId` and the crate via `near_primitives{,_core}::account::id` with default features (`borsh`, `serde`) but you can opt-out of those by depending on it directly. Resolves #2074, supersedes #2831. * [x] Existing unit tests pass with minor updates * [x] Nayduck tests pass without modifications * [x] Manually ensured that the protocol is not changed
# refactor: Introduce strictly typed and assuredly validated AccountId (#4440) This PR introduces a strictly typed structure - `AccountId` that enforces account ID validation. This way, we can ensure validity and thereby fail fast before an invalid account name is used. This also, optionally, ensures validation on {,de}serialization so, yeah.. The structure is defined within its own self-contained crate `near-account-id` to allow for easy publishing. The extra dependencies - `borsh`, `serde` are made optional to allow the crate to be lightweight enough to be depended upon. Within `nearcore`, the structure is reexported via `near_primitives::AccountId` and the crate via `near_primitives{,_core}::account::id` with default features (`borsh`, `serde`) but you can opt-out of those by depending on it directly. Resolves #2074, supersedes #2831. * [x] Existing unit tests pass with minor updates * [x] Nayduck tests pass without modifications * [x] Manually ensured that the protocol is not changed # impl workaround for invalid AccessKey-s in genesis records (resolves #4600) * [x] Manually booted a testnet node to ensure genesis loads properly and that no further AccountId-related issues occur. * [x] Ensured unit tests pass with no further updates * [x] Nayduck tests pass without modifications
This PR introduces a strictly typed structure - `AccountId` that enforces account ID validation. This way, we can ensure validity and thereby fail fast before an invalid account name is used. This also, optionally, ensures validation on {,de}serialization so, yeah.. The structure is defined within its own self-contained crate `near-account-id` to allow for easy publishing. The extra dependencies - `borsh`, `serde` are made optional to allow the crate to be lightweight enough to be depended upon. Within `nearcore`, the structure is reexported via `near_primitives::AccountId` and the crate via `near_primitives{,_core}::account::id` with default features (`borsh`, `serde`) but you can opt-out of those by depending on it directly. Resolves #2074, supersedes #2831. * [x] Existing unit tests pass with minor updates * [x] Nayduck tests pass without modifications * [x] Manually ensured that the protocol is not changed * [x] Manually booted a testnet node to ensure genesis loads properly and that no further AccountId-related issues occur. * [x] Ensured unit tests pass with no further updates * [x] Nayduck tests pass without modifications
This is work-in-progress, there are tons of compilation errors (though primitives crate compiles). I decided to push it to git just in case, I am currently busy with other tasks.
Resolves #2074.