Skip to content

Commit d0d142e

Browse files
committed
fix: persist monitored wallet data
1 parent fe8e31e commit d0d142e

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/localServer/workers/encrypt.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ const GasToEth = 0.00000001
2929
const mintCoNETCashEndpoint = `${CoNET_SI_Network_Domain}/api/mint_conetcash`
3030
const openSourceEndpoint = 'https://s3.us-east-1.wasabisys.com/conet-mvp/router/'
3131
const databaseName = 'CoNET'
32+
const monitoredWalletsDatabase = 'monitoredWallets'
3233
let activeNodes = null
3334
let Liveness:XMLHttpRequest|null = null
35+
3436
/**
3537
* CONET Platform
3638
*

src/localServer/workers/utilities/storage.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,26 @@ const checkStorage = async (plarformChannel: BroadcastChannel) => {
3232
nonce: 0
3333
}
3434

35-
try {
35+
try {
3636
doc = await database.get ('init', {latest: true})
3737
initData = JSON.parse ( buffer.Buffer.from (doc.title,'base64').toString ())
3838
passObj = initData.id
3939
preferences = initData.preferences
4040

4141
} catch (ex) {
42-
logger (`checkStorage have no CoNET data in IndexDB, INIT CoNET data`)
42+
logger (`checkStorage have no CoNET data in IndexDB, INIT CoNET data`)
4343
plarformChannel.postMessage('NONE')
4444
return returnInitNull (cmd)
4545
}
46-
47-
// if (initData.container) {
48-
// containerKeyObj = {
49-
// privateKeyArmor: initData.container.privateKeyArmor,
50-
// publicKeyArmor: initData.container.publicKeyArmor
51-
// }
52-
// }
5346

47+
try {
48+
const monitoredWalletsString = await database.get(monitoredWalletsDatabase)
49+
const monitoredWallets = JSON.parse( monitoredWalletsString?.title)
50+
CoNET_Data.monitoredWallets = monitoredWallets
51+
} catch (error) {
52+
53+
}
54+
5455
const data: systemInitialization = {
5556
preferences: preferences,
5657
passcode: {
@@ -61,11 +62,6 @@ const checkStorage = async (plarformChannel: BroadcastChannel) => {
6162
cmd.data = [data]
6263
plarformChannel.postMessage('LOCKED')
6364
returnCommand (cmd)
64-
65-
// already init database
66-
// fetchProxyData(`http://localhost:3001/connecting`, data => {
67-
// processCmd (data)
68-
// })
6965
}
7066

7167

src/localServer/workers/utilities/web3Util.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,7 @@ const getReferrer = async (wallet, CNTP_Referrals) => {
30023002
return result
30033003
}
30043004

3005-
const addMonitoredWallet = (cmd) => {
3005+
const addMonitoredWallet = async (cmd) => {
30063006
const walletAddress = cmd.data[0]
30073007

30083008
if (
@@ -3026,10 +3026,12 @@ const addMonitoredWallet = (cmd) => {
30263026
CoNET_Data?.monitoredWallets.push(monitoredWallet)
30273027
}
30283028

3029+
await storageHashData(monitoredWalletsDatabase, JSON.stringify(CoNET_Data.monitoredWallets))
3030+
30293031
return returnUUIDChannel(cmd)
30303032
}
30313033

3032-
const removeMonitoredWallet = (cmd) => {
3034+
const removeMonitoredWallet = async (cmd) => {
30333035
const walletAddress = cmd.data[0]
30343036

30353037
if (
@@ -3047,6 +3049,10 @@ const removeMonitoredWallet = (cmd) => {
30473049
if (CoNET_Data.monitoredWallets.find(w => w.address === walletAddress)) {
30483050
CoNET_Data.monitoredWallets = CoNET_Data?.monitoredWallets.filter(w => w.address !== walletAddress)
30493051
}
3052+
3053+
await storageHashData(monitoredWalletsDatabase, JSON.stringify(CoNET_Data.monitoredWallets))
3054+
3055+
return returnUUIDChannel(cmd);
30503056
}
30513057

30523058
const getBalanceOfMonitoredWallets = async () => {

0 commit comments

Comments
 (0)