Skip to content

Commit 03517ef

Browse files
committed
Change some native parameters to objects
1 parent c447cad commit 03517ef

File tree

3 files changed

+43
-29
lines changed

3 files changed

+43
-29
lines changed

packages/ironfish-native-module/src/index.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,45 +53,56 @@ export function isValidPublicAddress(hexAddress: string): boolean {
5353
return IronfishNativeModule.isValidPublicAddress(hexAddress);
5454
}
5555

56-
export function unpackGzip(
57-
gzipPath: string,
58-
outputPath: string,
59-
): Promise<boolean> {
56+
export function unpackGzip({
57+
gzipPath,
58+
outputPath,
59+
}: {
60+
gzipPath: string;
61+
outputPath: string;
62+
}): Promise<boolean> {
6063
return IronfishNativeModule.unpackGzip(gzipPath, outputPath);
6164
}
6265

63-
export function readPartialFile(
64-
path: string,
65-
offset: number,
66-
length: number,
67-
): Promise<Uint8Array> {
66+
export function readPartialFile({
67+
path,
68+
offset,
69+
length,
70+
}: {
71+
path: string;
72+
offset: number;
73+
length: number;
74+
}): Promise<Uint8Array> {
6875
return IronfishNativeModule.readPartialFile(path, offset, length);
6976
}
7077

7178
export function decryptNotesForOwner(
72-
noteEncrypted: string[],
79+
encryptedNotes: string[],
7380
incomingHexKey: string,
7481
): Promise<{ index: number; note: string }[]> {
7582
return IronfishNativeModule.decryptNotesForOwner(
76-
noteEncrypted,
83+
encryptedNotes,
7784
incomingHexKey,
7885
);
7986
}
8087

8188
export function decryptNotesForSpender(
82-
noteEncrypted: string[],
89+
encryptedNotes: string[],
8390
outgoingHexKey: string,
8491
): Promise<{ index: number; note: string }[]> {
8592
return IronfishNativeModule.decryptNotesForSpender(
86-
noteEncrypted,
93+
encryptedNotes,
8794
outgoingHexKey,
8895
);
8996
}
9097

91-
export function nullifier(
92-
note: string,
93-
position: string,
94-
viewKey: string,
95-
): Promise<string> {
96-
return IronfishNativeModule.nullifier(note, position, viewKey);
98+
export function nullifier({
99+
note,
100+
position,
101+
viewHexKey,
102+
}: {
103+
note: string;
104+
position: string;
105+
viewHexKey: string;
106+
}): Promise<string> {
107+
return IronfishNativeModule.nullifier(note, position, viewHexKey);
97108
}

packages/mobile-app/data/api/walletServerChunks.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ class WalletServerChunks {
106106
if (result.status !== 200) {
107107
console.warn("Unhandled status code", result.status);
108108
}
109-
await unpackGzip(directory + file + ".gz", directory + file);
109+
await unpackGzip({
110+
gzipPath: directory + file + ".gz",
111+
outputPath: directory + file,
112+
});
110113
}
111114

112115
/**
@@ -159,11 +162,11 @@ class WalletServerChunks {
159162
const start = ranges[pos][1];
160163
const end = ranges[endIndex][2];
161164
// TODO: start the next read while decoding
162-
const bytes = await readPartialFile(
163-
directory + file,
164-
start,
165-
end - start + 1,
166-
);
165+
const bytes = await readPartialFile({
166+
path: directory + file,
167+
offset: start,
168+
length: end - start + 1,
169+
});
167170

168171
for (let i = pos; i <= endIndex; i++) {
169172
const block = LightBlock.decode(

packages/mobile-app/data/wallet/wallet.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ class Wallet {
281281

282282
const note = new Note(Buffer.from(Uint8ArrayUtils.fromHex(result.note)));
283283
const position = startingNoteIndex + result.index;
284-
const nullifier = await IronfishNativeModule.nullifier(
285-
Uint8ArrayUtils.toHex(note.serialize()),
286-
position.toString(),
284+
const nullifier = await IronfishNativeModule.nullifier({
285+
note: Uint8ArrayUtils.toHex(note.serialize()),
286+
position: position.toString(),
287287
viewHexKey,
288-
);
288+
});
289289

290290
const hexHash = Uint8ArrayUtils.toHex(transaction.hash);
291291
const txnStore = transactions.get(hexHash);

0 commit comments

Comments
 (0)