|
@ -91,8 +91,8 @@ |
|
|
class="text-sm text-slate-500 flex justify-between items-center mb-1" |
|
|
class="text-sm text-slate-500 flex justify-between items-center mb-1" |
|
|
> |
|
|
> |
|
|
<span |
|
|
<span |
|
|
><code>{{ address }}</code> |
|
|
><code>{{ activeDid }}</code> |
|
|
<button @click="copy(address)"> |
|
|
<button @click="copy(activeDid)"> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
</button> |
|
|
</button> |
|
|
</span> |
|
|
</span> |
|
@ -202,11 +202,8 @@ |
|
|
</button> |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="flex"> |
|
|
<div class="flex py-2"> |
|
|
<button |
|
|
<button class="text-center text-md text-blue-500" @click="checkLimits()"> |
|
|
class="text-center text-md text-blue-500 px-1.5 py-2" |
|
|
|
|
|
@click="checkLimits()" |
|
|
|
|
|
> |
|
|
|
|
|
Check Limits |
|
|
Check Limits |
|
|
</button> |
|
|
</button> |
|
|
<div v-if="!!limits?.nextWeekBeginDateTime" class="px-9"> |
|
|
<div v-if="!!limits?.nextWeekBeginDateTime" class="px-9"> |
|
@ -225,6 +222,15 @@ |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div v-if="numAccounts > 0" class="flex py-2"> |
|
|
|
|
|
Switch Account |
|
|
|
|
|
<span v-for="accountNum in numAccounts" :key="accountNum"> |
|
|
|
|
|
<button class="text-blue-500 px-2" @click="switchAccount(accountNum)"> |
|
|
|
|
|
#{{ accountNum }} |
|
|
|
|
|
</button> |
|
|
|
|
|
</span> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
<div v-bind:class="computedAlertClassNames()"> |
|
|
<div v-bind:class="computedAlertClassNames()"> |
|
|
<button |
|
|
<button |
|
|
class="close-button bg-slate-200 w-8 leading-loose rounded-full absolute top-2 right-2" |
|
|
class="close-button bg-slate-200 w-8 leading-loose rounded-full absolute top-2 right-2" |
|
@ -273,11 +279,10 @@ interface RateLimits { |
|
|
}) |
|
|
}) |
|
|
export default class AccountViewView extends Vue { |
|
|
export default class AccountViewView extends Vue { |
|
|
activeDid = ""; |
|
|
activeDid = ""; |
|
|
address = ""; |
|
|
|
|
|
derivationPath = ""; |
|
|
derivationPath = ""; |
|
|
firstName = ""; |
|
|
firstName = ""; |
|
|
lastName = ""; |
|
|
lastName = ""; |
|
|
mnemonic = ""; |
|
|
numAccounts = 0; |
|
|
publicHex = ""; |
|
|
publicHex = ""; |
|
|
publicBase64 = ""; |
|
|
publicBase64 = ""; |
|
|
limits: RateLimits | null = null; |
|
|
limits: RateLimits | null = null; |
|
@ -300,23 +305,22 @@ export default class AccountViewView extends Vue { |
|
|
try { |
|
|
try { |
|
|
await db.open(); |
|
|
await db.open(); |
|
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY); |
|
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY); |
|
|
if (settings) { |
|
|
this.activeDid = settings?.activeDid || ""; |
|
|
this.activeDid = settings.activeDid || ""; |
|
|
this.firstName = settings?.firstName || ""; |
|
|
this.firstName = settings.firstName || ""; |
|
|
this.lastName = settings?.lastName || ""; |
|
|
this.lastName = settings.lastName || ""; |
|
|
this.showContactGives = !!settings?.showContactGivesInline; |
|
|
this.showContactGives = !!settings.showContactGivesInline; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await accountsDB.open(); |
|
|
await accountsDB.open(); |
|
|
const numAccounts = await accountsDB.accounts.count(); |
|
|
this.numAccounts = await accountsDB.accounts.count(); |
|
|
if (numAccounts === 0) { |
|
|
if (this.numAccounts === 0) { |
|
|
|
|
|
let address = ""; // 0x... ETH address, without "did:eth:" |
|
|
let privateHex = ""; |
|
|
let privateHex = ""; |
|
|
this.mnemonic = generateSeed(); |
|
|
const mnemonic = generateSeed(); |
|
|
[this.address, privateHex, this.publicHex, this.derivationPath] = |
|
|
[address, privateHex, this.publicHex, this.derivationPath] = |
|
|
deriveAddress(this.mnemonic); |
|
|
deriveAddress(mnemonic); |
|
|
|
|
|
|
|
|
const newId = newIdentifier( |
|
|
const newId = newIdentifier( |
|
|
this.address, |
|
|
address, |
|
|
this.publicHex, |
|
|
this.publicHex, |
|
|
privateHex, |
|
|
privateHex, |
|
|
this.derivationPath |
|
|
this.derivationPath |
|
@ -326,7 +330,7 @@ export default class AccountViewView extends Vue { |
|
|
derivationPath: this.derivationPath, |
|
|
derivationPath: this.derivationPath, |
|
|
did: newId.did, |
|
|
did: newId.did, |
|
|
identity: JSON.stringify(newId), |
|
|
identity: JSON.stringify(newId), |
|
|
mnemonic: this.mnemonic, |
|
|
mnemonic: mnemonic, |
|
|
publicKeyHex: newId.keys[0].publicKeyHex, |
|
|
publicKeyHex: newId.keys[0].publicKeyHex, |
|
|
}); |
|
|
}); |
|
|
this.activeDid = newId.did; |
|
|
this.activeDid = newId.did; |
|
@ -335,16 +339,13 @@ export default class AccountViewView extends Vue { |
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
const account = R.find((acc) => acc.did === this.activeDid, accounts); |
|
|
const account = R.find((acc) => acc.did === this.activeDid, accounts); |
|
|
const identity = JSON.parse(account?.identity || "undefined"); |
|
|
const identity = JSON.parse(account?.identity || "undefined"); |
|
|
this.address = identity.did; |
|
|
|
|
|
this.publicHex = identity.keys[0].publicKeyHex; |
|
|
this.publicHex = identity.keys[0].publicKeyHex; |
|
|
this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64"); |
|
|
this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64"); |
|
|
this.derivationPath = identity.keys[0].meta.derivationPath; |
|
|
this.derivationPath = identity.keys[0].meta.derivationPath; |
|
|
|
|
|
|
|
|
if (settings) { |
|
|
|
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
activeDid: identity.did, |
|
|
activeDid: identity.did, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
this.alertMessage = |
|
|
this.alertMessage = |
|
|
"Clear your cache and start over (after data backup). See console log for more info."; |
|
|
"Clear your cache and start over (after data backup). See console log for more info."; |
|
@ -358,12 +359,9 @@ export default class AccountViewView extends Vue { |
|
|
this.showContactGives = !this.showContactGives; |
|
|
this.showContactGives = !this.showContactGives; |
|
|
try { |
|
|
try { |
|
|
await db.open(); |
|
|
await db.open(); |
|
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY); |
|
|
|
|
|
if (settings) { |
|
|
|
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
showContactGivesInline: this.showContactGives, |
|
|
showContactGivesInline: this.showContactGives, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
this.alertMessage = |
|
|
this.alertMessage = |
|
|
"Clear your cache and start over (after data backup). See console log for more info."; |
|
|
"Clear your cache and start over (after data backup). See console log for more info."; |
|
@ -401,7 +399,7 @@ export default class AccountViewView extends Vue { |
|
|
const url = endorserApiServer + "/api/report/rateLimits"; |
|
|
const url = endorserApiServer + "/api/report/rateLimits"; |
|
|
await accountsDB.open(); |
|
|
await accountsDB.open(); |
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
const account = R.find((acc) => acc.did === this.address, accounts); |
|
|
const account = R.find((acc) => acc.did === this.activeDid, accounts); |
|
|
const identity = JSON.parse(account?.identity || "undefined"); |
|
|
const identity = JSON.parse(account?.identity || "undefined"); |
|
|
const token = await accessToken(identity); |
|
|
const token = await accessToken(identity); |
|
|
const headers = { |
|
|
const headers = { |
|
@ -432,6 +430,22 @@ export default class AccountViewView extends Vue { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async switchAccount(accountNum: number) { |
|
|
|
|
|
await accountsDB.open(); |
|
|
|
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
|
|
|
const account = accounts[accountNum - 1]; |
|
|
|
|
|
|
|
|
|
|
|
await db.open(); |
|
|
|
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
|
|
|
activeDid: account.did, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.activeDid = account.did; |
|
|
|
|
|
this.derivationPath = account.derivationPath; |
|
|
|
|
|
this.publicHex = account.publicKeyHex; |
|
|
|
|
|
this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public showContactGivesClassNames() { |
|
|
public showContactGivesClassNames() { |
|
|
return { |
|
|
return { |
|
|
"bg-slate-900": !this.showContactGives, |
|
|
"bg-slate-900": !this.showContactGives, |
|
|