@spirobel/monero-wallet-api 0.3.8 → 0.3.10
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.
|
@@ -269,6 +269,8 @@ export function resetStats(stats) {
|
|
|
269
269
|
stats.height = 0;
|
|
270
270
|
stats.total_spendable_amount = 0n;
|
|
271
271
|
stats.total_pending_amount = 0n;
|
|
272
|
+
stats.primary_address_received_amount = 0n;
|
|
273
|
+
stats.primary_address_pending_amount = 0n;
|
|
272
274
|
stats.found_transactions = {};
|
|
273
275
|
stats.ordered_transactions = [];
|
|
274
276
|
stats.subaddresses = {};
|
|
@@ -47,3 +47,15 @@ export declare const ADDRESS_VALID_RESPONSE: {
|
|
|
47
47
|
export declare const ADDRESS_INVALID_RESPONSE: {
|
|
48
48
|
readonly valid_address: false;
|
|
49
49
|
};
|
|
50
|
+
export type ShareViewkeyPayload = {
|
|
51
|
+
viewkey: string;
|
|
52
|
+
primary_address: string;
|
|
53
|
+
tool_invo: ParsedMoneroToolInvocation;
|
|
54
|
+
};
|
|
55
|
+
export type ShareViewkeyResult = {
|
|
56
|
+
ok: boolean;
|
|
57
|
+
successUrl: string | null;
|
|
58
|
+
};
|
|
59
|
+
export declare function shareViewKey002(payload: ShareViewkeyPayload): Promise<ShareViewkeyResult>;
|
|
60
|
+
export declare function potentialSuccessRedirect002(payload: ShareViewkeyPayload): Promise<void>;
|
|
61
|
+
export declare function constructPositive002Response(successUrl?: string): ShareViewkeyResult;
|
|
@@ -168,3 +168,60 @@ export const ADDRESS_VALID_RESPONSE = {
|
|
|
168
168
|
export const ADDRESS_INVALID_RESPONSE = {
|
|
169
169
|
valid_address: false,
|
|
170
170
|
};
|
|
171
|
+
export async function shareViewKey002(payload) {
|
|
172
|
+
const invo = payload.tool_invo;
|
|
173
|
+
if (invo.tool.tool_id !== "002")
|
|
174
|
+
return {
|
|
175
|
+
ok: false,
|
|
176
|
+
successUrl: null,
|
|
177
|
+
};
|
|
178
|
+
if (invo.valid !== "valid")
|
|
179
|
+
return {
|
|
180
|
+
ok: false,
|
|
181
|
+
successUrl: null,
|
|
182
|
+
};
|
|
183
|
+
const link = invo[invo.found_in];
|
|
184
|
+
const invo_link = new URL(link);
|
|
185
|
+
const shareVKUrl = `${invo_link.origin}/monerochan002/`;
|
|
186
|
+
const result = await fetch(shareVKUrl, {
|
|
187
|
+
method: "POST",
|
|
188
|
+
headers: { "Content-Type": "application/json" },
|
|
189
|
+
body: JSON.stringify({
|
|
190
|
+
viewkey: payload.viewkey,
|
|
191
|
+
primary_address: payload.primary_address,
|
|
192
|
+
}),
|
|
193
|
+
});
|
|
194
|
+
if (result.ok) {
|
|
195
|
+
const data = (await result.json());
|
|
196
|
+
if (data && typeof data === "object" && "ok" in data && data.ok === true) {
|
|
197
|
+
return {
|
|
198
|
+
ok: true,
|
|
199
|
+
successUrl: data.successUrl ?? null,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return {
|
|
204
|
+
ok: false,
|
|
205
|
+
successUrl: null,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
return {
|
|
211
|
+
ok: false,
|
|
212
|
+
successUrl: null,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export async function potentialSuccessRedirect002(payload) {
|
|
217
|
+
const shareVKresult = await shareViewKey002(payload);
|
|
218
|
+
if (shareVKresult.ok && shareVKresult.successUrl) {
|
|
219
|
+
window.location.href = shareVKresult.successUrl;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
export function constructPositive002Response(successUrl) {
|
|
223
|
+
return {
|
|
224
|
+
ok: true,
|
|
225
|
+
successUrl: successUrl ?? null,
|
|
226
|
+
};
|
|
227
|
+
}
|