Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Remove Pending data
Browse files Browse the repository at this point in the history
  • Loading branch information
pelle committed Apr 15, 2019
1 parent 24ce04c commit b433062
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 740 deletions.
34 changes: 0 additions & 34 deletions lib/actions/__tests__/__snapshots__/uportActions-test.js.snap
Expand Up @@ -387,40 +387,6 @@ Object {
}
`;

exports[`creates an ADD_PENDING_ATTESTATION action 1`] = `
Object {
"_backup": true,
"address": "0x123afdasdfasdfasdf",
"claimType": "name",
"iss": "0xdsasdfasdf",
"options": Object {},
"type": "ADD_PENDING_ATTESTATION",
}
`;

exports[`creates an ADD_PENDING_ATTESTATION action 2`] = `
Object {
"_backup": true,
"address": "0x123afdasdfasdfasdf",
"claimType": "name",
"iss": "0xdsasdfasdf",
"options": Object {
"applicant_id": 1234,
},
"type": "ADD_PENDING_ATTESTATION",
}
`;

exports[`creates an REMOVE_PENDING_ATTESTATION action 1`] = `
Object {
"_backup": true,
"address": "0x123afdasdfasdfasdf",
"claimType": "name",
"iss": "0xdsasdfasdf",
"type": "REMOVE_PENDING_ATTESTATION",
}
`;

exports[`creates an STORE_ATTESTATION action 1`] = `
Object {
"_backup": true,
Expand Down
11 changes: 1 addition & 10 deletions lib/actions/__tests__/uportActions-test.js
Expand Up @@ -21,7 +21,7 @@ import { createIdentity, createAccount, verificationSMS, verificationCall, verif
resetIdentity, removeIdentity, refreshExternalUport, createEncryptionKey, storeEncryptionKey, storePututuToken, storeFuelToken, storeActivity, updateActivity, openActivity,
removeActivity, updateInteractionStats, storeAttestation, removeAttestation, saveIpfsProfile,
addImage, storeExternalUport, storeCurrentIdentity, saveSegmentId, addImageOnboarding, savePublicUport, callFaucet,
addPendingAttestation, removePendingAttestation, storeKeyChainLevel } from 'uPortMobile/lib/actions/uportActions.js'
storeKeyChainLevel } from 'uPortMobile/lib/actions/uportActions.js'

const address = '0x0102030405'
const mockedTimeStamp = 1516134091907
Expand Down Expand Up @@ -194,15 +194,6 @@ it('creates a REMOVE_ATTESTATION action', () => {
expect(removeAttestation(address, '0xdsasdfasdf')).toMatchSnapshot()
})

it('creates an ADD_PENDING_ATTESTATION action', () => {
expect(addPendingAttestation('0x123afdasdfasdfasdf', '0xdsasdfasdf', 'name')).toMatchSnapshot()
expect(addPendingAttestation('0x123afdasdfasdfasdf', '0xdsasdfasdf', 'name', {applicant_id: 1234})).toMatchSnapshot()
})

it('creates an REMOVE_PENDING_ATTESTATION action', () => {
expect(removePendingAttestation('0x123afdasdfasdfasdf', '0xdsasdfasdf', 'name')).toMatchSnapshot()
})

it('creates a SAVE_PUBLIC_UPORT action', () => {
expect(savePublicUport('0x123')).toMatchSnapshot()
})
Expand Down
23 changes: 0 additions & 23 deletions lib/actions/uportActions.js
Expand Up @@ -66,8 +66,6 @@ import {
CREATE_ENCRYPTION_KEY,
STORE_ENCRYPTION_KEY,
STORE_PUTUTU_TOKEN,
ADD_PENDING_ATTESTATION,
REMOVE_PENDING_ATTESTATION,
STORE_KEYCHAIN_LEVEL,
STORE_SECURITY_LEVEL,
SHARE_STATE_DUMP,
Expand Down Expand Up @@ -392,27 +390,6 @@ export function updateInteractionStats(address, party, interactionType) {
}
}

export function addPendingAttestation(address, iss, claimType, options = {}) {
return {
type: ADD_PENDING_ATTESTATION,
address,
iss,
claimType,
options,
_backup,
}
}

export function removePendingAttestation(address, iss, claimType) {
return {
type: REMOVE_PENDING_ATTESTATION,
address,
iss,
claimType,
_backup,
}
}

// Expects an attestation object not a token itself
// The attestations object is basically the JWT payload with the jwt added under the `token` key
// This is not meant to be called directly
Expand Down
3 changes: 0 additions & 3 deletions lib/components/Verifications/VerificationListItem.js
Expand Up @@ -93,9 +93,6 @@ export function extractClaimType (verification) {
}

export function extractClaims (verification) {
if (verification.claimType) {
return 'pending'
}
const claim = verification.claim[Object.keys(verification.claim)[0]]
if (typeof claim === 'object') {
return Object.keys(claim).slice(0, 3).map(t => claim[t]).join(', ')
Expand Down
11 changes: 2 additions & 9 deletions lib/components/Verifications/Verifications.js
Expand Up @@ -22,10 +22,7 @@ import { connect } from 'react-redux'
import { toJs } from 'mori'

import VerificationList from 'uPortMobile/lib/components/Verifications/VerificationList'
import { removePendingAttestation } from 'uPortMobile/lib/actions/uportActions'

import { onlyPendingAndLatestAttestations,
pendingOrIssuedAttestationFor, pendingAttestationFor} from 'uPortMobile/lib/selectors/attestations'
import { onlyLatestAttestationsWithIssuer } from 'uPortMobile/lib/selectors/attestations'
import { externalProfile } from 'uPortMobile/lib/selectors/requests'
import { colors, font, textStyles } from 'uPortMobile/lib/styles/globalStyles'

Expand Down Expand Up @@ -74,9 +71,6 @@ export class Verifications extends React.Component {
}

render () {
// console.log( `pendingAttestations -> ${this.props.pendingAttestations}`)
// console.log( `pendingAttestationsFor -> ${this.props.pendingAttestationsFor}`)
// console.log( `pendingOrIssuedAttestationFor -> ${this.props.pendingOrIssuedAttestationFor}`)
return (
<View style={{padding: 10, flex: 1, backgroundColor: colors.white246, borderTopWidth: 1, borderColor: colors.white216}}>
{!this.props.attestations.length && <View>
Expand All @@ -97,14 +91,13 @@ export class Verifications extends React.Component {

Verifications.propTypes = {
attestations: PropTypes.array,
pendingAttestation: PropTypes.array,
lookupIssuer: PropTypes.func
}

const mapStateToProps = (state, ownProps) => {
return {
...ownProps,
attestations: onlyPendingAndLatestAttestations(state),
attestations: onlyLatestAttestationsWithIssuer(state),
lookupIssuer: (clientId) => toJs(externalProfile(state, clientId)),
address: currentAddress(state)
}
Expand Down
Expand Up @@ -53,13 +53,6 @@ const verificationNoExpiration = {
issuer
}

const pending = {
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
claimType: 'employer',
iss: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
issuer
}

const complexVerification = {
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
claim: {
Expand Down Expand Up @@ -97,17 +90,8 @@ describe('render VerificationListItem', () => {
expect(tree).toMatchSnapshot()
})

it('pending]', () => {
const tree = renderer.create(
<VerificationListItem
verification={pending}
selectVerification={handleClaimClick}
/>).toJSON()
expect(tree).toMatchSnapshot()
})

it('returns the verification claimType from the verification', () => {
expect(extractClaimType(pending)).toEqual('employer')
expect(extractClaimType(verification)).toEqual('employer')
})

it('extractClaims from the verification', () => {
Expand Down
Expand Up @@ -31,16 +31,6 @@ const issuer = {
name: 'Issuer Name'
}

const pendingAttestations = [{
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
claim: { employer: 'Consensys AG' },
iss: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
iat: 1482268217249,
exp: 1482354617249,
token: 'tokenstring',
issuer
}]

const attestations = [
{
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
Expand Down Expand Up @@ -115,18 +105,7 @@ const simpleIdentity = {
},
token: '0014.TOKEN'
}
},
pendingAttestations: {
'0x1bc5cbf71b068642fc5e89c5e3d0bdb3e366bc01': {
nationalId: {applicant_id: 1234},
name: {}
},
'0x1bc5cbf71b068642fc5e89c5e3d0bdb3e366bc02': {
nationalId: {}
}

}
}
}}
const withIssuers = toClj({
external: {
'0x1bc5cbf71b068642fc5e89c5e3d0bdb3e366bc01': {
Expand All @@ -142,17 +121,6 @@ const uport = uportReducer(withIssuers, storeIdentity(simpleIdentity))
const withVerifications = {...emptyState, uport}
// 47,73,105
describe('rendering', () => {
it('both pending and issued verifications', () => {
const tree = renderer.create(
<FakeProvider state={emptyState}>
<Verifications
attestations={attestations}
navigator={new FakeNavigator()}
/>
</FakeProvider>
).toJSON()
expect(tree).toMatchSnapshot()
})

it('only issued verifications', () => {
const tree = renderer.create(
Expand All @@ -166,18 +134,6 @@ describe('rendering', () => {
expect(tree).toMatchSnapshot()
})

it('only pending verifications', () => {
const tree = renderer.create(
<FakeProvider state={emptyState}>
<Verifications
attestations={pendingAttestations}
navigator={new FakeNavigator()}
/>
</FakeProvider>
).toJSON()
expect(tree).toMatchSnapshot()
})

it('empty', () => {
const tree = renderer.create(
<FakeProvider state={emptyState}>
Expand Down
2 changes: 0 additions & 2 deletions lib/constants/UportActionTypes.js
Expand Up @@ -64,9 +64,7 @@ export const UPDATE_INTERACTION_STATS = 'UPDATE_INTERACTION_STATS'

export const ADD_ATTESTATION = 'ADD_ATTESTATION'
export const STORE_ATTESTATION = 'STORE_ATTESTATION'
export const ADD_PENDING_ATTESTATION = 'ADD_PENDING_ATTESTATION'
export const REMOVE_ATTESTATION = 'REMOVE_ATTESTATION'
export const REMOVE_PENDING_ATTESTATION = 'REMOVE_PENDING_ATTESTATION'

export const SAVE_PUBLIC_UPORT = 'SAVE_PUBLIC_UPORT'
export const SAVE_IPFS_PROFILE = 'SAVE_IPFS_PROFILE'
Expand Down

0 comments on commit b433062

Please sign in to comment.