@seams/wallet 0.9.0 → 0.9.1
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/README.md +3 -3
- package/dist/.build-inputs.sha256 +1 -1
- package/dist/esm/core/signingEngine/chains/evm/bytes.js +15 -1
- package/dist/esm/core/signingEngine/flows/signEvmFamily/signingFlow.js +1 -1
- package/dist/esm/core/signingEngine/flows/signNear/shared/ed25519YaoNormalSigning.js +84 -38
- package/dist/esm/core/signingEngine/flows/signNear/signTransactions.js +49 -2
- package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/abi/abiDecode.js +315 -0
- package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/abi/enrichDisplayModelWithAbi.js +77 -0
- package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/formatters.js +10 -1
- package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/renderers/fallback.js +52 -0
- package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/renderers/types.js +62 -0
- package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/tree.js +249 -0
- package/dist/esm/sdk/{host-B1CdRGoI.js → host-c1__wJwz.js} +1 -1
- package/dist/esm/sdk/{runtime-auth-tgfe70hU.js → runtime-auth-BKFyLISf.js} +1 -1
- package/dist/{public/sdk/runtime-device-link-BUxuQupR.js → esm/sdk/runtime-device-link-ENxdEXQW.js} +1 -1
- package/dist/{public/sdk/runtime-ecdsa-tempo-DOBk_EtI.js → esm/sdk/runtime-ecdsa-tempo-DhGEb9U7.js} +1 -1
- package/dist/esm/sdk/{runtime-email-otp-CsAJKvYC.js → runtime-email-otp-dgsP7XZi.js} +1 -1
- package/dist/esm/sdk/{runtime-export-7REbcnBl.js → runtime-export-D2RCm5Gk.js} +1 -1
- package/dist/esm/sdk/{runtime-near-BA0DQf6H.js → runtime-near-Bf-9MFBQ.js} +1 -1
- package/dist/esm/sdk/{runtime-preferences-cRViPE8a.js → runtime-preferences-LQ8SPE7o.js} +1 -1
- package/dist/esm/sdk/{runtime-recovery-RRc8Yz1y.js → runtime-recovery-BuEzJzuZ.js} +1 -1
- package/dist/esm/sdk/shared-8ffIBYw2.js +6 -0
- package/dist/esm/sdk/signNear-BhTkDm2-.js +1 -0
- package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/esm/utils/intentDigest.js +59 -1
- package/dist/public/headers.manifest.json +1 -1
- package/dist/public/sdk/{host-B1CdRGoI.js → host-c1__wJwz.js} +1 -1
- package/dist/public/sdk/{runtime-auth-tgfe70hU.js → runtime-auth-BKFyLISf.js} +1 -1
- package/dist/{esm/sdk/runtime-device-link-BUxuQupR.js → public/sdk/runtime-device-link-ENxdEXQW.js} +1 -1
- package/dist/{esm/sdk/runtime-ecdsa-tempo-DOBk_EtI.js → public/sdk/runtime-ecdsa-tempo-DhGEb9U7.js} +1 -1
- package/dist/public/sdk/{runtime-email-otp-CsAJKvYC.js → runtime-email-otp-dgsP7XZi.js} +1 -1
- package/dist/public/sdk/{runtime-export-7REbcnBl.js → runtime-export-D2RCm5Gk.js} +1 -1
- package/dist/public/sdk/{runtime-near-BA0DQf6H.js → runtime-near-Bf-9MFBQ.js} +1 -1
- package/dist/public/sdk/{runtime-preferences-cRViPE8a.js → runtime-preferences-LQ8SPE7o.js} +1 -1
- package/dist/public/sdk/{runtime-recovery-RRc8Yz1y.js → runtime-recovery-BuEzJzuZ.js} +1 -1
- package/dist/public/sdk/shared-8ffIBYw2.js +6 -0
- package/dist/public/sdk/signNear-BhTkDm2-.js +1 -0
- package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/public/wallet-assets.manifest.json +26 -26
- package/dist/public/wallet-service/index.html +4 -4
- package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/ed25519YaoNormalSigning.d.ts +16 -4
- package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/signatureOnlySigning.d.ts +3 -3
- package/dist/types/wallet/src/core/signingEngine/nonce/nearTransactionReadiness.d.ts +3 -0
- package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/confirmOperation.d.ts +3 -1
- package/dist/types/wallet/src/core/signingEngine/uiConfirm/handlers/flows/signing.d.ts +2 -0
- package/dist/types/wallet/src/core/signingEngine/uiConfirm/handlers/handlePromptFromWorker.d.ts +2 -0
- package/dist/types/wallet/src/core/signingEngine/uiConfirm/uiConfirm.types.d.ts +3 -0
- package/package.json +1 -1
- package/dist/esm/sdk/shared-DdfxBUGY.js +0 -6
- package/dist/esm/sdk/signNear-CO5bx24Z.js +0 -1
- package/dist/public/sdk/shared-DdfxBUGY.js +0 -6
- package/dist/public/sdk/signNear-CO5bx24Z.js +0 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { decodeCallDataWithAbi } from "./abiDecode.js";
|
|
2
|
+
//#region src/core/signingEngine/uiConfirm/ui/transaction-display/abi/enrichDisplayModelWithAbi.ts
|
|
3
|
+
function isGenericContractCallOperation(operation) {
|
|
4
|
+
return operation.kind === "generic.contractCall";
|
|
5
|
+
}
|
|
6
|
+
function rewriteCallingLabel(label, functionLabel) {
|
|
7
|
+
const normalized = String(label || "").trim();
|
|
8
|
+
const match = normalized.match(/^Calling\s+.+?\s+using\s+(.+)$/i);
|
|
9
|
+
if (!match) return normalized;
|
|
10
|
+
return `Calling ${functionLabel} using ${match[1]}`;
|
|
11
|
+
}
|
|
12
|
+
function isDataField(field) {
|
|
13
|
+
return String(field.label || "").trim().toLowerCase() === "data";
|
|
14
|
+
}
|
|
15
|
+
function rewriteDataFieldWithDecodedArgs(args) {
|
|
16
|
+
const next = Array.isArray(args.fields) ? [...args.fields] : [];
|
|
17
|
+
const dataFieldIndex = next.findIndex((field) => isDataField(field));
|
|
18
|
+
const existingDataField = dataFieldIndex >= 0 ? next[dataFieldIndex] : void 0;
|
|
19
|
+
const rawFallbackValue = String(existingDataField?.value || "").trim() || String(args.fallbackRawDataHex || "").trim();
|
|
20
|
+
const rewrittenDataField = {
|
|
21
|
+
...existingDataField || { label: "Data" },
|
|
22
|
+
value: args.decodedArgsJsonText,
|
|
23
|
+
renderAs: "file-content",
|
|
24
|
+
hideChevron: typeof existingDataField?.hideChevron === "boolean" ? existingDataField.hideChevron : true,
|
|
25
|
+
contentVariants: {
|
|
26
|
+
decoded: args.decodedArgsJsonText,
|
|
27
|
+
raw: rawFallbackValue,
|
|
28
|
+
defaultMode: "decoded"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (dataFieldIndex >= 0) {
|
|
32
|
+
next[dataFieldIndex] = rewrittenDataField;
|
|
33
|
+
return next;
|
|
34
|
+
}
|
|
35
|
+
next.push(rewrittenDataField);
|
|
36
|
+
return next;
|
|
37
|
+
}
|
|
38
|
+
function maybeDecodeOperationWithAbi(operation) {
|
|
39
|
+
const hint = operation.abiDecodeHint;
|
|
40
|
+
if (!hint || !Array.isArray(hint.abi) || hint.abi.length === 0) return operation;
|
|
41
|
+
const decoded = decodeCallDataWithAbi({
|
|
42
|
+
dataHex: hint.dataHex,
|
|
43
|
+
abi: hint.abi
|
|
44
|
+
});
|
|
45
|
+
if (!decoded) return operation;
|
|
46
|
+
const fields = decoded.decodedArgumentsJsonText ? rewriteDataFieldWithDecodedArgs({
|
|
47
|
+
fields: operation.fields,
|
|
48
|
+
decodedArgsJsonText: decoded.decodedArgumentsJsonText,
|
|
49
|
+
fallbackRawDataHex: hint.dataHex
|
|
50
|
+
}) : operation.fields;
|
|
51
|
+
return {
|
|
52
|
+
...operation,
|
|
53
|
+
label: rewriteCallingLabel(operation.label, decoded.functionLabel),
|
|
54
|
+
fields
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function enrichOperation(operation) {
|
|
58
|
+
const children = Array.isArray(operation.children) ? operation.children.map((child) => enrichOperation(child)) : operation.children;
|
|
59
|
+
const operationWithChildren = children === operation.children ? operation : {
|
|
60
|
+
...operation,
|
|
61
|
+
children
|
|
62
|
+
};
|
|
63
|
+
if (!isGenericContractCallOperation(operationWithChildren)) return operationWithChildren;
|
|
64
|
+
return maybeDecodeOperationWithAbi(operationWithChildren);
|
|
65
|
+
}
|
|
66
|
+
function enrichDisplayModelWithAbi(model) {
|
|
67
|
+
if (!Array.isArray(model.operations) || model.operations.length === 0) return model;
|
|
68
|
+
const operations = model.operations.map((operation) => enrichOperation(operation));
|
|
69
|
+
return {
|
|
70
|
+
...model,
|
|
71
|
+
operations
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { enrichDisplayModelWithAbi };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=enrichDisplayModelWithAbi.js.map
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
//#region src/core/signingEngine/uiConfirm/ui/transaction-display/formatters.ts
|
|
2
|
+
function formatArgs(args) {
|
|
3
|
+
if (!args) return "";
|
|
4
|
+
if (typeof args === "string") return args;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.stringify(args, (_k, v) => typeof v === "bigint" ? v.toString() : v, 2);
|
|
7
|
+
} catch {
|
|
8
|
+
return String(args);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
2
11
|
function formatDeposit(deposit) {
|
|
3
12
|
if (!deposit || deposit === "0") return "0 NEAR";
|
|
4
13
|
try {
|
|
@@ -43,6 +52,6 @@ function formatCodeSize(code) {
|
|
|
43
52
|
return "unknown";
|
|
44
53
|
}
|
|
45
54
|
//#endregion
|
|
46
|
-
export { formatCodeSize, formatDeposit, formatGas, shortenPubkey };
|
|
55
|
+
export { formatArgs, formatCodeSize, formatDeposit, formatGas, shortenPubkey };
|
|
47
56
|
|
|
48
57
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { buildFieldNodes } from "./types.js";
|
|
2
|
+
//#region src/core/signingEngine/uiConfirm/ui/transaction-display/renderers/fallback.ts
|
|
3
|
+
const renderFallbackDisplayOperation = ({ operation, depth, path, renderChild }) => {
|
|
4
|
+
const opId = String(operation.id || "").trim() || `op-${path}`;
|
|
5
|
+
const contractAddress = (() => {
|
|
6
|
+
const raw = String(operation.to || "").trim();
|
|
7
|
+
return /^0x[0-9a-fA-F]{40}$/.test(raw) ? raw : void 0;
|
|
8
|
+
})();
|
|
9
|
+
const description = String(operation.description || "").trim();
|
|
10
|
+
const childOps = Array.isArray(operation.children) ? operation.children.map((child, childIndex) => renderChild(child, depth + 1, `${path}.${childIndex}`)) : [];
|
|
11
|
+
const fieldNodes = buildFieldNodes(opId, operation.fields);
|
|
12
|
+
const metadataNodes = description ? [{
|
|
13
|
+
id: `${opId}-description`,
|
|
14
|
+
label: description,
|
|
15
|
+
type: "file",
|
|
16
|
+
open: false
|
|
17
|
+
}] : [];
|
|
18
|
+
if (operation.kind === "raw.fallback") {
|
|
19
|
+
const rawValue = String(operation.raw || "").trim();
|
|
20
|
+
if (rawValue) metadataNodes.push({
|
|
21
|
+
id: `${opId}-raw`,
|
|
22
|
+
label: "Raw payload",
|
|
23
|
+
type: "file",
|
|
24
|
+
open: false,
|
|
25
|
+
content: rawValue
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const children = [
|
|
29
|
+
...metadataNodes,
|
|
30
|
+
...fieldNodes,
|
|
31
|
+
...childOps
|
|
32
|
+
];
|
|
33
|
+
if (children.length === 0) return {
|
|
34
|
+
id: opId,
|
|
35
|
+
label: String(operation.label || operation.kind),
|
|
36
|
+
type: "file",
|
|
37
|
+
open: false,
|
|
38
|
+
contractAddress
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
id: opId,
|
|
42
|
+
label: String(operation.label || operation.kind),
|
|
43
|
+
type: "folder",
|
|
44
|
+
open: depth < 1,
|
|
45
|
+
contractAddress,
|
|
46
|
+
children
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { renderFallbackDisplayOperation };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=fallback.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/core/signingEngine/uiConfirm/ui/transaction-display/renderers/types.ts
|
|
2
|
+
function sanitizeContentVariants(variants) {
|
|
3
|
+
if (!variants) return void 0;
|
|
4
|
+
const decoded = String(variants.decoded || "");
|
|
5
|
+
const raw = String(variants.raw || "");
|
|
6
|
+
if (!decoded || !raw) return void 0;
|
|
7
|
+
if (decoded === raw) return void 0;
|
|
8
|
+
return {
|
|
9
|
+
decoded,
|
|
10
|
+
raw,
|
|
11
|
+
defaultMode: variants.defaultMode === "raw" ? "raw" : "decoded"
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function isZeroWeiDisplayField(label, value) {
|
|
15
|
+
if (!/Value \(wei\)$/i.test(label.trim())) return false;
|
|
16
|
+
const normalized = value.trim();
|
|
17
|
+
if (!normalized) return false;
|
|
18
|
+
if (normalized === "0") return true;
|
|
19
|
+
if (/^0x0+$/i.test(normalized)) return true;
|
|
20
|
+
try {
|
|
21
|
+
return BigInt(normalized) === 0n;
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function buildFieldNodes(parentId, fields) {
|
|
27
|
+
if (!Array.isArray(fields) || fields.length === 0) return [];
|
|
28
|
+
return fields.flatMap((field, fieldIndex) => {
|
|
29
|
+
const label = String(field.label || "").trim();
|
|
30
|
+
const value = String(field.value || "");
|
|
31
|
+
const renderAs = field.renderAs || "inline";
|
|
32
|
+
if (isZeroWeiDisplayField(label, value)) return [];
|
|
33
|
+
if (renderAs === "file-content") {
|
|
34
|
+
const contentVariants = sanitizeContentVariants(field.contentVariants);
|
|
35
|
+
const content = contentVariants?.defaultMode === "raw" ? contentVariants.raw : contentVariants?.decoded || value;
|
|
36
|
+
return [{
|
|
37
|
+
id: `${parentId}-field-${fieldIndex}`,
|
|
38
|
+
label: label ? `${label}:` : "",
|
|
39
|
+
fieldLabel: label ? `${label}:` : void 0,
|
|
40
|
+
type: "file",
|
|
41
|
+
open: false,
|
|
42
|
+
content,
|
|
43
|
+
...contentVariants ? { contentVariants } : {},
|
|
44
|
+
copyValue: typeof field.copyValue === "string" ? field.copyValue : void 0,
|
|
45
|
+
hideLabel: Boolean(field.hideLabel),
|
|
46
|
+
hideChevron: typeof field.hideChevron === "boolean" ? field.hideChevron : true
|
|
47
|
+
}];
|
|
48
|
+
}
|
|
49
|
+
return [{
|
|
50
|
+
id: `${parentId}-field-${fieldIndex}`,
|
|
51
|
+
label: label ? `${label}: ${value}` : value,
|
|
52
|
+
fieldLabel: label ? `${label}:` : void 0,
|
|
53
|
+
type: "file",
|
|
54
|
+
open: false,
|
|
55
|
+
copyValue: typeof field.copyValue === "string" ? field.copyValue : void 0
|
|
56
|
+
}];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { buildFieldNodes };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { isString } from "../../../../../shared-ts/src/utils/validation.js";
|
|
2
|
+
import { formatArgs, formatCodeSize, shortenPubkey } from "./formatters.js";
|
|
3
|
+
import { renderFallbackDisplayOperation } from "./renderers/fallback.js";
|
|
4
|
+
//#region src/core/signingEngine/uiConfirm/ui/transaction-display/tree.ts
|
|
5
|
+
function toChainLabel(chain) {
|
|
6
|
+
switch (chain) {
|
|
7
|
+
case "near": return "NEAR";
|
|
8
|
+
case "evm": return "EVM";
|
|
9
|
+
case "tempo": return "Tempo";
|
|
10
|
+
default: return "Unknown";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function buildWarningNodes(warnings) {
|
|
14
|
+
if (!Array.isArray(warnings) || warnings.length === 0) return [];
|
|
15
|
+
return [{
|
|
16
|
+
id: "warnings-root",
|
|
17
|
+
label: "Warnings",
|
|
18
|
+
type: "folder",
|
|
19
|
+
open: true,
|
|
20
|
+
children: warnings.map((warning, warningIndex) => ({
|
|
21
|
+
id: `warning-${warningIndex}`,
|
|
22
|
+
label: `[${String(warning.severity || "warning").toUpperCase()}] ${String(warning.message || "")}`,
|
|
23
|
+
type: "file",
|
|
24
|
+
open: false
|
|
25
|
+
}))
|
|
26
|
+
}];
|
|
27
|
+
}
|
|
28
|
+
function renderOperationNode(operation, depth, path) {
|
|
29
|
+
return renderFallbackDisplayOperation({
|
|
30
|
+
operation,
|
|
31
|
+
depth,
|
|
32
|
+
path,
|
|
33
|
+
renderChild: (childOperation, childDepth, childPath) => renderOperationNode(childOperation, childDepth, childPath)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function hideFolderChevrons(node) {
|
|
37
|
+
const children = Array.isArray(node.children) ? node.children.map((child) => hideFolderChevrons(child)) : void 0;
|
|
38
|
+
if (node.type !== "folder") return children ? {
|
|
39
|
+
...node,
|
|
40
|
+
children
|
|
41
|
+
} : node;
|
|
42
|
+
return {
|
|
43
|
+
...node,
|
|
44
|
+
hideChevron: true,
|
|
45
|
+
children
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function attachChainToNode(node, chain) {
|
|
49
|
+
const children = Array.isArray(node.children) ? node.children.map((child) => attachChainToNode(child, chain)) : void 0;
|
|
50
|
+
return {
|
|
51
|
+
...node,
|
|
52
|
+
chain,
|
|
53
|
+
...children ? { children } : {}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function buildDisplayTreeFromModel(model) {
|
|
57
|
+
const hideModelFolderChevrons = model.chain === "evm" || model.chain === "tempo";
|
|
58
|
+
const operationNodes = (Array.isArray(model.operations) ? model.operations : []).map((operation, operationIndex) => renderOperationNode(operation, 0, String(operationIndex))).map((node) => attachChainToNode(node, model.chain)).map((node) => hideModelFolderChevrons ? hideFolderChevrons(node) : node);
|
|
59
|
+
const rootChildren = [...buildWarningNodes(model.warnings).map((node) => attachChainToNode(node, model.chain)).map((node) => hideModelFolderChevrons ? hideFolderChevrons(node) : node), ...operationNodes];
|
|
60
|
+
if (rootChildren.length === 0) rootChildren.push({
|
|
61
|
+
id: "no-operations",
|
|
62
|
+
label: "No operations",
|
|
63
|
+
type: "file",
|
|
64
|
+
open: false
|
|
65
|
+
});
|
|
66
|
+
const chainLabel = toChainLabel(model.chain);
|
|
67
|
+
return {
|
|
68
|
+
id: "display-root",
|
|
69
|
+
label: String(model.title || "").trim() || `${chainLabel} Transaction`,
|
|
70
|
+
type: "folder",
|
|
71
|
+
open: true,
|
|
72
|
+
children: rootChildren
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function buildActionNode(action, idx) {
|
|
76
|
+
let actionNodes;
|
|
77
|
+
switch (action.type) {
|
|
78
|
+
case "FunctionCall":
|
|
79
|
+
actionNodes = [{
|
|
80
|
+
id: `a${idx}-args`,
|
|
81
|
+
label: "using args:",
|
|
82
|
+
type: "file",
|
|
83
|
+
open: false,
|
|
84
|
+
hideChevron: true,
|
|
85
|
+
hideLabel: true,
|
|
86
|
+
content: formatArgs(action.args)
|
|
87
|
+
}];
|
|
88
|
+
break;
|
|
89
|
+
case "Transfer":
|
|
90
|
+
actionNodes = [];
|
|
91
|
+
break;
|
|
92
|
+
case "CreateAccount":
|
|
93
|
+
actionNodes = [];
|
|
94
|
+
break;
|
|
95
|
+
case "DeployContract": {
|
|
96
|
+
const codeSize = formatCodeSize(action.code);
|
|
97
|
+
actionNodes = [{
|
|
98
|
+
id: `a${idx}-code-size`,
|
|
99
|
+
label: `WASM contract code size: ${codeSize}`,
|
|
100
|
+
type: "file",
|
|
101
|
+
open: false
|
|
102
|
+
}];
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "DeployGlobalContract": {
|
|
106
|
+
const code = action.code;
|
|
107
|
+
const deployMode = action.deployMode;
|
|
108
|
+
const codeSize = formatCodeSize(code);
|
|
109
|
+
actionNodes = [{
|
|
110
|
+
id: `a${idx}-deploy-mode`,
|
|
111
|
+
label: `mode: ${String(deployMode || "")}`,
|
|
112
|
+
type: "file",
|
|
113
|
+
open: false
|
|
114
|
+
}, {
|
|
115
|
+
id: `a${idx}-code-size`,
|
|
116
|
+
label: `WASM global contract code size: ${codeSize}`,
|
|
117
|
+
type: "file",
|
|
118
|
+
open: false
|
|
119
|
+
}];
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case "UseGlobalContract": {
|
|
123
|
+
const accountId = action.accountId;
|
|
124
|
+
const codeHash = action.codeHash;
|
|
125
|
+
let label;
|
|
126
|
+
if (accountId) label = `by account: ${String(accountId)}`;
|
|
127
|
+
else if (codeHash) label = `by hash: ${shortenPubkey(String(codeHash), {
|
|
128
|
+
prefix: 10,
|
|
129
|
+
suffix: 6
|
|
130
|
+
})}`;
|
|
131
|
+
else label = "by global contract identifier";
|
|
132
|
+
actionNodes = [{
|
|
133
|
+
id: `a${idx}-identifier`,
|
|
134
|
+
label,
|
|
135
|
+
type: "file",
|
|
136
|
+
open: false
|
|
137
|
+
}];
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "Stake":
|
|
141
|
+
actionNodes = [{
|
|
142
|
+
id: `a${idx}-publicKey`,
|
|
143
|
+
label: `validator: ${shortenPubkey(action.publicKey)}`,
|
|
144
|
+
type: "file",
|
|
145
|
+
open: true,
|
|
146
|
+
copyValue: action.publicKey
|
|
147
|
+
}];
|
|
148
|
+
break;
|
|
149
|
+
case "AddKey": {
|
|
150
|
+
const ak = action.accessKey;
|
|
151
|
+
let permissions = "";
|
|
152
|
+
try {
|
|
153
|
+
permissions = (isString(ak) ? JSON.parse(ak) : ak).permission === "FullAccess" ? "Full Access" : "Function Call";
|
|
154
|
+
} catch {
|
|
155
|
+
permissions = "Unknown";
|
|
156
|
+
}
|
|
157
|
+
actionNodes = [{
|
|
158
|
+
id: `a${idx}-publicKey`,
|
|
159
|
+
label: `key: ${shortenPubkey(action.publicKey)}`,
|
|
160
|
+
open: false,
|
|
161
|
+
type: "file",
|
|
162
|
+
copyValue: action.publicKey
|
|
163
|
+
}, {
|
|
164
|
+
id: `a${idx}-permissions`,
|
|
165
|
+
label: `permissions: ${permissions}`,
|
|
166
|
+
open: false,
|
|
167
|
+
type: "file"
|
|
168
|
+
}];
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case "DeleteKey":
|
|
172
|
+
actionNodes = [{
|
|
173
|
+
id: `a${idx}-publicKey`,
|
|
174
|
+
label: `key: ${shortenPubkey(action.publicKey)}`,
|
|
175
|
+
open: false,
|
|
176
|
+
type: "file",
|
|
177
|
+
copyValue: action.publicKey
|
|
178
|
+
}];
|
|
179
|
+
break;
|
|
180
|
+
case "DeleteAccount":
|
|
181
|
+
actionNodes = [{
|
|
182
|
+
id: `a${idx}-beneficiaryId`,
|
|
183
|
+
label: `sending balance to: ${action.beneficiaryId}`,
|
|
184
|
+
open: false,
|
|
185
|
+
type: "file"
|
|
186
|
+
}];
|
|
187
|
+
break;
|
|
188
|
+
default: {
|
|
189
|
+
let raw = "";
|
|
190
|
+
try {
|
|
191
|
+
raw = JSON.stringify(action, null, 2);
|
|
192
|
+
} catch {
|
|
193
|
+
raw = String(action);
|
|
194
|
+
}
|
|
195
|
+
actionNodes = [{
|
|
196
|
+
id: `a${idx}-action`,
|
|
197
|
+
label: `Action: ${action.type || "Unknown"}`,
|
|
198
|
+
open: false,
|
|
199
|
+
type: "file"
|
|
200
|
+
}, {
|
|
201
|
+
id: `a${idx}-raw`,
|
|
202
|
+
label: "Raw Data",
|
|
203
|
+
type: "file",
|
|
204
|
+
open: false,
|
|
205
|
+
content: raw
|
|
206
|
+
}];
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
id: `action-${idx}`,
|
|
212
|
+
label: "",
|
|
213
|
+
type: "folder",
|
|
214
|
+
open: false,
|
|
215
|
+
hideChevron: true,
|
|
216
|
+
action,
|
|
217
|
+
actionIndex: idx,
|
|
218
|
+
children: actionNodes
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function buildTransactionNode(tx, tIdx, totalTransactions) {
|
|
222
|
+
const actionFolders = tx.actions.map((action, idx) => buildActionNode(action, idx));
|
|
223
|
+
return {
|
|
224
|
+
id: `tx-${tIdx}`,
|
|
225
|
+
label: "",
|
|
226
|
+
type: "folder",
|
|
227
|
+
open: true,
|
|
228
|
+
hideChevron: true,
|
|
229
|
+
transaction: tx,
|
|
230
|
+
transactionIndex: tIdx,
|
|
231
|
+
totalTransactions,
|
|
232
|
+
children: [...actionFolders]
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function buildDisplayTreeFromTxPayloads(txSigningRequests) {
|
|
236
|
+
const totalTransactions = txSigningRequests.length;
|
|
237
|
+
const txFolders = txSigningRequests.map((tx, tIdx) => buildTransactionNode(tx, tIdx, totalTransactions));
|
|
238
|
+
return {
|
|
239
|
+
id: "txs-root",
|
|
240
|
+
label: totalTransactions > 1 ? "Transactions" : "Transaction",
|
|
241
|
+
type: "folder",
|
|
242
|
+
open: true,
|
|
243
|
+
children: txFolders
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
export { buildDisplayTreeFromModel, buildDisplayTreeFromTxPayloads };
|
|
248
|
+
|
|
249
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t}from"./chains-CiYQT1K4.js";import{_ as n,c as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,t as d,v as f}from"./messages-vxz27Way.js";import{a as p,c as m,i as h,l as g,n as _,o as v,s as y,t as b,u as x}from"./transactionReviewAdmission-C-a3ctCJ.js";import{t as S}from"./events-DsQJQ0Cl.js";import{t as C}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as w}from"./errors-BZO3LF6G.js";function T(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function E(){T(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),D(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;i()||o(r)}function D(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const O={};let k=null,A=null;function j(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),k):(O[e.kind]??=N(e.kind),O[e.kind])}async function M(){k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),A??=Promise.all([k,import(`./mountRecoveryCodeBackupSurface-B1qhFF6G.js`)]).then(()=>void 0),await A}function N(e){switch(e){case`auth`:return import(`./runtime-auth-tgfe70hU.js`);case`near`:return import(`./runtime-near-BA0DQf6H.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DOBk_EtI.js`);case`email_otp`:return import(`./runtime-email-otp-CsAJKvYC.js`);case`recovery`:return import(`./runtime-recovery-RRc8Yz1y.js`);case`export`:return import(`./runtime-export-7REbcnBl.js`);case`device_link`:return import(`./runtime-device-link-BUxuQupR.js`);case`preferences`:return import(`./runtime-preferences-cRViPE8a.js`)}return P(e)}function P(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function F(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function I(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function L(e){try{return C(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function R(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(u(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(r(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return F(e)}function z(e){return e.kind!==`boot`}let B=!1;const V=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function H(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function U(t){return!e(t)||!H(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!H(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function W(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function G(e){try{e.close()}catch{}}function K(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:d,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return G(e),!0}function q(e,t){return!t||t.has(e.kind)}function J(e,t,n,r){e.executionGeneration===t&&n(r)}function Y(e,t,n,r){return e.executionGeneration!==t||n(r)}function X(e={}){if(B)return;B=!0,E(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&M().catch(()=>void 0);let r=new Set,i=new Set,o={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},s=e=>{try{o.port?.postMessage(e)}catch{}},c=e=>{e&&r.add(e)},u=e=>!!e&&(r.has(e)||h(e)?.cancelled===!0),d=e=>{e&&r.delete(e)},C=e=>{e&&s({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},T=e=>!e||!u(e)?!1:h(e)?.cancelled?!0:(C(e),d(e),!0),D=()=>{for(let e of V){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(S.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},O=async r=>{let l=r.data;if(!l||!t(l))return;let S=l.requestId,E=o.executionGeneration,O=J.bind(null,o,E,s),k=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new p(`review_invalid_input`,`Review is unsupported for this request`);let e=m(l.transactionReview);if(e.requestId!==S)throw new p(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new p(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);k=new b(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>O({type:`TRANSACTION_REVIEW_STATE`,requestId:S,payload:e}),e=>O({type:`ERROR`,requestId:S,payload:{code:e instanceof p?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&_(new p(`review_identity_changed`,`The wallet session changed`));let t=R(l);if(!z(t))switch(t.type){case`PING`:s({type:`PONG`,requestId:S});return;case`PM_SET_CONFIG`:{let e=a(o.configuration,n(t.request.payload)),r=f(o.configuration.kind===`configured`?o.configuration.config:null)!==f(e.config);if(o.configuration=e,r){o.executionGeneration+=1;for(let e of i)s({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}o.onConfigurationChanged?.(),r&&(_(new p(`review_identity_changed`,`Wallet execution configuration changed`)),D()),s({type:`PONG`,requestId:S});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=y(t.request.payload);e&&h(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=m(r),i=h(t.requestId);if(t.requestId===e&&i&&g(t,i.metadata)){let e=new p(x(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{v(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}s({type:`PONG`,requestId:S});return}let i=e?h(e):void 0;if(i){i.cancel(new p(`cancelled`,`Request cancelled`)),s({type:`PONG`,requestId:S});return}c(e),D(),e&&C(e),s({type:`PONG`,requestId:S});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!q(t,e.supportedRuntimeRouteKinds)){s({type:`ERROR`,requestId:S,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}S&&i.add(S);let r=await j(t);if(E!==o.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:k,state:o,executionGeneration:E,req:t.request,post:J.bind(null,o,E,s),isCancelled:Y.bind(null,o,E,u),respondIfCancelled:Y.bind(null,o,E,T)})}catch(e){if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`||k?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-DEHsPxNm.js`);if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=w(e),i=t.resolveWalletBoundaryErrorCode({requestType:l.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:l.type,rawCode:n,code:i,message:r}),c=t.resolveWalletBoundarySignerKind(l.type);s({type:`ERROR`,requestId:S,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&c?{signerKind:c}:{}}})}finally{S&&(i.delete(S),d(S)),k?.finish()}};window.addEventListener(`message`,e=>{let t=U(e.data),n=e.ports[0];if(!(!t||!n||o.port)){if(e.source!==window.parent||!W(e.origin)){G(n);return}if(!K(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(o.parentOrigin=e.origin),o.port=n;try{o.port.onmessage=O,o.port.start?.()}catch{}s({type:`READY`,payload:{protocolVersion:l}})}}})}try{X()}catch(e){console.error(`[WalletHost] init failed`,e)}export{X as t};
|
|
1
|
+
import{C as e,S as t}from"./chains-CiYQT1K4.js";import{_ as n,c as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,t as d,v as f}from"./messages-vxz27Way.js";import{a as p,c as m,i as h,l as g,n as _,o as v,s as y,t as b,u as x}from"./transactionReviewAdmission-C-a3ctCJ.js";import{t as S}from"./events-DsQJQ0Cl.js";import{t as C}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as w}from"./errors-BZO3LF6G.js";function T(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function E(){T(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),D(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;i()||o(r)}function D(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const O={};let k=null,A=null;function j(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),k):(O[e.kind]??=N(e.kind),O[e.kind])}async function M(){k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),A??=Promise.all([k,import(`./mountRecoveryCodeBackupSurface-B1qhFF6G.js`)]).then(()=>void 0),await A}function N(e){switch(e){case`auth`:return import(`./runtime-auth-BKFyLISf.js`);case`near`:return import(`./runtime-near-Bf-9MFBQ.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DhGEb9U7.js`);case`email_otp`:return import(`./runtime-email-otp-dgsP7XZi.js`);case`recovery`:return import(`./runtime-recovery-BuEzJzuZ.js`);case`export`:return import(`./runtime-export-D2RCm5Gk.js`);case`device_link`:return import(`./runtime-device-link-ENxdEXQW.js`);case`preferences`:return import(`./runtime-preferences-LQ8SPE7o.js`)}return P(e)}function P(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function F(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function I(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function L(e){try{return C(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function R(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(u(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(r(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return F(e)}function z(e){return e.kind!==`boot`}let B=!1;const V=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function H(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function U(t){return!e(t)||!H(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!H(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function W(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function G(e){try{e.close()}catch{}}function K(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:d,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return G(e),!0}function q(e,t){return!t||t.has(e.kind)}function J(e,t,n,r){e.executionGeneration===t&&n(r)}function Y(e,t,n,r){return e.executionGeneration!==t||n(r)}function X(e={}){if(B)return;B=!0,E(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&M().catch(()=>void 0);let r=new Set,i=new Set,o={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},s=e=>{try{o.port?.postMessage(e)}catch{}},c=e=>{e&&r.add(e)},u=e=>!!e&&(r.has(e)||h(e)?.cancelled===!0),d=e=>{e&&r.delete(e)},C=e=>{e&&s({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},T=e=>!e||!u(e)?!1:h(e)?.cancelled?!0:(C(e),d(e),!0),D=()=>{for(let e of V){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(S.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},O=async r=>{let l=r.data;if(!l||!t(l))return;let S=l.requestId,E=o.executionGeneration,O=J.bind(null,o,E,s),k=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new p(`review_invalid_input`,`Review is unsupported for this request`);let e=m(l.transactionReview);if(e.requestId!==S)throw new p(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new p(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);k=new b(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>O({type:`TRANSACTION_REVIEW_STATE`,requestId:S,payload:e}),e=>O({type:`ERROR`,requestId:S,payload:{code:e instanceof p?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&_(new p(`review_identity_changed`,`The wallet session changed`));let t=R(l);if(!z(t))switch(t.type){case`PING`:s({type:`PONG`,requestId:S});return;case`PM_SET_CONFIG`:{let e=a(o.configuration,n(t.request.payload)),r=f(o.configuration.kind===`configured`?o.configuration.config:null)!==f(e.config);if(o.configuration=e,r){o.executionGeneration+=1;for(let e of i)s({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}o.onConfigurationChanged?.(),r&&(_(new p(`review_identity_changed`,`Wallet execution configuration changed`)),D()),s({type:`PONG`,requestId:S});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=y(t.request.payload);e&&h(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=m(r),i=h(t.requestId);if(t.requestId===e&&i&&g(t,i.metadata)){let e=new p(x(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{v(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}s({type:`PONG`,requestId:S});return}let i=e?h(e):void 0;if(i){i.cancel(new p(`cancelled`,`Request cancelled`)),s({type:`PONG`,requestId:S});return}c(e),D(),e&&C(e),s({type:`PONG`,requestId:S});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!q(t,e.supportedRuntimeRouteKinds)){s({type:`ERROR`,requestId:S,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}S&&i.add(S);let r=await j(t);if(E!==o.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:k,state:o,executionGeneration:E,req:t.request,post:J.bind(null,o,E,s),isCancelled:Y.bind(null,o,E,u),respondIfCancelled:Y.bind(null,o,E,T)})}catch(e){if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`||k?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-DEHsPxNm.js`);if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=w(e),i=t.resolveWalletBoundaryErrorCode({requestType:l.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:l.type,rawCode:n,code:i,message:r}),c=t.resolveWalletBoundarySignerKind(l.type);s({type:`ERROR`,requestId:S,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&c?{signerKind:c}:{}}})}finally{S&&(i.delete(S),d(S)),k?.finish()}};window.addEventListener(`message`,e=>{let t=U(e.data),n=e.ports[0];if(!(!t||!n||o.port)){if(e.source!==window.parent||!W(e.origin)){G(n);return}if(!K(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(o.parentOrigin=e.origin),o.port=n;try{o.port.onmessage=O,o.port.start?.()}catch{}s({type:`READY`,payload:{protocolVersion:l}})}}})}try{X()}catch(e){console.error(`[WalletHost] init failed`,e)}export{X as t};
|