@tokamak-private-dapps/private-state-cli 2.4.3 → 3.0.0
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/CHANGELOG.md +94 -4
- package/README.md +230 -90
- package/agents.md +1476 -148
- package/assets/service-terms.md +294 -0
- package/assets/tx-fees.json +4 -4
- package/commands/account.mjs +5 -1
- package/commands/channel.mjs +14 -0
- package/commands/index.mjs +5 -0
- package/commands/notes.mjs +5 -0
- package/commands/secret.mjs +20 -0
- package/commands/system.mjs +7 -2
- package/commands/wallet.mjs +12 -2
- package/investigator/README.md +13 -11
- package/investigator/index.html +1 -1
- package/lib/private-state-browser-wallet-helpers.mjs +91 -0
- package/lib/private-state-cli-command-registry.mjs +222 -97
- package/lib/private-state-runtime-management.mjs +90 -10
- package/lib/private-state-terms.mjs +35 -0
- package/lib/runtime.mjs +3493 -399
- package/package.json +3 -3
- package/private-state-bridge-cli.mjs +1 -1
- package/cli-assistant.html +0 -1534
package/investigator/index.html
CHANGED
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
<div id="status" class="status">Load a raw evidence ZIP to begin.</div>
|
|
181
181
|
</div>
|
|
182
182
|
<div class="actions">
|
|
183
|
-
<button id="exportAscii" type="button" disabled>Export
|
|
183
|
+
<button id="exportAscii" type="button" disabled>Export plain-text report</button>
|
|
184
184
|
<button id="selectAll" type="button" disabled>Select all</button>
|
|
185
185
|
<button id="selectNone" type="button" disabled>Select none</button>
|
|
186
186
|
</div>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ethers,
|
|
3
|
+
getAddress,
|
|
4
|
+
} from "ethers";
|
|
5
|
+
|
|
6
|
+
export function personalSignPayload(message) {
|
|
7
|
+
if (typeof message === "string") {
|
|
8
|
+
return ethers.hexlify(ethers.toUtf8Bytes(message));
|
|
9
|
+
}
|
|
10
|
+
return ethers.hexlify(message);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function buildEip712Payload({ domain, types, value }) {
|
|
14
|
+
return {
|
|
15
|
+
types: {
|
|
16
|
+
EIP712Domain: eip712DomainType(domain),
|
|
17
|
+
...types,
|
|
18
|
+
},
|
|
19
|
+
primaryType: Object.keys(types)[0],
|
|
20
|
+
domain: normalizeTypedDataValue(domain),
|
|
21
|
+
message: normalizeTypedDataValue(value),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function eip712DomainType(domain) {
|
|
26
|
+
return [
|
|
27
|
+
["name", "string"],
|
|
28
|
+
["version", "string"],
|
|
29
|
+
["chainId", "uint256"],
|
|
30
|
+
["verifyingContract", "address"],
|
|
31
|
+
["salt", "bytes32"],
|
|
32
|
+
]
|
|
33
|
+
.filter(([name]) => domain?.[name] !== undefined && domain?.[name] !== null)
|
|
34
|
+
.map(([name, type]) => ({ name, type }));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function normalizeTypedDataValue(value) {
|
|
38
|
+
if (typeof value === "bigint") {
|
|
39
|
+
return value.toString();
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
return value.map((entry) => normalizeTypedDataValue(entry));
|
|
43
|
+
}
|
|
44
|
+
if (value instanceof Uint8Array) {
|
|
45
|
+
return ethers.hexlify(value);
|
|
46
|
+
}
|
|
47
|
+
if (value && typeof value === "object") {
|
|
48
|
+
return Object.fromEntries(
|
|
49
|
+
Object.entries(value)
|
|
50
|
+
.filter(([, entry]) => entry !== undefined)
|
|
51
|
+
.map(([key, entry]) => [key, normalizeTypedDataValue(entry)]),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function normalizeBrowserTransaction(transaction) {
|
|
58
|
+
const tx = {};
|
|
59
|
+
for (const [sourceKey, targetKey] of [
|
|
60
|
+
["from", "from"],
|
|
61
|
+
["to", "to"],
|
|
62
|
+
["data", "data"],
|
|
63
|
+
]) {
|
|
64
|
+
if (transaction[sourceKey] !== undefined && transaction[sourceKey] !== null) {
|
|
65
|
+
tx[targetKey] = sourceKey === "data" ? ethers.hexlify(transaction[sourceKey]) : getAddress(transaction[sourceKey]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (const [sourceKey, targetKey] of [
|
|
69
|
+
["value", "value"],
|
|
70
|
+
["gasLimit", "gas"],
|
|
71
|
+
["gasPrice", "gasPrice"],
|
|
72
|
+
["maxFeePerGas", "maxFeePerGas"],
|
|
73
|
+
["maxPriorityFeePerGas", "maxPriorityFeePerGas"],
|
|
74
|
+
["nonce", "nonce"],
|
|
75
|
+
["chainId", "chainId"],
|
|
76
|
+
]) {
|
|
77
|
+
if (transaction[sourceKey] !== undefined && transaction[sourceKey] !== null) {
|
|
78
|
+
tx[targetKey] = ethers.toQuantity(transaction[sourceKey]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return tx;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function safeJsonForScript(value) {
|
|
85
|
+
return JSON.stringify(value)
|
|
86
|
+
.replaceAll("<", "\\u003c")
|
|
87
|
+
.replaceAll(">", "\\u003e")
|
|
88
|
+
.replaceAll("&", "\\u0026")
|
|
89
|
+
.replaceAll("\u2028", "\\u2028")
|
|
90
|
+
.replaceAll("\u2029", "\\u2029");
|
|
91
|
+
}
|