I created a number of keychains under the “master” key account, and happened to name one of them as “pdex”. Then I found out that I can delete any other keychain but not this one: the “delete” option when you swipe right simply wouldn’t appear for this key. Why?
Cannot delete key named "pdex"?
When you enter the pDEX for the first time, the app will automatically generates a “pDEX” and “pDEXWithdraw” account for you. These are special accounts that need to be present for the pDEX to function properly. As a result, once created, these accounts cannot be removed.
Since you manually created an account with that name, the app is likely preventing deletion based on the name.
I only knew they were special in the “Masterless” account. Are they still special in the “Master” account? At least I didn’t notice they are automatically created.
Yep, the wallet app determines if an account isDeletable by checking if it isDEXAccount by name. For pDEX there are two constants defined: “pDEX” and “pDEXWithdraw”.
Github incognito-wallet > src > screens > Setting > features > AccountSection > AccountSection.js
const isDeletable = (account) =>
listAccount.length > 1 &&
!dexUtils.isDEXAccount(account?.name) &&
!isNodeAccount(account?.name, devices);
[source]
Github incognito-wallet > src > utils > dex.js
export const DEX = {
MAIN_ACCOUNT: 'pDEX',
WITHDRAW_ACCOUNT: 'pDEXWithdraw',
};
export default {
isDEXAccount(accountName) {
if (!accountName) {
return false;
}
const name = accountName.toLowerCase();
return name === DEX.WITHDRAW_ACCOUNT.toLowerCase() || name === DEX.MAIN_ACCOUNT.toLowerCase();
},
isDEXMainAccount(accountName) {
if (!accountName) {
return false;
}
const name = accountName.toLowerCase();
return name === DEX.MAIN_ACCOUNT.toLowerCase();
},
isDEXWithdrawAccount(accountName) {
if (!accountName) {
return false;
}
const name = accountName.toLowerCase();
return name === DEX.WITHDRAW_ACCOUNT.toLowerCase();
},
[source]
These accounts are created per current keychain.
Let’s say you have three keychains: Master > Anon, Masterless > Account 0 and Master > Zebra. Opening the pDEX while on a Master > Anon will create pDEX and pDEXWithdraw accounts under Master > Anon. Masterless > Account 0 and Master > Zebra will not have pDEX or pDEXWithdraw accounts (yet).
Later, you switch to Masterless > Account 0 and again enter the pDEX. The app will create pDEX and pDEXWithdraw accounts under Masterless > Account 0. Master > Zebra will remain without a pDEX or pDEXWithdraw account. You can use either pDEX account (Master > Anon or Masterless > Account 0) to trade on the pDEX.
And later if you enter the pDEX while Master > Zebra is selected, guess what? That’s right – pDEX and pDEXWithdraw accounts would then be added to Master > Zebra.
Thanks for the explanation! Very helpful!
This is all deprecated and no longer the case, right?
I’ve used pDEX and have never seen accounts like this.
Yes. Deprecated.