Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
feat: login page (#314)
Browse files Browse the repository at this point in the history
Co-authored-by: Timo Welde <tjwelde@gmail.com>
  • Loading branch information
Dudleyneedham and tjwelde authored Jan 28, 2021
1 parent 984f370 commit 13a9e26
Show file tree
Hide file tree
Showing 52 changed files with 682 additions and 198 deletions.
7 changes: 4 additions & 3 deletions src/components/AttestationStatus/AttestationStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import AttestationService from '../../services/AttestationService'
import * as Claims from '../../state/ducks/Claims'
import * as UiState from '../../state/ducks/UiState'
import * as Attestations from '../../state/ducks/Attestations'
import PersistentStore, {
import {
persistentStoreInstance,
State as ReduxState,
} from '../../state/PersistentStore'
import Spinner from '../Spinner/Spinner'
Expand Down Expand Up @@ -99,11 +100,11 @@ class AttestationStatus extends React.Component<Props, State> {
status: STATUS.UNVERIFIED,
})
if (isAttestedClaim(attestation)) {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
Claims.Store.revokeAttestation(attestation.request.rootHash)
)
} else {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
Attestations.Store.revokeAttestation(attestation.claimHash)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IAttestedClaim } from '@kiltprotocol/sdk-js'
import React from 'react'
import * as UiState from '../../state/ducks/UiState'
import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'

import { ICType } from '../../types/Ctype'
import AttestationStatus from '../AttestationStatus/AttestationStatus'
Expand All @@ -20,7 +20,7 @@ type State = {}

class AttestedClaimVerificationView extends React.Component<Props, State> {
private static verifyAttestatedClaim(): void {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.refreshAttestationStatusAction()
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IAttestedClaim, IDelegationNode } from '@kiltprotocol/sdk-js'
import React from 'react'

import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'
import AttestationStatus from '../AttestationStatus/AttestationStatus'
import AttestedClaimVerificationView from '../AttestedClaimVerificationView/AttestedClaimVerificationView'
import ContactPresentation from '../ContactPresentation/ContactPresentation'
Expand Down Expand Up @@ -54,7 +54,7 @@ type State = {

class AttestedClaimsListView extends React.Component<Props, State> {
private static verifyAttestations(): void {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.refreshAttestationStatusAction()
)
}
Expand Down
14 changes: 7 additions & 7 deletions src/components/CTypePresentation/CTypePresentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SubmitTermsProps } from '../../containers/Tasks/SubmitTerms/SubmitTerms

import CTypeRepository from '../../services/CtypeRepository'
import * as UiState from '../../state/ducks/UiState'
import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'
import { ICTypeWithMetadata } from '../../types/Ctype'
import SelectAction, { Action } from '../SelectAction/SelectAction'

Expand Down Expand Up @@ -96,7 +96,7 @@ class CTypePresentation extends React.Component<Props, State> {
},
{
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_CLAIMS_FOR_CTYPES,
props: { cTypeHashes: [cTypeHash] } as RequestClaimsForCTypeProps,
Expand All @@ -107,7 +107,7 @@ class CTypePresentation extends React.Component<Props, State> {
},
{
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_TERMS,
props: {
Expand All @@ -120,7 +120,7 @@ class CTypePresentation extends React.Component<Props, State> {
},
{
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.SUBMIT_CLAIMS_FOR_CTYPES_CLASSIC,
props: { cTypeHashes: [cTypeHash] } as SubmitClaimsForCTypeProps,
Expand All @@ -131,7 +131,7 @@ class CTypePresentation extends React.Component<Props, State> {
},
{
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.SUBMIT_TERMS,
props: {
Expand All @@ -144,7 +144,7 @@ class CTypePresentation extends React.Component<Props, State> {
},
{
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_ACCEPT_DELEGATION,
props: {
Expand All @@ -158,7 +158,7 @@ class CTypePresentation extends React.Component<Props, State> {
},
{
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_ACCEPT_DELEGATION,
props: {
Expand Down
27 changes: 16 additions & 11 deletions src/components/ContactPresentation/ContactPresentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import ContactRepository from '../../services/ContactRepository'
import * as Contacts from '../../state/ducks/Contacts'
import * as Wallet from '../../state/ducks/Wallet'
import * as UiState from '../../state/ducks/UiState'
import PersistentStore, {
import {
persistentStoreInstance,
State as ReduxState,
} from '../../state/PersistentStore'
import { IContact, IMyIdentity } from '../../types/Contact'
Expand Down Expand Up @@ -85,7 +86,7 @@ class ContactPresentation extends React.Component<Props, State> {

actions.push({
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_CLAIMS_FOR_CTYPES,
props: {
Expand All @@ -99,7 +100,7 @@ class ContactPresentation extends React.Component<Props, State> {

actions.push({
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_TERMS,
props: {
Expand All @@ -113,7 +114,7 @@ class ContactPresentation extends React.Component<Props, State> {

actions.push({
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.SUBMIT_CLAIMS_FOR_CTYPES_CLASSIC,
props: {
Expand All @@ -127,7 +128,7 @@ class ContactPresentation extends React.Component<Props, State> {

actions.push({
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.SUBMIT_TERMS,
props: {
Expand All @@ -141,7 +142,7 @@ class ContactPresentation extends React.Component<Props, State> {

actions.push({
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_ACCEPT_DELEGATION,
props: {
Expand All @@ -156,7 +157,7 @@ class ContactPresentation extends React.Component<Props, State> {

actions.push({
callback: () => {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_ACCEPT_DELEGATION,
props: {
Expand Down Expand Up @@ -186,7 +187,7 @@ class ContactPresentation extends React.Component<Props, State> {
const { address } = this.props

const myIdentity: IMyIdentity = Wallet.getIdentity(
PersistentStore.store.getState(),
persistentStoreInstance.store.getState(),
address
)

Expand All @@ -197,7 +198,7 @@ class ContactPresentation extends React.Component<Props, State> {
const { contact } = this.state

const selectedIdentity = Wallet.getSelectedIdentity(
PersistentStore.store.getState()
persistentStoreInstance.store.getState()
)

if (contact) {
Expand All @@ -211,7 +212,9 @@ class ContactPresentation extends React.Component<Props, State> {
},
publicIdentity,
}
PersistentStore.store.dispatch(Contacts.Store.addContact(myContact))
persistentStoreInstance.store.dispatch(
Contacts.Store.addContact(myContact)
)
this.setState({
contact: myContact,
})
Expand All @@ -222,7 +225,9 @@ class ContactPresentation extends React.Component<Props, State> {
const { address } = this.props

if (address) {
PersistentStore.store.dispatch(Contacts.Store.removeMyContact(address))
persistentStoreInstance.store.dispatch(
Contacts.Store.removeMyContact(address)
)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/DelegationNode/DelegationNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import FeedbackService, {
import * as Delegations from '../../state/ducks/Delegations'
import { IMyDelegation } from '../../state/ducks/Delegations'
import * as UiState from '../../state/ducks/UiState'
import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'
import { IMyIdentity } from '../../types/Contact'
import {
IBlockingNotification,
Expand Down Expand Up @@ -75,7 +75,7 @@ type State = {

class DelegationNode extends React.Component<Props, State> {
private static inviteContactsTo(delegation: IMyDelegation): void {
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
UiState.Store.updateCurrentTaskAction({
objective: MessageBodyType.REQUEST_ACCEPT_DELEGATION,
props: {
Expand Down Expand Up @@ -105,7 +105,7 @@ class DelegationNode extends React.Component<Props, State> {
const { node } = this.state

const myDelegation = Delegations.getDelegation(
PersistentStore.store.getState(),
persistentStoreInstance.store.getState(),
node.delegation.id
)

Expand Down
8 changes: 5 additions & 3 deletions src/components/DevTools/DevTools.attestations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import MessageRepository from '../../services/MessageRepository'
import * as Claims from '../../state/ducks/Claims'
import * as Attestations from '../../state/ducks/Attestations'
import { IMyDelegation } from '../../state/ducks/Delegations'
import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'
import { IMyIdentity } from '../../types/Contact'
import { ICTypeWithMetadata } from '../../types/Ctype'
import { BsClaim, BsClaimsPool, BsClaimsPoolElement } from './DevTools.claims'
Expand Down Expand Up @@ -97,13 +97,15 @@ class BsAttestation {
// import to claimers claim
// therefore switch to claimer identity
BsIdentity.selectIdentity(claimerIdentity)
PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
Claims.Store.addRequestForAttestation(
requestForAttestation,
attesterIdentity.identity.address
)
)
PersistentStore.store.dispatch(Claims.Store.addAttestedClaim(attestedClaim))
persistentStoreInstance.store.dispatch(
Claims.Store.addAttestedClaim(attestedClaim)
)

if (withMessages) {
BsAttestation.sendMessages(
Expand Down
6 changes: 3 additions & 3 deletions src/components/DevTools/DevTools.claims.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Claim, CType, IClaim } from '@kiltprotocol/sdk-js'

import * as Claims from '../../state/ducks/Claims'
import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'
import { BsCType, BsCTypesPool } from './DevTools.ctypes'
import { BsIdentitiesPool, BsIdentity } from './DevTools.wallet'

Expand Down Expand Up @@ -34,7 +34,7 @@ class BsClaim {
identity.identity.address
)

PersistentStore.store.dispatch(
persistentStoreInstance.store.dispatch(
Claims.Store.saveAction(claim, { alias: bsClaimData.alias })
)

Expand Down Expand Up @@ -72,7 +72,7 @@ class BsClaim {
const bsClaim = await BsClaim.getBsClaimByKey(bsClaimKey)
BsIdentity.selectIdentity(await BsIdentity.getByKey(bsClaim.claimerKey))
const myClaims: Claims.Entry[] = Claims.getClaims(
PersistentStore.store.getState()
persistentStoreInstance.store.getState()
)
const myClaim: Claims.Entry | undefined = myClaims.find(
(claim: Claims.Entry) => claim.meta.alias === bsClaim.alias
Expand Down
6 changes: 3 additions & 3 deletions src/components/DevTools/DevTools.delegations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DelegationsService from '../../services/DelegationsService'
import MessageRepository from '../../services/MessageRepository'
import * as Delegations from '../../state/ducks/Delegations'
import { DelegationType, IMyDelegation } from '../../state/ducks/Delegations'
import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'
import { IMyIdentity } from '../../types/Contact'
import { ICTypeWithMetadata } from '../../types/Ctype'
import { BsCType, BsCTypesPool } from './DevTools.ctypes'
Expand Down Expand Up @@ -260,7 +260,7 @@ class BsDelegation {
if (match) {
BsIdentity.selectIdentity(await BsIdentity.getByKey(match.ownerKey))
const allDelegations: IMyDelegation[] = Delegations.getAllDelegations(
PersistentStore.store.getState()
persistentStoreInstance.store.getState()
)

const myDelegation = allDelegations.find(
Expand Down Expand Up @@ -288,7 +288,7 @@ class BsDelegation {
const bsDelegation = pool[bsDelegationKey]
if (bsDelegation) {
// the current pool contains the requested delegation
Delegations.getAllDelegations(PersistentStore.store.getState())
Delegations.getAllDelegations(persistentStoreInstance.store.getState())
return pool[bsDelegationKey]
}
// dive deeper
Expand Down
6 changes: 3 additions & 3 deletions src/components/DevTools/DevTools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { BsDelegation, BsDelegationsPool } from './DevTools.delegations'
import { BsIdentitiesPool, BsIdentity } from './DevTools.wallet'
import * as Wallet from '../../state/ducks/Wallet'
import * as Balances from '../../state/ducks/Balances'
import PersistentStore from '../../state/PersistentStore'
import { persistentStoreInstance } from '../../state/PersistentStore'
import { IMyIdentity } from '../../types/Contact'
import identitiesPool from './data/identities.json'

Expand Down Expand Up @@ -128,12 +128,12 @@ class DevTools extends React.Component<Props> {
]

const selectedIdentity: IMyIdentity = Wallet.getSelectedIdentity(
PersistentStore.store.getState()
persistentStoreInstance.store.getState()
)

const balance: BN = selectedIdentity
? Balances.getBalance(
PersistentStore.store.getState(),
persistentStoreInstance.store.getState(),
selectedIdentity.identity.address
)
: new BN(0)
Expand Down
Loading

0 comments on commit 13a9e26

Please sign in to comment.