Merge pull request #11989 from AmineKhaldi/rename_did

Rename DISTRIBUTED_ID to DECENTRALIZED_ID
This commit is contained in:
Amine Khaldi
2022-06-20 20:53:23 +01:00
committed by GitHub
8 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -548,7 +548,7 @@ async def print_balances(args: dict, wallet_client: WalletRpcClient, fingerprint
print(f"{indent}{'-Pending Total Balance:'.ljust(23)} " f"{unconfirmed_wallet_balance}")
print(f"{indent}{'-Spendable:'.ljust(23)} {spendable_balance}")
print(f"{indent}{'-Type:'.ljust(23)} {typ.name}")
if typ == WalletType.DISTRIBUTED_ID:
if typ == WalletType.DECENTRALIZED_ID:
get_did_response = await wallet_client.get_did_id(wallet_id)
my_did = get_did_response["my_did"]
print(f"{indent}{'-DID ID:'.ljust(23)} {my_did}")
+3 -3
View File
@@ -1129,7 +1129,7 @@ class WalletRpcApi:
assert self.service.wallet_state_manager is not None
wallet_id = int(request["wallet_id"])
wallet: DIDWallet = self.service.wallet_state_manager.wallets[wallet_id]
if wallet.type() == WalletType.DISTRIBUTED_ID:
if wallet.type() == WalletType.DECENTRALIZED_ID:
await wallet.set_name(str(request["name"]))
return {"success": True, "wallet_id": wallet_id}
else:
@@ -1165,7 +1165,7 @@ class WalletRpcApi:
async def did_update_metadata(self, request):
wallet_id = int(request["wallet_id"])
wallet: DIDWallet = self.service.wallet_state_manager.wallets[wallet_id]
if wallet.type() != WalletType.DISTRIBUTED_ID.value:
if wallet.type() != WalletType.DECENTRALIZED_ID.value:
return {"success": False, "error": f"Wallet with id {wallet_id} is not a DID one"}
metadata: Dict[str, str] = {}
if "metadata" in request and type(request["metadata"]) is dict:
@@ -1452,7 +1452,7 @@ class WalletRpcApi:
did_wallets_by_did_id: Dict[bytes32, uint32] = {
wallet.did_info.origin_coin.name(): wallet.id()
for wallet in all_wallets
if wallet.type() == uint8(WalletType.DISTRIBUTED_ID) and wallet.did_info.origin_coin is not None
if wallet.type() == uint8(WalletType.DECENTRALIZED_ID) and wallet.did_info.origin_coin is not None
}
did_nft_wallets: List[Dict] = []
for wallet in all_wallets:
+6 -6
View File
@@ -94,7 +94,7 @@ class DIDWallet:
)
info_as_string = json.dumps(self.did_info.to_json_dict())
self.wallet_info = await wallet_state_manager.user_store.create_wallet(
name, WalletType.DISTRIBUTED_ID.value, info_as_string
name, WalletType.DECENTRALIZED_ID.value, info_as_string
)
if self.wallet_info is None:
raise ValueError("Internal Error")
@@ -189,7 +189,7 @@ class DIDWallet:
self.check_existed_did()
info_as_string = json.dumps(self.did_info.to_json_dict())
self.wallet_info = await wallet_state_manager.user_store.create_wallet(
name, WalletType.DISTRIBUTED_ID.value, info_as_string
name, WalletType.DECENTRALIZED_ID.value, info_as_string
)
await self.wallet_state_manager.add_new_wallet(self, self.wallet_info.id)
await self.save_info(self.did_info, False)
@@ -258,7 +258,7 @@ class DIDWallet:
info_as_string = json.dumps(self.did_info.to_json_dict())
self.wallet_info = await wallet_state_manager.user_store.create_wallet(
name, WalletType.DISTRIBUTED_ID.value, info_as_string, in_transaction=True
name, WalletType.DECENTRALIZED_ID.value, info_as_string, in_transaction=True
)
await self.wallet_state_manager.add_new_wallet(self, self.wallet_info.id, in_transaction=True)
await self.wallet_state_manager.update_wallet_puzzle_hashes(self.wallet_info.id, in_transaction=True)
@@ -298,7 +298,7 @@ class DIDWallet:
@classmethod
def type(cls) -> uint8:
return uint8(WalletType.DISTRIBUTED_ID)
return uint8(WalletType.DECENTRALIZED_ID)
def id(self):
return self.wallet_info.id
@@ -1292,7 +1292,7 @@ class DIDWallet:
"""
max_num = 0
for wallet in self.wallet_state_manager.wallets.values():
if wallet.type() == WalletType.DISTRIBUTED_ID:
if wallet.type() == WalletType.DECENTRALIZED_ID:
matched = re.search(r"^Profile (\d+)$", wallet.wallet_info.name)
if matched and int(matched.group(1)) > max_num:
max_num = int(matched.group(1))
@@ -1305,7 +1305,7 @@ class DIDWallet:
"""
for wallet in self.wallet_state_manager.wallets.values():
if (
wallet.type() == WalletType.DISTRIBUTED_ID
wallet.type() == WalletType.DECENTRALIZED_ID
and self.did_info.origin_coin.name() == wallet.did_info.origin_coin.name()
):
self.log.warning(f"DID {self.did_info.origin_coin} already existed, ignore the wallet creation.")
+1 -1
View File
@@ -326,7 +326,7 @@ class NFTWallet:
did_id = self.did_id
for _, wallet in self.wallet_state_manager.wallets.items():
self.log.debug("Checking wallet type %s", wallet.type())
if wallet.type() == WalletType.DISTRIBUTED_ID:
if wallet.type() == WalletType.DECENTRALIZED_ID:
self.log.debug("Found a DID wallet, checking did: %r == %r", wallet.get_my_DID(), did_id)
if bytes32.fromhex(wallet.get_my_DID()) == did_id:
self.log.debug("Creating announcement from DID for nft_id: %s", nft_id)
+1 -1
View File
@@ -17,7 +17,7 @@ class WalletType(IntEnum):
CUSTODY = 5
CAT = 6
RECOVERABLE = 7
DISTRIBUTED_ID = 8
DECENTRALIZED_ID = 8
POOLING_WALLET = 9
NFT = 10
+3 -3
View File
@@ -206,7 +206,7 @@ class WalletStateManager:
)
elif wallet_info.type == WalletType.RATE_LIMITED:
wallet = await RLWallet.create(self, wallet_info)
elif wallet_info.type == WalletType.DISTRIBUTED_ID:
elif wallet_info.type == WalletType.DECENTRALIZED_ID:
wallet = await DIDWallet.create(
self,
self.main_wallet,
@@ -746,7 +746,7 @@ class WalletStateManager:
if wallet_id is None:
if did_id is not None:
found_did: bool = False
for wallet_info in await self.get_all_wallet_info_entries(wallet_type=WalletType.DISTRIBUTED_ID):
for wallet_info in await self.get_all_wallet_info_entries(wallet_type=WalletType.DECENTRALIZED_ID):
did_info: DIDInfo = DIDInfo.from_json_dict(json.loads(wallet_info.data))
if did_info.origin_coin is not None and did_info.origin_coin.name() == did_id:
found_did = True
@@ -1213,7 +1213,7 @@ class WalletStateManager:
)
await self.coin_store.add_coin_record(coin_record_1)
if wallet_type == WalletType.CAT or wallet_type == WalletType.DISTRIBUTED_ID:
if wallet_type == WalletType.CAT or wallet_type == WalletType.DECENTRALIZED_ID:
wallet = self.wallets[wallet_id]
await wallet.coin_added(coin, height)
+1 -1
View File
@@ -666,7 +666,7 @@ class TestDIDWallet:
# Get the new DID wallet
did_wallets = list(
filter(
lambda w: (w.type == WalletType.DISTRIBUTED_ID),
lambda w: (w.type == WalletType.DECENTRALIZED_ID),
await wallet_node_2.wallet_state_manager.get_all_wallet_info_entries(),
)
)
+1 -1
View File
@@ -818,7 +818,7 @@ async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
did_wallets = list(
filter(
lambda w: (w.type == WalletType.DISTRIBUTED_ID),
lambda w: (w.type == WalletType.DECENTRALIZED_ID),
await wallet_2_node.wallet_state_manager.get_all_wallet_info_entries(),
)
)