Skip to content

Commit

Permalink
feat(data): ✨ encrypt alias & contact data
Browse files Browse the repository at this point in the history
  • Loading branch information
jojobyte committed Jan 21, 2024
1 parent 59265a1 commit c2b1116
Show file tree
Hide file tree
Showing 11 changed files with 383 additions and 295 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ A Graphical User Interface (GUI) for
- [x] Request
- [x] Send
- [x] Modify CrypticStorage.js Keystore code to be Xchain compatible
- [ ] Encrypt wallet data in LocalStorage / IndexedDB
- [x] Encrypt wallet data in LocalStorage / IndexedDB
- [x] Recovery Phrase
- [ ] Contact Data
- [ ] Backup Wallet & Contacts
- [x] Aliases Data
- [x] Contact Data
- [ ] Backup/Restore Wallet & Contacts
### Stage 2
- [ ] Transactions view
Expand Down
10 changes: 5 additions & 5 deletions src/components/contacts-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ const initialState = {
// },
handleClick: state => event => {
event.preventDefault()
console.log(
'handle contacts click',
event,
state,
)
// console.log(
// 'handle contacts click',
// event,
// state,
// )
},
handleContactsChange: (newState, oldState) => {
if (newState.contacts !== oldState.contacts) {
Expand Down
58 changes: 25 additions & 33 deletions src/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,6 @@ export function generatePaymentRequestURI(
let addr = state.wallet?.address || ''
let claims = []

// dash:XmPNH5bMkwwc1kjVGwxWxTs86C3ZsgjdSX?amount=0.0001
// dash:XktddCruaWEMDqqiciagWPXCfqc1jfY6zf?amount=0.0001
// dash:XtXnZkocKvrqGDxW7mhBvoR6yCAD99mnau?amount=0.0001

if (state.userInfo) {
let filteredInfo = Array.from(
Object.entries(state.userInfo)
Expand Down Expand Up @@ -658,41 +654,37 @@ export function generatePaymentRequestURI(
return res
}

// export function generatePaymentRequestURI(state) {
// let shareUri = `dash:${state.wallet?.address || ''}?`
// let shareParams = []

// if (state.amount > 0) {
// shareParams.push(`amount=${state.amount}`)
// }

// if (state.label) {
// shareParams.push(`label=${state.label}`)
// }
export async function getStoreData(
store,
callback,
iterableCallback = res => async (v, k, i) => res.push(v)
) {
let result = []

// if (state.message) {
// shareParams.push(`message=${state.message}`)
// }
return await store.keys().then(async function(keys) {
for (let k of keys) {
let v = await store.getItem(k)
await iterableCallback(result)(v, k)
}

// if (shareParams.length > 0) {
// shareUri += `?${shareParams.join('&')}`
// }
callback?.(result)

// return shareUri
// }
return result
}).catch(function(err) {
console.error('getStoreData', err)
return null
});
}

export async function loadStore(store, callback) {
// let storeLen = await store.length()
export async function loadStore(
store,
callback,
iterableCallback = res => v => res.push(v)
) {
let result = []

return await store.iterate((v, k, i) => {
result.push(v)

// if (i === storeLen) {
// return result
// }
})
.then(() => callback(result))
return await store.iterate(iterableCallback(result))
.then(() => callback?.(result))
.catch(err => {
console.error('loadStore', err)
return null
Expand Down
Loading

0 comments on commit c2b1116

Please sign in to comment.