Skip to content

Commit

Permalink
CR: update
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed Jan 30, 2023
1 parent f2bf2a1 commit 1ff7a3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/yoroi-wallets/cardano/ShelleyWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ export class ShelleyWallet implements WalletInterface {
}

get transactions() {
console.log('transactions', this.transactionManager.getTransactions())
return this.transactionManager.getTransactions()
}

Expand Down
17 changes: 10 additions & 7 deletions src/yoroi-wallets/cardano/transactionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,24 @@ export const makeTransactionManager = async (storage: Storage, backendConfig: Ba

export type TransactionManager = Awaited<ReturnType<typeof makeTransactionManager>>

type Memos = {
[txId: number]: string
}

export const makeMemosManager = async (storage: Storage) => {
const getMemos = () => storage.getAllKeys().then(storage.multiGet).then(Object.fromEntries)
let memos: Readonly<....> = await getMemos()
const getMemos = () => storage.getAllKeys().then(storage.multiGet).then(Object.fromEntries) ?? {}
let memos: Readonly<Memos> = await getMemos()

const updateMemos = (txId, memo) => memos = {...memos, {[txId]: memo}}
const updateMemos = (txId: string, memo: string) => (memos = {...memos, [txId]: memo})

const saveMemo = async (txId: string, memo: string): Promise<void> => {
updateMemos(txId, memo)
storage.setItem(txId, memo)
updateMemos(txId, memo)
await storage.setItem(txId, memo)
}

const clear = async () => {
memos = {}
storage.getAllKeys().then(storage.multiRemove)

await storage.getAllKeys().then(storage.multiRemove)
}

return {
Expand Down

0 comments on commit 1ff7a3e

Please sign in to comment.