@spirobel/monero-wallet-api 0.6.8 → 0.6.9
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.
|
@@ -231,7 +231,9 @@ export function outputStatus(output, cache, current_height) {
|
|
|
231
231
|
return { status: "spent" };
|
|
232
232
|
}
|
|
233
233
|
const unlock_height = unlockedAtHeight(output);
|
|
234
|
-
|
|
234
|
+
// current_height is the top block index. monerod compares against the
|
|
235
|
+
// block count (top index + 1), the height the spending tx would land in.
|
|
236
|
+
if (unlock_height > current_height + 1) {
|
|
235
237
|
return { status: "pending", unlock_height };
|
|
236
238
|
}
|
|
237
239
|
return { status: "spendable" };
|
package/dist/tools/content.d.ts
CHANGED
|
@@ -15,8 +15,7 @@ declare global {
|
|
|
15
15
|
var browser: ExtensionBrowser;
|
|
16
16
|
var chrome: ExtensionBrowser;
|
|
17
17
|
}
|
|
18
|
-
/** send toolCall and openSidebar to worker. after the check, toolCall message to worker again to persist validity status,
|
|
19
|
-
* potential second round of communication with backend. */
|
|
20
18
|
export declare function interceptToolLinkCallback(e: Event): void;
|
|
19
|
+
export declare function deliverToolUrl(url: string): boolean;
|
|
21
20
|
export declare function installToolLinkEventInterception(): void;
|
|
22
21
|
export {};
|
package/dist/tools/content.js
CHANGED
|
@@ -28,13 +28,7 @@ function anchorFromEvent(e) {
|
|
|
28
28
|
}
|
|
29
29
|
/** send toolCall and openSidebar to worker. after the check, toolCall message to worker again to persist validity status,
|
|
30
30
|
* potential second round of communication with backend. */
|
|
31
|
-
|
|
32
|
-
const link = anchorFromEvent(e);
|
|
33
|
-
const monerotoolLink = processTargetLink(link);
|
|
34
|
-
if (!link || !monerotoolLink)
|
|
35
|
-
return;
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
e.stopImmediatePropagation();
|
|
31
|
+
function deliver(monerotoolLink) {
|
|
38
32
|
void sendToBackground("toolCall", monerotoolLink).catch(() => { });
|
|
39
33
|
void sendToBackground("openSidebar", null).catch(() => { });
|
|
40
34
|
checkToolInvocationValidity(monerotoolLink).then((result) => {
|
|
@@ -46,8 +40,36 @@ export function interceptToolLinkCallback(e) {
|
|
|
46
40
|
tools[id]?.content.execute_deliver?.(monerotoolLink);
|
|
47
41
|
});
|
|
48
42
|
}
|
|
43
|
+
export function interceptToolLinkCallback(e) {
|
|
44
|
+
const link = anchorFromEvent(e);
|
|
45
|
+
const monerotoolLink = processTargetLink(link);
|
|
46
|
+
if (!link || !monerotoolLink)
|
|
47
|
+
return;
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
e.stopImmediatePropagation();
|
|
50
|
+
deliver(monerotoolLink);
|
|
51
|
+
}
|
|
52
|
+
// the page url itself is the tool link. a click never happens.
|
|
53
|
+
export function deliverToolUrl(url) {
|
|
54
|
+
let href = url;
|
|
55
|
+
let hostname = "";
|
|
56
|
+
try {
|
|
57
|
+
const parsed = new URL(url);
|
|
58
|
+
href = parsed.href;
|
|
59
|
+
hostname = parsed.hostname;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const invo = parseToolInvocation(href, "", { href, hostname });
|
|
65
|
+
if (!invo)
|
|
66
|
+
return false;
|
|
67
|
+
deliver(invo);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
49
70
|
export function installToolLinkEventInterception() {
|
|
50
71
|
document.addEventListener("click", interceptToolLinkCallback, true);
|
|
51
72
|
document.addEventListener("touchend", interceptToolLinkCallback, true);
|
|
52
73
|
document.addEventListener("keydown", interceptToolLinkCallback, true);
|
|
74
|
+
deliverToolUrl(location.href);
|
|
53
75
|
}
|
|
@@ -45,11 +45,12 @@ export function createToolLink(tool) {
|
|
|
45
45
|
throw new Error("unknown tool");
|
|
46
46
|
return tools[id].counterparty.make(tool.payload);
|
|
47
47
|
}
|
|
48
|
+
// xmr3.ts API to parse tool links
|
|
48
49
|
export function parseToolInvocation(link, linkText, context_location) {
|
|
49
|
-
const context_domain = getDomainWithTLD(context_location.hostname);
|
|
50
|
-
const context_href = context_location.href;
|
|
51
50
|
const link_parse = parseToolLink(link);
|
|
52
51
|
if (link_parse) {
|
|
52
|
+
const context_domain = getDomainWithTLD(context_location.hostname);
|
|
53
|
+
const context_href = context_location.href;
|
|
53
54
|
return {
|
|
54
55
|
tool: link_parse,
|
|
55
56
|
destination_domain: parseDestination(link),
|
|
@@ -65,6 +66,8 @@ export function parseToolInvocation(link, linkText, context_location) {
|
|
|
65
66
|
}
|
|
66
67
|
const linkText_parse = parseToolLink(linkText);
|
|
67
68
|
if (linkText_parse) {
|
|
69
|
+
const context_domain = getDomainWithTLD(context_location.hostname);
|
|
70
|
+
const context_href = context_location.href;
|
|
68
71
|
return {
|
|
69
72
|
tool: linkText_parse,
|
|
70
73
|
destination_domain: parseDestination(linkText),
|