privacycash 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/getUtxos.js +18 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/package.json +1 -1
- package/src/getUtxos.ts +18 -1
- package/src/utils/constants.ts +1 -1
package/dist/getUtxos.js
CHANGED
|
@@ -32,6 +32,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
|
|
|
32
32
|
getMyUtxosPromise = (async () => {
|
|
33
33
|
let valid_utxos = [];
|
|
34
34
|
let valid_strings = [];
|
|
35
|
+
let history_indexes = [];
|
|
35
36
|
try {
|
|
36
37
|
let offsetStr = storage.getItem(LSK_FETCH_OFFSET + localstorageKey(publicKey));
|
|
37
38
|
if (offsetStr) {
|
|
@@ -51,6 +52,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
|
|
|
51
52
|
const nonZeroUtxos = [];
|
|
52
53
|
const nonZeroEncrypted = [];
|
|
53
54
|
for (let [k, utxo] of fetched.utxos.entries()) {
|
|
55
|
+
history_indexes.push(utxo.index);
|
|
54
56
|
if (utxo.amount.toNumber() > 0) {
|
|
55
57
|
nonZeroUtxos.push(utxo);
|
|
56
58
|
nonZeroEncrypted.push(fetched.encryptedOutputs[k]);
|
|
@@ -71,7 +73,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
|
|
|
71
73
|
if (!fetched.hasMore) {
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
|
-
await sleep(
|
|
76
|
+
await sleep(20);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
catch (e) {
|
|
@@ -80,6 +82,21 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
|
|
|
80
82
|
finally {
|
|
81
83
|
getMyUtxosPromise = null;
|
|
82
84
|
}
|
|
85
|
+
// get history index
|
|
86
|
+
let historyKey = 'tradeHistory' + localstorageKey(publicKey);
|
|
87
|
+
let rec = storage.getItem(historyKey);
|
|
88
|
+
let recIndexes = [];
|
|
89
|
+
if (rec?.length) {
|
|
90
|
+
recIndexes = rec.split(',').map(n => Number(n));
|
|
91
|
+
}
|
|
92
|
+
if (recIndexes.length) {
|
|
93
|
+
history_indexes = [...history_indexes, ...recIndexes];
|
|
94
|
+
}
|
|
95
|
+
let unique_history_indexes = Array.from(new Set(history_indexes));
|
|
96
|
+
let top20 = unique_history_indexes.sort((a, b) => b - a).slice(0, 20);
|
|
97
|
+
if (top20.length) {
|
|
98
|
+
storage.setItem(historyKey, top20.join(','));
|
|
99
|
+
}
|
|
83
100
|
// store valid strings
|
|
84
101
|
logger.debug(`valid_strings len before set: ${valid_strings.length}`);
|
|
85
102
|
valid_strings = [...new Set(valid_strings)];
|
|
@@ -4,7 +4,7 @@ export declare const FIELD_SIZE: BN;
|
|
|
4
4
|
export declare const PROGRAM_ID: PublicKey;
|
|
5
5
|
export declare const DEPLOYER_ID: PublicKey;
|
|
6
6
|
export declare const FEE_RECIPIENT: PublicKey;
|
|
7
|
-
export declare const FETCH_UTXOS_GROUP_SIZE =
|
|
7
|
+
export declare const FETCH_UTXOS_GROUP_SIZE = 10000;
|
|
8
8
|
export declare const TRANSACT_IX_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
9
9
|
export declare const MERKLE_TREE_DEPTH = 26;
|
|
10
10
|
export declare const ALT_ADDRESS: PublicKey;
|
package/dist/utils/constants.js
CHANGED
|
@@ -4,7 +4,7 @@ export const FIELD_SIZE = new BN('2188824287183927522224640574525727508854836440
|
|
|
4
4
|
export const PROGRAM_ID = new PublicKey('9fhQBbumKEFuXtMBDw8AaQyAjCorLGJQiS3skWZdQyQD');
|
|
5
5
|
export const DEPLOYER_ID = new PublicKey('AWexibGxNFKTa1b5R5MN4PJr9HWnWRwf8EW9g8cLx3dM');
|
|
6
6
|
export const FEE_RECIPIENT = new PublicKey('AWexibGxNFKTa1b5R5MN4PJr9HWnWRwf8EW9g8cLx3dM');
|
|
7
|
-
export const FETCH_UTXOS_GROUP_SIZE =
|
|
7
|
+
export const FETCH_UTXOS_GROUP_SIZE = 10_000;
|
|
8
8
|
export const TRANSACT_IX_DISCRIMINATOR = Buffer.from([217, 149, 130, 143, 221, 52, 252, 119]);
|
|
9
9
|
export const MERKLE_TREE_DEPTH = 26;
|
|
10
10
|
export const ALT_ADDRESS = new PublicKey('72bpRay17JKp4k8H87p7ieU9C6aRDy5yCqwvtpTN2wuU');
|
package/package.json
CHANGED
package/src/getUtxos.ts
CHANGED
|
@@ -62,6 +62,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
|
|
|
62
62
|
getMyUtxosPromise = (async () => {
|
|
63
63
|
let valid_utxos: Utxo[] = []
|
|
64
64
|
let valid_strings: string[] = []
|
|
65
|
+
let history_indexes: number[] = []
|
|
65
66
|
try {
|
|
66
67
|
let offsetStr = storage.getItem(LSK_FETCH_OFFSET + localstorageKey(publicKey))
|
|
67
68
|
if (offsetStr) {
|
|
@@ -81,6 +82,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
|
|
|
81
82
|
const nonZeroUtxos: Utxo[] = [];
|
|
82
83
|
const nonZeroEncrypted: any[] = [];
|
|
83
84
|
for (let [k, utxo] of fetched.utxos.entries()) {
|
|
85
|
+
history_indexes.push(utxo.index)
|
|
84
86
|
if (utxo.amount.toNumber() > 0) {
|
|
85
87
|
nonZeroUtxos.push(utxo);
|
|
86
88
|
nonZeroEncrypted.push(fetched.encryptedOutputs[k]);
|
|
@@ -101,13 +103,28 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
|
|
|
101
103
|
if (!fetched.hasMore) {
|
|
102
104
|
break
|
|
103
105
|
}
|
|
104
|
-
await sleep(
|
|
106
|
+
await sleep(20)
|
|
105
107
|
}
|
|
106
108
|
} catch (e: any) {
|
|
107
109
|
throw e
|
|
108
110
|
} finally {
|
|
109
111
|
getMyUtxosPromise = null
|
|
110
112
|
}
|
|
113
|
+
// get history index
|
|
114
|
+
let historyKey = 'tradeHistory' + localstorageKey(publicKey)
|
|
115
|
+
let rec = storage.getItem(historyKey)
|
|
116
|
+
let recIndexes: number[] = []
|
|
117
|
+
if (rec?.length) {
|
|
118
|
+
recIndexes = rec.split(',').map(n => Number(n))
|
|
119
|
+
}
|
|
120
|
+
if (recIndexes.length) {
|
|
121
|
+
history_indexes = [...history_indexes, ...recIndexes]
|
|
122
|
+
}
|
|
123
|
+
let unique_history_indexes = Array.from(new Set(history_indexes));
|
|
124
|
+
let top20 = unique_history_indexes.sort((a, b) => b - a).slice(0, 20);
|
|
125
|
+
if (top20.length) {
|
|
126
|
+
storage.setItem(historyKey, top20.join(','))
|
|
127
|
+
}
|
|
111
128
|
// store valid strings
|
|
112
129
|
logger.debug(`valid_strings len before set: ${valid_strings.length}`)
|
|
113
130
|
valid_strings = [...new Set(valid_strings)];
|
package/src/utils/constants.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const DEPLOYER_ID = new PublicKey('AWexibGxNFKTa1b5R5MN4PJr9HWnWRwf8EW9g8
|
|
|
9
9
|
|
|
10
10
|
export const FEE_RECIPIENT = new PublicKey('AWexibGxNFKTa1b5R5MN4PJr9HWnWRwf8EW9g8cLx3dM')
|
|
11
11
|
|
|
12
|
-
export const FETCH_UTXOS_GROUP_SIZE =
|
|
12
|
+
export const FETCH_UTXOS_GROUP_SIZE = 10_000
|
|
13
13
|
|
|
14
14
|
export const TRANSACT_IX_DISCRIMINATOR = Buffer.from([217, 149, 130, 143, 221, 52, 252, 119]);
|
|
15
15
|
|