Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ members = [
"examples",
]

exclude = ["bindings/wasm/identity_wasm", "bindings/grpc"]
exclude = ["bindings/wasm/identity_wasm", "bindings/grpc", "identity_iota_core/packages/iota_identity/tests"]

[workspace.dependencies]
bls12_381_plus = { version = "0.8.17" }
Expand Down
18 changes: 9 additions & 9 deletions identity_iota_core/packages/iota_identity/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 3
manifest_digest = "C2AC50C3DADC20A9BC9C4473015BF689654F2549655BBCE287C1EA2477294A4F"
manifest_digest = "4F683992E583AF26EC3B6B905CAE1643F799A1B4F2D48E4BA5E48DA165952893"
deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C"
dependencies = [
{ id = "Iota", name = "Iota" },
Expand All @@ -13,15 +13,15 @@ dependencies = [

[[move.package]]
id = "Iota"
source = { git = "https://github.com/iotaledger/iota.git", rev = "e3c45c9370f14b8137fd1bb9d109d3563d416223", subdir = "crates/iota-framework/packages/iota-framework" }
source = { git = "https://github.com/iotaledger/iota.git", rev = "5b7be9f6824e2b7b8626b55fa5eb4853eb4dc102", subdir = "crates/iota-framework/packages/iota-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[[move.package]]
id = "IotaSystem"
source = { git = "https://github.com/iotaledger/iota.git", rev = "e3c45c9370f14b8137fd1bb9d109d3563d416223", subdir = "crates/iota-framework/packages/iota-system" }
source = { git = "https://github.com/iotaledger/iota.git", rev = "5b7be9f6824e2b7b8626b55fa5eb4853eb4dc102", subdir = "crates/iota-framework/packages/iota-system" }

dependencies = [
{ id = "Iota", name = "Iota" },
Expand All @@ -30,19 +30,19 @@ dependencies = [

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/iotaledger/iota.git", rev = "e3c45c9370f14b8137fd1bb9d109d3563d416223", subdir = "crates/iota-framework/packages/move-stdlib" }
source = { git = "https://github.com/iotaledger/iota.git", rev = "5b7be9f6824e2b7b8626b55fa5eb4853eb4dc102", subdir = "crates/iota-framework/packages/move-stdlib" }

[[move.package]]
id = "Stardust"
source = { git = "https://github.com/iotaledger/iota.git", rev = "e3c45c9370f14b8137fd1bb9d109d3563d416223", subdir = "crates/iota-framework/packages/stardust" }
source = { git = "https://github.com/iotaledger/iota.git", rev = "5b7be9f6824e2b7b8626b55fa5eb4853eb4dc102", subdir = "crates/iota-framework/packages/stardust" }

dependencies = [
{ id = "Iota", name = "Iota" },
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[move.toolchain-version]
compiler-version = "1.18.0-beta"
compiler-version = "1.22.1"
edition = "2024"
flavor = "iota"

Expand All @@ -61,9 +61,9 @@ latest-published-id = "0x8896ab04fe24c044c54925df3f8a7c383a8d1d6f6bbb95d1c57cfa9
published-version = "1"

[env.localnet]
chain-id = "a6bad7ce"
original-published-id = "0x057742ffe67851bc2f0d31affcd23925cfc78633bb2c11ae53cacfafb0236f96"
latest-published-id = "0x057742ffe67851bc2f0d31affcd23925cfc78633bb2c11ae53cacfafb0236f96"
chain-id = "64333340"
original-published-id = "0x37233f30a3fd758a9146e19e39c750b9fa099313f9c87db663580a4fea40a392"
latest-published-id = "0x37233f30a3fd758a9146e19e39c750b9fa099313f9c87db663580a4fea40a392"
published-version = "1"

[env.mainnet]
Expand Down
1 change: 1 addition & 0 deletions identity_iota_core/packages/iota_identity/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2024"

[addresses]
iota_identity = "0x0"
identity_team = "0x1d3c717" # TODO: replace this with the actual address of the identity team.

[dev-dependencies]

Expand Down
77 changes: 77 additions & 0 deletions identity_iota_core/packages/iota_identity/sources/identity.move
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
// SPDX-License-Identifier: Apache-2.0

module iota_identity::identity {
use iota::authenticator_function::AuthenticatorFunctionRefV1;
use iota::clock::Clock;
use iota::dynamic_field as df;
use iota::transfer::Receiving;
use iota::vec_map::{Self, VecMap};
use iota_identity::aa_migration::{Self, AAMigrationProposal};
use iota_identity::aa_migration_registry::AAMigrationRegistry;
use iota_identity::access_sub_entity_proposal::{Self, AccessSubEntity};
use iota_identity::borrow_proposal::{Self, Borrow};
use iota_identity::config_proposal;
use iota_identity::controller::{DelegationToken, ControllerCap};
use iota_identity::controller_proposal::{Self, ControllerExecution};
use iota_identity::delete_proposal::{Self, Delete};
use iota_identity::identity_config::new as new_config;
use iota_identity::identity_v2::{Self, IdentityV2};
use iota_identity::multicontroller::{Self, Multicontroller, Action};
use iota_identity::transfer_proposal::{Self, Send};
use iota_identity::update_value_proposal::{Self, UpdateValue};
Expand All @@ -29,6 +35,8 @@ module iota_identity::identity {
const ECannotDelete: u64 = 5;
/// Identity had been deleted.
const EDeletedIdentity: u64 = 6;
#[error(code = 7)]
const EThresholdNotReached: vector<u8> = b"Not enough voting power to execute proposal";

const PACKAGE_VERSION: u64 = 0;

Expand Down Expand Up @@ -679,6 +687,10 @@ module iota_identity::identity {
/// set to `true`.
public fun delete(self: Identity) {
assert!(self.deleted && self.did_doc.controllers().is_empty(), ECannotDelete);
self.force_delete();
}

public(package) fun force_delete(self: Identity) {
let Identity {
id,
did_doc,
Expand All @@ -688,6 +700,71 @@ module iota_identity::identity {
did_doc.delete();
}

public struct AAMigrationKey has copy, drop, store {}

/// Proposes or approves a migration to the AA-based implementation of this Identity object.
public fun propose_or_approve_aa_migration(
self: &mut Identity,
cap: &mut ControllerCap,
ctx: &mut TxContext,
) {
assert!(!self.deleted, EDeletedIdentity);
let (token, borrow) = cap.borrow();
self.did_doc.assert_is_member(&token);

let proposal: &mut AAMigrationProposal = if (df::exists_(&self.id, AAMigrationKey {})) {
df::borrow_mut(&mut self.id, AAMigrationKey {})
} else {
let proposal = aa_migration::new();
df::add(&mut self.id, AAMigrationKey {}, proposal);
df::borrow_mut(&mut self.id, AAMigrationKey {})
};

proposal.insert_controller(ctx.sender(), self.did_doc.voting_power(token.controller()));
cap.put_back(token, borrow);
}

public fun execute_aa_migration(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(Reminder) What about the objects owned by the identity?

IIRC, we can't just provide them as arguments here, so this should be responsibility of the Rust API, right?

Should work, but a check or something here would be really nice, but I don't think, that's an option. >.<

mut self: Identity,
mut cap: ControllerCap,
migration_registry: &mut AAMigrationRegistry,
auth_fn: AuthenticatorFunctionRefV1<IdentityV2>,
ctx: &mut TxContext,
) {
self.propose_or_approve_aa_migration(&mut cap, ctx);
let proposal: AAMigrationProposal = df::remove(&mut self.id, AAMigrationKey {});

let total_weights = proposal.weights().fold!(0, |acc, w| acc + w);
assert!(total_weights >= self.did_doc.threshold(), EThresholdNotReached);

let mut permissions = vector::empty();
proposal.controllers().do_ref!(|_| permissions.push_back(std::u64::max_value!()));
let config = new_config(
proposal.controllers(),
proposal.weights(),
permissions,
self.did_doc.threshold(),
);

let did_doc = identity_v2::new_did_document(
*self.did_doc.value().borrow(),
self.created,
self.updated,
self.deleted_did,
);
let new_identity_id = identity_v2::new_from_parts(
did_doc,
config,
option::some(self.id().to_inner()),
auth_fn,
ctx,
);
migration_registry.insert(self.id().to_inner(), new_identity_id);

cap.delete();
self.force_delete();
}

public(package) fun uid_mut(self: &mut Identity): &mut UID {
&mut self.id
}
Expand Down
Loading
Loading