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

Refactor the Account state #462

Merged
merged 75 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
0f6a76e
Get rid of `IdentitySnapshot`
PhilippGackstatter Oct 29, 2021
538a5aa
Start replacing parts of `IdentityState`
PhilippGackstatter Nov 1, 2021
dd5e5a7
Create identity document from core structures
PhilippGackstatter Nov 2, 2021
48224cb
Impl int/diff update determination
PhilippGackstatter Nov 3, 2021
915763f
Remove `Deref` impls for IdentityState
PhilippGackstatter Nov 3, 2021
d51ba7b
Implement `CreateMethod` update
PhilippGackstatter Nov 3, 2021
3d6476c
Impl attach/detach `MethodRelationship`
PhilippGackstatter Nov 3, 2021
683b388
Merge branch 'epic/account-refactor' into chore/state-refactor
PhilippGackstatter Nov 4, 2021
cb99939
Update to cap inv refactor
PhilippGackstatter Nov 4, 2021
e2583cc
Use `IotaDocument` directly to construct the doc
PhilippGackstatter Nov 4, 2021
877acc1
Update tests for account updates
PhilippGackstatter Nov 4, 2021
f3ca9d2
Remove unused types & variables
PhilippGackstatter Nov 5, 2021
71ce4ba
Return to unified publish method
PhilippGackstatter Nov 5, 2021
bdd0a17
Merge branch 'epic/account-refactor' into chore/state-refactor
PhilippGackstatter Nov 8, 2021
cf38e03
Implement & test attaching relationships
PhilippGackstatter Nov 8, 2021
cdeb63c
Fix attach/detach tests post-merge
PhilippGackstatter Nov 8, 2021
aff66b1
Implement detach relationship test
PhilippGackstatter Nov 8, 2021
3356f17
Implement insert and remove service
PhilippGackstatter Nov 8, 2021
a8da89d
Move `Publish` to low-level API
PhilippGackstatter Nov 9, 2021
26a86f7
Remove did field from account
PhilippGackstatter Nov 9, 2021
afb7a32
Refactor publishing & storing
PhilippGackstatter Nov 9, 2021
5660f6a
Rename int/diff generations
PhilippGackstatter Nov 9, 2021
c07cebf
Change fresh id detection & fix `store_state` call
PhilippGackstatter Nov 10, 2021
1330c5e
Factor out `ChainState` from `IdentityState`
PhilippGackstatter Nov 10, 2021
30e3085
Remove `this_message_id` from chain state
PhilippGackstatter Nov 10, 2021
12d292a
Test the chain state
PhilippGackstatter Nov 10, 2021
dd354e3
Fix some error TODOs
PhilippGackstatter Nov 10, 2021
bbde6a0
Fix some TODOs
PhilippGackstatter Nov 10, 2021
35733f6
Fix some storage todos/errors
PhilippGackstatter Nov 10, 2021
bfa24e3
Make `IotaDocument::remove_method` fallible again
PhilippGackstatter Nov 10, 2021
a63f8ca
Use name instead of identifier to call from_did
PhilippGackstatter Nov 11, 2021
29f6ecb
Move state loading into the else clause
PhilippGackstatter Nov 11, 2021
0edebbd
Remove `persist` flag on `process_update`
PhilippGackstatter Nov 11, 2021
314c3b3
Remove unnecessary cloning
PhilippGackstatter Nov 11, 2021
00fc3db
Rename `as_document` -> `document`
PhilippGackstatter Nov 11, 2021
3f4f941
Improve `ChainState` docs
PhilippGackstatter Nov 11, 2021
23bd282
Merge branch 'epic/account-refactor' into chore/state-refactor
PhilippGackstatter Nov 11, 2021
48eb055
Fix post-merge things & clippy lint
PhilippGackstatter Nov 11, 2021
12eb51a
Remove `Tiny*` and other unused state types
PhilippGackstatter Nov 11, 2021
bfc1f61
`InvalidMethodTarget` -> `InvalidTargetMethod`
PhilippGackstatter Nov 11, 2021
5009d57
`as_document_mut` -> `document_mut`
PhilippGackstatter Nov 11, 2021
542089b
Expand lazy test
PhilippGackstatter Nov 11, 2021
b7068f4
Rename impl_command_builder to update
PhilippGackstatter Nov 11, 2021
2a4d428
Remove event context
PhilippGackstatter Nov 11, 2021
15aee64
Rename `events` module to `updates`
PhilippGackstatter Nov 11, 2021
e807e5c
Apply fmt
PhilippGackstatter Nov 11, 2021
89d6c4d
Rename `commands` -> `updates`
PhilippGackstatter Nov 11, 2021
cbdaa25
Remove `UnixTimestamp`
PhilippGackstatter Nov 11, 2021
979b62f
Remove unused errors in account & update
PhilippGackstatter Nov 11, 2021
cb0cf35
Change `fromDID` method in Wasm
PhilippGackstatter Nov 12, 2021
35dac21
Return `Option<Publish>` from constructor
PhilippGackstatter Nov 12, 2021
828bbc0
Use strum, add todo!(), rename `PublishType`
PhilippGackstatter Nov 12, 2021
8bfe2fe
Move attach/detach relationship to `CoreDocument`
PhilippGackstatter Nov 12, 2021
51c2368
Return bool from `detach_method_relationship`
PhilippGackstatter Nov 12, 2021
551f158
Use `MethodQuery` in attach/detach
PhilippGackstatter Nov 12, 2021
8a49e0a
Revert "Change `fromDID` method in Wasm"
PhilippGackstatter Nov 12, 2021
2967bc4
Nest `MethodRelationship` in `MethodScope`
PhilippGackstatter Nov 12, 2021
0837e06
Move some chain state logic to publish_diff_change
PhilippGackstatter Nov 12, 2021
48446c4
Don't expect, bubble up
PhilippGackstatter Nov 12, 2021
73beaa3
Return early if there's nothing to publish
PhilippGackstatter Nov 12, 2021
473dc1e
Add todo about error handling
PhilippGackstatter Nov 12, 2021
4d16553
Remove mut state methods
PhilippGackstatter Nov 12, 2021
b3abf16
Move account constructors to the top
PhilippGackstatter Nov 12, 2021
e703cc6
Use `try_resolve_method_with_scope` in tests
PhilippGackstatter Nov 12, 2021
d5b2c85
Remove todos, inline code, explicitly ignore res.
PhilippGackstatter Nov 12, 2021
990e9d6
Remove todo comments, `unwrap`
PhilippGackstatter Nov 12, 2021
557e336
Rename chain state fields to `last_*`
PhilippGackstatter Nov 12, 2021
38b263e
Improve `InvalidTargetMethod` Error name
PhilippGackstatter Nov 12, 2021
5a01461
Increment actions when updating
PhilippGackstatter Nov 12, 2021
74be318
check for updated referenced method in publish
PhilippGackstatter Nov 15, 2021
806d11e
Enable diff updates for merkle cap. inv. methods
PhilippGackstatter Nov 15, 2021
8bc9fe9
Only attach relationship on non-embedded methods
PhilippGackstatter Nov 15, 2021
5809927
Add proper type annotations in publish
PhilippGackstatter Nov 16, 2021
f6c7c86
Improve chain state docs & variable naming
PhilippGackstatter Nov 16, 2021
b8c0a09
Merge branch 'epic/account-refactor' into chore/state-refactor
PhilippGackstatter Nov 16, 2021
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/wasm/src/did/wasm_verification_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl WasmVerificationMethod {
/// Creates a new `VerificationMethod` object from the given `did` and `key`.
#[wasm_bindgen(js_name = fromDID)]
pub fn from_did(did: &WasmDID, key: &KeyPair, fragment: String) -> Result<WasmVerificationMethod, JsValue> {
IotaVerificationMethod::from_did(did.0.clone(), &key.0, &fragment)
IotaVerificationMethod::from_did(did.0.clone(), key.0.type_(), key.0.public(), &fragment)
.map_err(wasm_error)
.map(Self)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/account/create_did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn main() -> Result<()> {
println!(
"[Example] Local Document from {} = {:#?}",
iota_did,
account.state().await?.to_document()
account.state().document()
);

// Prints the Identity Resolver Explorer URL.
Expand Down
6 changes: 3 additions & 3 deletions examples/account/manipulate_did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use identity::account::AccountStorage;
use identity::account::IdentitySetup;
use identity::account::Result;
use identity::core::Url;
use identity::did::MethodScope;
use identity::did::MethodRelationship;
use identity::iota::IotaDID;

#[tokio::main]
Expand Down Expand Up @@ -48,8 +48,8 @@ async fn main() -> Result<()> {
.update_identity()
.attach_method()
.fragment("my-next-key")
.scope(MethodScope::CapabilityDelegation)
.scope(MethodScope::CapabilityInvocation)
.relationship(MethodRelationship::CapabilityDelegation)
.relationship(MethodRelationship::CapabilityInvocation)
.apply()
.await?;

Expand Down
3 changes: 2 additions & 1 deletion examples/low-level-api/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ pub async fn add_new_key(

// Add #newKey to the document
let new_key: KeyPair = KeyPair::new_ed25519()?;
let method: IotaVerificationMethod = IotaVerificationMethod::from_did(updated_doc.did().clone(), &new_key, "newKey")?;
let method: IotaVerificationMethod =
IotaVerificationMethod::from_did(updated_doc.did().clone(), new_key.type_(), new_key.public(), "newKey")?;
assert!(updated_doc.insert_method(method, MethodScope::VerificationMethod));

// Prepare the update
Expand Down
3 changes: 2 additions & 1 deletion examples/low-level-api/manipulate_did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ pub async fn run() -> Result<(IotaDocument, KeyPair, KeyPair, Receipt, Receipt)>

// Add a new VerificationMethod with a new keypair
let new_key: KeyPair = KeyPair::new_ed25519()?;
let method: IotaVerificationMethod = IotaVerificationMethod::from_did(document.did().clone(), &new_key, "newKey")?;
let method: IotaVerificationMethod =
IotaVerificationMethod::from_did(document.did().clone(), new_key.type_(), new_key.public(), "newKey")?;
assert!(document.insert_method(method, MethodScope::VerificationMethod));

// Add a new Service
Expand Down
4 changes: 2 additions & 2 deletions examples/low-level-api/resolve_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn main() -> Result<()> {

// Add a new VerificationMethod with a new KeyPair, with the tag "keys-1"
let keys_1: KeyPair = KeyPair::new_ed25519()?;
let method_1: IotaVerificationMethod = IotaVerificationMethod::from_did(int_doc_1.id().clone(), &keys_1, "keys-1")?;
let method_1: IotaVerificationMethod = IotaVerificationMethod::from_did(int_doc_1.id().clone(), keys_1.type_(), keys_1.public(), "keys-1")?;
assert!(int_doc_1.insert_method(method_1, MethodScope::VerificationMethod));

// Add the `message_id` of the previous message in the chain.
Expand Down Expand Up @@ -176,7 +176,7 @@ async fn main() -> Result<()> {

// Add a VerificationMethod with a new KeyPair, called "keys-2"
let keys_2: KeyPair = KeyPair::new_ed25519()?;
let method_2: IotaVerificationMethod = IotaVerificationMethod::from_did(int_doc_2.id().clone(), &keys_2, "keys-2")?;
let method_2: IotaVerificationMethod = IotaVerificationMethod::from_did(int_doc_2.id().clone(), keys_2.type_(), keys_2.public(), "keys-2")?;
assert!(int_doc_2.insert_method(method_2, MethodScope::VerificationMethod));

// Note: the `previous_message_id` points to the `message_id` of the last integration chain
Expand Down
3 changes: 2 additions & 1 deletion examples/low-level-api/revoke_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ pub async fn add_new_key(

// Add #newKey to the document
let new_key: KeyPair = KeyPair::new_ed25519()?;
let method: IotaVerificationMethod = IotaVerificationMethod::from_did(updated_doc.did().clone(), &new_key, "newKey")?;
let method: IotaVerificationMethod =
IotaVerificationMethod::from_did(updated_doc.did().clone(), new_key.type_(), new_key.public(), "newKey")?;
assert!(updated_doc.insert_method(method, MethodScope::VerificationMethod));

// Prepare the update
Expand Down
Loading