dexe-mcp 0.17.0 → 0.20.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 +110 -0
- package/README.md +126 -228
- package/dexe-plugin/skills/dexe-create-dao/SKILL.md +92 -66
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/diag/checks.js +11 -0
- package/dist/diag/checks.js.map +1 -1
- package/dist/lib/avatarImage.d.ts +22 -0
- package/dist/lib/avatarImage.d.ts.map +1 -0
- package/dist/lib/avatarImage.js +199 -0
- package/dist/lib/avatarImage.js.map +1 -0
- package/dist/lib/imageSniff.d.ts +44 -0
- package/dist/lib/imageSniff.d.ts.map +1 -0
- package/dist/lib/imageSniff.js +145 -0
- package/dist/lib/imageSniff.js.map +1 -0
- package/dist/lib/preflight.d.ts +67 -4
- package/dist/lib/preflight.d.ts.map +1 -1
- package/dist/lib/preflight.js +155 -14
- package/dist/lib/preflight.js.map +1 -1
- package/dist/lib/qr.d.ts +43 -0
- package/dist/lib/qr.d.ts.map +1 -0
- package/dist/lib/qr.js +95 -0
- package/dist/lib/qr.js.map +1 -0
- package/dist/lib/walletconnect.d.ts +15 -0
- package/dist/lib/walletconnect.d.ts.map +1 -1
- package/dist/lib/walletconnect.js +26 -0
- package/dist/lib/walletconnect.js.map +1 -1
- package/dist/tools/daoCreate.d.ts +40 -1
- package/dist/tools/daoCreate.d.ts.map +1 -1
- package/dist/tools/daoCreate.js +272 -28
- package/dist/tools/daoCreate.js.map +1 -1
- package/dist/tools/daoDeploy.d.ts.map +1 -1
- package/dist/tools/daoDeploy.js +41 -3
- package/dist/tools/daoDeploy.js.map +1 -1
- package/dist/tools/flow.d.ts +16 -1
- package/dist/tools/flow.d.ts.map +1 -1
- package/dist/tools/flow.js +65 -11
- package/dist/tools/flow.js.map +1 -1
- package/dist/tools/getConfig.d.ts.map +1 -1
- package/dist/tools/getConfig.js +7 -0
- package/dist/tools/getConfig.js.map +1 -1
- package/dist/tools/index.js +3 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/ipfs.d.ts +1 -0
- package/dist/tools/ipfs.d.ts.map +1 -1
- package/dist/tools/ipfs.js +49 -42
- package/dist/tools/ipfs.js.map +1 -1
- package/dist/tools/otc.d.ts +2 -1
- package/dist/tools/otc.d.ts.map +1 -1
- package/dist/tools/otc.js +6 -4
- package/dist/tools/otc.js.map +1 -1
- package/dist/tools/txSend.d.ts.map +1 -1
- package/dist/tools/txSend.js +36 -14
- package/dist/tools/txSend.js.map +1 -1
- package/dist/tools/walletconnectStatus.d.ts.map +1 -1
- package/dist/tools/walletconnectStatus.js +13 -29
- package/dist/tools/walletconnectStatus.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Magic-byte sniffing for avatar uploads.
|
|
3
|
+
*
|
|
4
|
+
* The DeXe serving chain is unforgiving about content type: the Go
|
|
5
|
+
* `ipfs-cache` service copies DAO avatar bytes to R2 under `<descCid>.jpeg`
|
|
6
|
+
* with a hardcoded `image/jpeg` content-type and no byte inspection, and the
|
|
7
|
+
* app.dexe.io `<img>` has no error fallback after a successful GET. Raster
|
|
8
|
+
* bytes (JPEG/PNG/WebP/GIF) survive that because browsers content-sniff
|
|
9
|
+
* rasters inside `<img>`; SVG does not — browsers never sniff SVG, so SVG
|
|
10
|
+
* bytes labeled `image/jpeg` render as a broken image. Hence: validate what
|
|
11
|
+
* the caller claims against what the bytes actually are.
|
|
12
|
+
*/
|
|
13
|
+
export type SniffedImageFormat = "jpeg" | "png" | "webp" | "gif" | "svg" | "html" | "unknown";
|
|
14
|
+
export type RasterFormat = Extract<SniffedImageFormat, "jpeg" | "png" | "webp" | "gif">;
|
|
15
|
+
/** Identify an image (or image impostor) by its magic bytes. */
|
|
16
|
+
export declare function sniffImageFormat(bytes: Uint8Array): SniffedImageFormat;
|
|
17
|
+
/**
|
|
18
|
+
* Gate for every avatar upload path. Returns the detected raster format and
|
|
19
|
+
* its true MIME type, or throws an actionable error for anything that would
|
|
20
|
+
* end up as a permanently broken avatar on app.dexe.io.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertRasterAvatar(bytes: Uint8Array): {
|
|
23
|
+
format: RasterFormat;
|
|
24
|
+
mime: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Best-effort remote validation for avatar CIDs passed **by reference**
|
|
28
|
+
* (dexe_ipfs_upload_dao_metadata / dexe_ipfs_update_dao_metadata /
|
|
29
|
+
* dexe_dao_create take an avatarCID that was pinned elsewhere, so the local
|
|
30
|
+
* byte gate never saw it). Fetches the first KB of `<cid>/<fileName>` off the
|
|
31
|
+
* gateway chain and sniffs it.
|
|
32
|
+
*
|
|
33
|
+
* Verdicts:
|
|
34
|
+
* - `{ ok: true }` — bytes fetched, real raster.
|
|
35
|
+
* - `{ ok: false, error }` — bytes fetched, NOT a raster → hard-block.
|
|
36
|
+
* - `{ ok: true, warning }` — unreachable/timeout (fresh pins often
|
|
37
|
+
* haven't propagated to gateways yet) → proceed, surface the warning.
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkAvatarCidBytes(cid: string, fileName: string, gateways: string[], perRequestTimeoutMs?: number): Promise<{
|
|
40
|
+
ok: boolean;
|
|
41
|
+
error?: string;
|
|
42
|
+
warning?: string;
|
|
43
|
+
}>;
|
|
44
|
+
//# sourceMappingURL=imageSniff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSniff.d.ts","sourceRoot":"","sources":["../../src/lib/imageSniff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9F,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,kBAAkB,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC;AAmBxF,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAuBtE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA0B5F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAAE,EAClB,mBAAmB,SAAO,GACzB,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA2C5D"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Magic-byte sniffing for avatar uploads.
|
|
3
|
+
*
|
|
4
|
+
* The DeXe serving chain is unforgiving about content type: the Go
|
|
5
|
+
* `ipfs-cache` service copies DAO avatar bytes to R2 under `<descCid>.jpeg`
|
|
6
|
+
* with a hardcoded `image/jpeg` content-type and no byte inspection, and the
|
|
7
|
+
* app.dexe.io `<img>` has no error fallback after a successful GET. Raster
|
|
8
|
+
* bytes (JPEG/PNG/WebP/GIF) survive that because browsers content-sniff
|
|
9
|
+
* rasters inside `<img>`; SVG does not — browsers never sniff SVG, so SVG
|
|
10
|
+
* bytes labeled `image/jpeg` render as a broken image. Hence: validate what
|
|
11
|
+
* the caller claims against what the bytes actually are.
|
|
12
|
+
*/
|
|
13
|
+
const RASTER_MIME = {
|
|
14
|
+
jpeg: "image/jpeg",
|
|
15
|
+
png: "image/png",
|
|
16
|
+
webp: "image/webp",
|
|
17
|
+
gif: "image/gif",
|
|
18
|
+
};
|
|
19
|
+
const PNG_SIG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
20
|
+
function startsWith(bytes, sig, offset = 0) {
|
|
21
|
+
if (bytes.length < offset + sig.length)
|
|
22
|
+
return false;
|
|
23
|
+
for (let i = 0; i < sig.length; i++) {
|
|
24
|
+
if (bytes[offset + i] !== sig[i])
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
/** Identify an image (or image impostor) by its magic bytes. */
|
|
30
|
+
export function sniffImageFormat(bytes) {
|
|
31
|
+
if (startsWith(bytes, [0xff, 0xd8, 0xff]))
|
|
32
|
+
return "jpeg";
|
|
33
|
+
if (startsWith(bytes, PNG_SIG))
|
|
34
|
+
return "png";
|
|
35
|
+
if (startsWith(bytes, [0x47, 0x49, 0x46, 0x38, 0x37, 0x61]) || startsWith(bytes, [0x47, 0x49, 0x46, 0x38, 0x39, 0x61])) {
|
|
36
|
+
return "gif";
|
|
37
|
+
}
|
|
38
|
+
// RIFF....WEBP
|
|
39
|
+
if (startsWith(bytes, [0x52, 0x49, 0x46, 0x46]) && startsWith(bytes, [0x57, 0x45, 0x42, 0x50], 8)) {
|
|
40
|
+
return "webp";
|
|
41
|
+
}
|
|
42
|
+
// Text-based impostors: skip BOM + leading whitespace (trimStart strips
|
|
43
|
+
// U+FEFF too — it's spec whitespace), look at the first tag.
|
|
44
|
+
const head = Buffer.from(bytes.slice(0, 512))
|
|
45
|
+
.toString("utf8")
|
|
46
|
+
.trimStart()
|
|
47
|
+
.toLowerCase();
|
|
48
|
+
if (head.startsWith("<?xml") || head.startsWith("<svg"))
|
|
49
|
+
return "svg";
|
|
50
|
+
if (head.startsWith("<!doctype")) {
|
|
51
|
+
// `<!DOCTYPE svg ...>` is a legal SVG prologue — don't call it HTML.
|
|
52
|
+
return /^<!doctype\s+svg/.test(head) ? "svg" : "html";
|
|
53
|
+
}
|
|
54
|
+
if (head.startsWith("<html"))
|
|
55
|
+
return "html";
|
|
56
|
+
return "unknown";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gate for every avatar upload path. Returns the detected raster format and
|
|
60
|
+
* its true MIME type, or throws an actionable error for anything that would
|
|
61
|
+
* end up as a permanently broken avatar on app.dexe.io.
|
|
62
|
+
*/
|
|
63
|
+
export function assertRasterAvatar(bytes) {
|
|
64
|
+
const format = sniffImageFormat(bytes);
|
|
65
|
+
switch (format) {
|
|
66
|
+
case "jpeg":
|
|
67
|
+
case "png":
|
|
68
|
+
case "webp":
|
|
69
|
+
case "gif":
|
|
70
|
+
return { format, mime: RASTER_MIME[format] };
|
|
71
|
+
case "svg":
|
|
72
|
+
throw new Error("Avatar bytes are SVG, which never renders on app.dexe.io: the ipfs-cache service serves DAO avatars " +
|
|
73
|
+
"with a hardcoded image/jpeg content-type and browsers refuse SVG bytes labeled image/jpeg. " +
|
|
74
|
+
"Provide real raster bytes (JPEG/PNG/WebP/GIF), or use dexe_dao_generate_avatar to get a valid JPEG.");
|
|
75
|
+
case "html":
|
|
76
|
+
throw new Error("Avatar bytes look like an HTML page, not an image — most likely a gateway error/directory-listing page " +
|
|
77
|
+
"was downloaded instead of the image file. Re-fetch the image (use the full <cid>/<fileName> path, " +
|
|
78
|
+
"not the bare CID) and upload the actual raster bytes.");
|
|
79
|
+
default:
|
|
80
|
+
throw new Error("Avatar bytes are not a recognized raster image — expected JPEG (FF D8 FF), PNG, WebP, or GIF magic bytes. " +
|
|
81
|
+
"Check that the base64 payload is the image file itself (not a data: URL wrapper or a truncated buffer).");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Best-effort remote validation for avatar CIDs passed **by reference**
|
|
86
|
+
* (dexe_ipfs_upload_dao_metadata / dexe_ipfs_update_dao_metadata /
|
|
87
|
+
* dexe_dao_create take an avatarCID that was pinned elsewhere, so the local
|
|
88
|
+
* byte gate never saw it). Fetches the first KB of `<cid>/<fileName>` off the
|
|
89
|
+
* gateway chain and sniffs it.
|
|
90
|
+
*
|
|
91
|
+
* Verdicts:
|
|
92
|
+
* - `{ ok: true }` — bytes fetched, real raster.
|
|
93
|
+
* - `{ ok: false, error }` — bytes fetched, NOT a raster → hard-block.
|
|
94
|
+
* - `{ ok: true, warning }` — unreachable/timeout (fresh pins often
|
|
95
|
+
* haven't propagated to gateways yet) → proceed, surface the warning.
|
|
96
|
+
*/
|
|
97
|
+
export async function checkAvatarCidBytes(cid, fileName, gateways, perRequestTimeoutMs = 4000) {
|
|
98
|
+
const pinataGatewayToken = process.env.DEXE_PINATA_GATEWAY_TOKEN?.trim();
|
|
99
|
+
for (const gw of gateways.slice(0, 3)) {
|
|
100
|
+
const base = gw.replace(/\/+$/, "").replace(/\/ipfs$/, "");
|
|
101
|
+
const url = `${base}/ipfs/${cid}/${fileName}`;
|
|
102
|
+
const controller = new AbortController();
|
|
103
|
+
const t = setTimeout(() => controller.abort(), perRequestTimeoutMs);
|
|
104
|
+
try {
|
|
105
|
+
const headers = { Range: "bytes=0-1023" };
|
|
106
|
+
let host = null;
|
|
107
|
+
try {
|
|
108
|
+
host = new URL(base).hostname;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
host = null;
|
|
112
|
+
}
|
|
113
|
+
if (pinataGatewayToken && host && (host === "mypinata.cloud" || host.endsWith(".mypinata.cloud"))) {
|
|
114
|
+
headers["x-pinata-gateway-token"] = pinataGatewayToken;
|
|
115
|
+
}
|
|
116
|
+
const res = await fetch(url, { headers, signal: controller.signal });
|
|
117
|
+
if (!res.ok)
|
|
118
|
+
continue;
|
|
119
|
+
const head = new Uint8Array(await res.arrayBuffer());
|
|
120
|
+
try {
|
|
121
|
+
assertRasterAvatar(head);
|
|
122
|
+
return { ok: true };
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
error: `avatarCID ${cid}/${fileName} does not contain a usable avatar: ${err instanceof Error ? err.message : String(err)}`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// gateway unreachable/timeout — try the next one
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
clearTimeout(t);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
ok: true,
|
|
140
|
+
warning: `avatar bytes at ${cid}/${fileName} were not reachable on any configured gateway (fresh pins can take a while ` +
|
|
141
|
+
`to propagate) — byte validation skipped. If this CID did not come from dexe_ipfs_upload_avatar or ` +
|
|
142
|
+
`dexe_dao_generate_avatar, verify it is a real raster image.`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=imageSniff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSniff.js","sourceRoot":"","sources":["../../src/lib/imageSniff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,WAAW,GAAiC;IAChD,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;CACjB,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEjE,SAAS,UAAU,CAAC,KAAiB,EAAE,GAAa,EAAE,MAAM,GAAG,CAAC;IAC9D,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd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,EAAE;iBAC5H,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,iDAAiD;QACnD,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,OAAO,EACL,mBAAmB,GAAG,IAAI,QAAQ,6EAA6E;YAC/G,oGAAoG;YACpG,6DAA6D;KAChE,CAAC;AACJ,CAAC"}
|
package/dist/lib/preflight.d.ts
CHANGED
|
@@ -105,7 +105,15 @@ export declare const DEPOSITED_POWER_REMEDIATION: string;
|
|
|
105
105
|
* will under-count. Advisory (never blocks): the flow re-reads live power.
|
|
106
106
|
*/
|
|
107
107
|
export declare function checkTokensUnlocked(depositedPower: bigint, availablePower: bigint): PreflightResult;
|
|
108
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* cap rules (verified live on BSC mainnet via eth_call, 2026-07-06):
|
|
110
|
+
* - `cap = 0` reverts — the gov token is ERC20Capped: "ERC20Capped: cap is 0".
|
|
111
|
+
* There is NO uncapped mode (the old "cap=0 = uncapped" belief was wrong).
|
|
112
|
+
* - `cap < mintedTotal` reverts: "ERC20Gov: mintedTotal should not be greater than cap".
|
|
113
|
+
* - `cap == mintedTotal` is VALID (fixed supply) — the old bug #28 ("cap==minted
|
|
114
|
+
* reverts") is outdated; it succeeds live.
|
|
115
|
+
* So the rule is simply: `cap ≥ mintedTotal` and `cap > 0`.
|
|
116
|
+
*/
|
|
109
117
|
export declare function checkDeployCap(cap: string, mintedTotal: string, isTokenCreation: boolean): PreflightResult;
|
|
110
118
|
/** LINEAR vote power needs the `__LinearPower_init()` selector, never 0x. */
|
|
111
119
|
export declare const LINEAR_POWER_INIT_SELECTOR = "0x892aea1f";
|
|
@@ -113,10 +121,65 @@ export declare function checkLinearInitData(voteType: string, initData: string |
|
|
|
113
121
|
/** UserKeeper needs at least one non-zero governance asset (token or NFT). */
|
|
114
122
|
export declare function checkUserKeeperAsset(tokenAddress: string, nftAddress: string, isTokenCreation: boolean): PreflightResult;
|
|
115
123
|
/**
|
|
116
|
-
*
|
|
117
|
-
* mintedTotal
|
|
124
|
+
* Treasury is an IMPLICIT remainder. `sum(amounts)` may be LESS than
|
|
125
|
+
* `mintedTotal`: the contract mints the difference to the DAO (govPool) itself.
|
|
126
|
+
* This is the frontend's proven pattern (`useCreateDAO.ts` — `users`/`amounts`
|
|
127
|
+
* cover only the wallet distribution; the treasury is never an explicit
|
|
128
|
+
* recipient), shipped to BSC mainnet daily. The earlier "mainnet needs
|
|
129
|
+
* mintedTotal == sum(amounts)" belief (old bug #32) was wrong and forced the
|
|
130
|
+
* treasury address into `users[]`. Only OVER-distribution (sum > minted) is
|
|
131
|
+
* invalid. See also `checkNoTreasuryRecipient`.
|
|
132
|
+
*/
|
|
133
|
+
export declare function checkTreasuryRemainder(mintedTotal: string, amounts: string[], isTokenCreation: boolean): PreflightResult;
|
|
134
|
+
/**
|
|
135
|
+
* Meritocratic (polynomial) voting power for `votes` at a given `totalSupply`,
|
|
136
|
+
* ported from the frontend `calcMeritocraticVotingPower`
|
|
137
|
+
* (`utils/votePowerMath.ts`) with the default holder coefficient k3 = 0.97.
|
|
138
|
+
* Below the 7%-of-supply threshold, power is linear (== votes); above it the
|
|
139
|
+
* cubic curve applies. Token-amount math stays in bigint (wei); only the
|
|
140
|
+
* dimensionless percentage `t` uses float, at 6-decimal precision.
|
|
141
|
+
*/
|
|
142
|
+
export declare function meritocraticVotingPower(votes: bigint, totalSupply: bigint): bigint;
|
|
143
|
+
/**
|
|
144
|
+
* Quorum must be REACHABLE by the votable (wallet-held) token distribution —
|
|
145
|
+
* treasury/undistributed tokens can't vote. Mirrors the frontend's blocking
|
|
146
|
+
* `isLteThanInitialDistribution` (LINEAR) / `isDistributionCanReachQuorum`
|
|
147
|
+
* (POLYNOMIAL). Token-creation only (an external token's supply/distribution
|
|
148
|
+
* is unknown at deploy time, so the frontend skips it too).
|
|
149
|
+
*/
|
|
150
|
+
export declare function checkQuorumReachable(args: {
|
|
151
|
+
voteType: string;
|
|
152
|
+
quorumRaw: string;
|
|
153
|
+
mintedTotal: string;
|
|
154
|
+
votable: string;
|
|
155
|
+
isTokenCreation: boolean;
|
|
156
|
+
}): PreflightResult;
|
|
157
|
+
/**
|
|
158
|
+
* `minVotesForVoting` / `minVotesForCreating` must not exceed the largest single
|
|
159
|
+
* recipient's balance — otherwise no holder can ever create or vote. Mirrors the
|
|
160
|
+
* frontend `value-lower-than-distribution` rule. Token-creation only.
|
|
161
|
+
*/
|
|
162
|
+
export declare function checkMinVotesVsDistribution(minVotesForVoting: string, minVotesForCreating: string, amounts: string[], isTokenCreation: boolean): PreflightResult;
|
|
163
|
+
/**
|
|
164
|
+
* Contract-level init bounds (`GovSettings.sol:94-106`, `GovValidators.sol`):
|
|
165
|
+
* `0 < quorum ≤ 1e27`, `0 < quorumValidators ≤ 1e27`, `duration > 0`,
|
|
166
|
+
* `durationValidators > 0`. Violations revert `deployGovPool` with an empty
|
|
167
|
+
* reason — catch them here with a readable message.
|
|
168
|
+
*/
|
|
169
|
+
export declare function checkSettingsBounds(s: {
|
|
170
|
+
quorum: string;
|
|
171
|
+
quorumValidators: string;
|
|
172
|
+
duration: string;
|
|
173
|
+
durationValidators: string;
|
|
174
|
+
}): PreflightResult;
|
|
175
|
+
/**
|
|
176
|
+
* The DAO treasury (predicted govPool) must NEVER be a token recipient in
|
|
177
|
+
* `tokenParams.users` — treasury tokens can't vote, and the frontend never
|
|
178
|
+
* lists it (the remainder is minted to the DAO implicitly). Listing it inflates
|
|
179
|
+
* `sum(amounts)`, hides an unreachable quorum, and diverges from the frontend
|
|
180
|
+
* calldata shape.
|
|
118
181
|
*/
|
|
119
|
-
export declare function
|
|
182
|
+
export declare function checkNoTreasuryRecipient(users: string[], predictedGovPool?: string): PreflightResult;
|
|
120
183
|
/** Avatar must be a real JPEG, not SVG bytes with a .jpeg name (browser rejects). */
|
|
121
184
|
export declare function checkAvatarIsJpeg(fileName: string, firstBytes?: Uint8Array): PreflightResult;
|
|
122
185
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/lib/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/lib/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,OAAO,CAAC;IACZ,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAUD,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,eAAe,GAAG,IAAI,CAE/E;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAGhE;AAMD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,6KAWvB,CAAC;AAEX,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,aAAqB,CAAC;AAMpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAa5B,CAAC;AAEjB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAA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E,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;CAC1B,GAAG,eAAe,CAqBlB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,MAAM,EACzB,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,MAAM,EAAE,EACjB,eAAe,EAAE,OAAO,GACvB,eAAe,CAYjB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GAAG,eAAe,CAYlB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,eAAe,CAapG;AAMD,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,eAAe,CAqB5F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,eAAe,CAazG;AAED,uEAAuE;AACvE,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,CAM1B"}
|
package/dist/lib/preflight.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { z } from "zod";
|
|
19
19
|
import { isAddress, ZeroAddress } from "ethers";
|
|
20
20
|
import { checkBlacklist, blacklistError } from "./blacklist.js";
|
|
21
|
+
import { quorumPctFromRaw } from "./quorumRisk.js";
|
|
21
22
|
const pass = (check, detail) => ({ check, ok: true, detail });
|
|
22
23
|
const fail = (check, remediation, detail) => ({
|
|
23
24
|
check,
|
|
@@ -128,16 +129,29 @@ export function checkTokensUnlocked(depositedPower, availablePower) {
|
|
|
128
129
|
// ==========================================================================
|
|
129
130
|
// Mode 7 — DAO deploy silent reverts
|
|
130
131
|
// ==========================================================================
|
|
131
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* cap rules (verified live on BSC mainnet via eth_call, 2026-07-06):
|
|
134
|
+
* - `cap = 0` reverts — the gov token is ERC20Capped: "ERC20Capped: cap is 0".
|
|
135
|
+
* There is NO uncapped mode (the old "cap=0 = uncapped" belief was wrong).
|
|
136
|
+
* - `cap < mintedTotal` reverts: "ERC20Gov: mintedTotal should not be greater than cap".
|
|
137
|
+
* - `cap == mintedTotal` is VALID (fixed supply) — the old bug #28 ("cap==minted
|
|
138
|
+
* reverts") is outdated; it succeeds live.
|
|
139
|
+
* So the rule is simply: `cap ≥ mintedTotal` and `cap > 0`.
|
|
140
|
+
*/
|
|
132
141
|
export function checkDeployCap(cap, mintedTotal, isTokenCreation) {
|
|
133
142
|
if (!isTokenCreation)
|
|
134
143
|
return pass("deploy.cap");
|
|
135
144
|
const capBn = BigInt(cap);
|
|
136
145
|
const mintedBn = BigInt(mintedTotal);
|
|
137
|
-
if (capBn
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
if (capBn <= 0n) {
|
|
147
|
+
return fail("deploy.cap", `tokenParams.cap must be > 0 — the gov token is ERC20Capped and cap=0 reverts ("ERC20Capped: cap is 0"). ` +
|
|
148
|
+
`There is no uncapped mode. Set cap ≥ mintedTotal (${mintedBn}); cap == mintedTotal is a valid fixed supply.`);
|
|
149
|
+
}
|
|
150
|
+
if (capBn < mintedBn) {
|
|
151
|
+
return fail("deploy.cap", `tokenParams.cap (${capBn}) must be ≥ mintedTotal (${mintedBn}) — otherwise deployGovPool reverts ` +
|
|
152
|
+
`"ERC20Gov: mintedTotal should not be greater than cap". cap == mintedTotal is allowed (fixed supply).`);
|
|
153
|
+
}
|
|
154
|
+
return pass("deploy.cap", `cap=${capBn} minted=${mintedBn}`);
|
|
141
155
|
}
|
|
142
156
|
/** LINEAR vote power needs the `__LinearPower_init()` selector, never 0x. */
|
|
143
157
|
export const LINEAR_POWER_INIT_SELECTOR = "0x892aea1f";
|
|
@@ -167,21 +181,148 @@ export function checkUserKeeperAsset(tokenAddress, nftAddress, isTokenCreation)
|
|
|
167
181
|
"userKeeperParams.nftAddress (existing ERC721), or tokenParams.name to create a new token.");
|
|
168
182
|
}
|
|
169
183
|
/**
|
|
170
|
-
*
|
|
171
|
-
* mintedTotal
|
|
184
|
+
* Treasury is an IMPLICIT remainder. `sum(amounts)` may be LESS than
|
|
185
|
+
* `mintedTotal`: the contract mints the difference to the DAO (govPool) itself.
|
|
186
|
+
* This is the frontend's proven pattern (`useCreateDAO.ts` — `users`/`amounts`
|
|
187
|
+
* cover only the wallet distribution; the treasury is never an explicit
|
|
188
|
+
* recipient), shipped to BSC mainnet daily. The earlier "mainnet needs
|
|
189
|
+
* mintedTotal == sum(amounts)" belief (old bug #32) was wrong and forced the
|
|
190
|
+
* treasury address into `users[]`. Only OVER-distribution (sum > minted) is
|
|
191
|
+
* invalid. See also `checkNoTreasuryRecipient`.
|
|
172
192
|
*/
|
|
173
|
-
export function checkTreasuryRemainder(mintedTotal, amounts,
|
|
193
|
+
export function checkTreasuryRemainder(mintedTotal, amounts, isTokenCreation) {
|
|
174
194
|
if (!isTokenCreation)
|
|
175
195
|
return pass("deploy.treasury-remainder");
|
|
176
196
|
const minted = BigInt(mintedTotal);
|
|
177
197
|
const sum = amounts.reduce((a, b) => a + BigInt(b), 0n);
|
|
178
|
-
if (
|
|
179
|
-
return
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
198
|
+
if (sum > minted) {
|
|
199
|
+
return fail("deploy.treasury-remainder", `sum(amounts) (${sum}) exceeds tokenParams.mintedTotal (${minted}) — cannot distribute more than the total ` +
|
|
200
|
+
"mint. Lower the recipient amounts or raise mintedTotal.", `over=${sum - minted}`);
|
|
201
|
+
}
|
|
202
|
+
return pass("deploy.treasury-remainder", `treasuryRemainder=${minted - sum}`);
|
|
203
|
+
}
|
|
204
|
+
// ==========================================================================
|
|
205
|
+
// DAO governance coherence — frontend parity (never ship a broken/unusable DAO)
|
|
206
|
+
// ==========================================================================
|
|
207
|
+
//
|
|
208
|
+
// The frontend (C:/dev/investing-dashboard, source of truth) BLOCKS DAO configs
|
|
209
|
+
// where governance can never function. dexe-mcp had none of these, so the model
|
|
210
|
+
// could (and did) ship a DAO whose quorum was unreachable or whose treasury was
|
|
211
|
+
// jammed into the voter list. These guards mirror the frontend's create-DAO
|
|
212
|
+
// validation (`DefaultProposalStep`, `TokenCreationStep`, `GovSettings.sol`).
|
|
213
|
+
/** DeXe percentage base: 100% = 1e27 (a quorum setting is pct × 1e25). */
|
|
214
|
+
const PERCENTAGE_100 = 10n ** 27n;
|
|
215
|
+
/**
|
|
216
|
+
* Meritocratic (polynomial) voting power for `votes` at a given `totalSupply`,
|
|
217
|
+
* ported from the frontend `calcMeritocraticVotingPower`
|
|
218
|
+
* (`utils/votePowerMath.ts`) with the default holder coefficient k3 = 0.97.
|
|
219
|
+
* Below the 7%-of-supply threshold, power is linear (== votes); above it the
|
|
220
|
+
* cubic curve applies. Token-amount math stays in bigint (wei); only the
|
|
221
|
+
* dimensionless percentage `t` uses float, at 6-decimal precision.
|
|
222
|
+
*/
|
|
223
|
+
export function meritocraticVotingPower(votes, totalSupply) {
|
|
224
|
+
if (totalSupply <= 0n)
|
|
225
|
+
return votes;
|
|
226
|
+
const threshold = (totalSupply * 7n) / 100n - 7n;
|
|
227
|
+
if (votes < threshold)
|
|
228
|
+
return votes;
|
|
229
|
+
// t = (votes/totalSupply)×100 − 7, in percentage points, 6-dec precision.
|
|
230
|
+
const t = Number((votes * 1000000n) / totalSupply) / 1_000_000 * 100 - 7;
|
|
231
|
+
let poly = t * 1.041 + t * t * -0.007211 + t * t * t * 0.00001994;
|
|
232
|
+
poly = poly * 0.97; // k3 (holders)
|
|
233
|
+
// power above threshold = poly% of totalSupply (poly scaled ×1e6 to stay integer).
|
|
234
|
+
const aboveWei = (BigInt(Math.round(poly * 1_000_000)) * totalSupply) / (100n * 1000000n);
|
|
235
|
+
const above = aboveWei > 0n ? aboveWei : 0n;
|
|
236
|
+
return above + threshold;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Quorum must be REACHABLE by the votable (wallet-held) token distribution —
|
|
240
|
+
* treasury/undistributed tokens can't vote. Mirrors the frontend's blocking
|
|
241
|
+
* `isLteThanInitialDistribution` (LINEAR) / `isDistributionCanReachQuorum`
|
|
242
|
+
* (POLYNOMIAL). Token-creation only (an external token's supply/distribution
|
|
243
|
+
* is unknown at deploy time, so the frontend skips it too).
|
|
244
|
+
*/
|
|
245
|
+
export function checkQuorumReachable(args) {
|
|
246
|
+
if (!args.isTokenCreation)
|
|
247
|
+
return pass("deploy.quorum-reachable", "external token");
|
|
248
|
+
const quorum = BigInt(args.quorumRaw);
|
|
249
|
+
const supply = BigInt(args.mintedTotal);
|
|
250
|
+
const votable = BigInt(args.votable);
|
|
251
|
+
if (supply <= 0n)
|
|
252
|
+
return pass("deploy.quorum-reachable", "no supply");
|
|
253
|
+
const quorumInTokens = (quorum * supply) / PERCENTAGE_100;
|
|
254
|
+
const power = args.voteType === "POLYNOMIAL_VOTES" ? meritocraticVotingPower(votable, supply) : votable;
|
|
255
|
+
if (power >= quorumInTokens) {
|
|
256
|
+
return pass("deploy.quorum-reachable", `quorumTokens=${quorumInTokens} ≤ votablePower=${power}`);
|
|
257
|
+
}
|
|
258
|
+
const quorumPct = quorumPctFromRaw(args.quorumRaw);
|
|
259
|
+
const reachablePct = Number((power * 10000n) / supply) / 100;
|
|
260
|
+
return fail("deploy.quorum-reachable", `Quorum ${quorumPct}% is UNREACHABLE: it requires ${quorumInTokens} vote-power but the votable token ` +
|
|
261
|
+
`distribution only provides ${power} (~${reachablePct}% of supply). Treasury/undistributed tokens cannot ` +
|
|
262
|
+
`vote. Fix: lower quorum to ≤ ${reachablePct}%, distribute more tokens to voters, or shrink the treasury ` +
|
|
263
|
+
`share. The frontend blocks this exact config (DefaultProposalStep isLteThanInitialDistribution).`, `voteType=${args.voteType}`);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* `minVotesForVoting` / `minVotesForCreating` must not exceed the largest single
|
|
267
|
+
* recipient's balance — otherwise no holder can ever create or vote. Mirrors the
|
|
268
|
+
* frontend `value-lower-than-distribution` rule. Token-creation only.
|
|
269
|
+
*/
|
|
270
|
+
export function checkMinVotesVsDistribution(minVotesForVoting, minVotesForCreating, amounts, isTokenCreation) {
|
|
271
|
+
if (!isTokenCreation || amounts.length === 0)
|
|
272
|
+
return pass("deploy.min-votes");
|
|
273
|
+
const largest = amounts.reduce((m, a) => (BigInt(a) > m ? BigInt(a) : m), 0n);
|
|
274
|
+
const bad = [];
|
|
275
|
+
if (BigInt(minVotesForVoting) > largest)
|
|
276
|
+
bad.push(`minVotesForVoting (${minVotesForVoting})`);
|
|
277
|
+
if (BigInt(minVotesForCreating) > largest)
|
|
278
|
+
bad.push(`minVotesForCreating (${minVotesForCreating})`);
|
|
279
|
+
if (bad.length === 0)
|
|
280
|
+
return pass("deploy.min-votes", `largestRecipient=${largest}`);
|
|
281
|
+
return fail("deploy.min-votes", `${bad.join(" and ")} exceed the largest single recipient's balance (${largest}). No holder could then create ` +
|
|
282
|
+
"or vote on a proposal. Set these ≤ the biggest voter's token balance (frontend: value-lower-than-distribution).");
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Contract-level init bounds (`GovSettings.sol:94-106`, `GovValidators.sol`):
|
|
286
|
+
* `0 < quorum ≤ 1e27`, `0 < quorumValidators ≤ 1e27`, `duration > 0`,
|
|
287
|
+
* `durationValidators > 0`. Violations revert `deployGovPool` with an empty
|
|
288
|
+
* reason — catch them here with a readable message.
|
|
289
|
+
*/
|
|
290
|
+
export function checkSettingsBounds(s) {
|
|
291
|
+
const q = BigInt(s.quorum);
|
|
292
|
+
const qv = BigInt(s.quorumValidators);
|
|
293
|
+
const d = BigInt(s.duration);
|
|
294
|
+
const dv = BigInt(s.durationValidators);
|
|
295
|
+
const bad = [];
|
|
296
|
+
if (q <= 0n || q > PERCENTAGE_100)
|
|
297
|
+
bad.push(`quorum must be 0 < q ≤ 1e27 (got ${q})`);
|
|
298
|
+
if (qv <= 0n || qv > PERCENTAGE_100)
|
|
299
|
+
bad.push(`quorumValidators must be 0 < q ≤ 1e27 (got ${qv})`);
|
|
300
|
+
if (d <= 0n)
|
|
301
|
+
bad.push(`duration must be > 0 (got ${d})`);
|
|
302
|
+
if (dv <= 0n)
|
|
303
|
+
bad.push(`durationValidators must be > 0 (got ${dv})`);
|
|
304
|
+
if (bad.length === 0)
|
|
305
|
+
return pass("deploy.settings-bounds");
|
|
306
|
+
return fail("deploy.settings-bounds", `GovSettings/GovValidators init would revert: ${bad.join("; ")}.`);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The DAO treasury (predicted govPool) must NEVER be a token recipient in
|
|
310
|
+
* `tokenParams.users` — treasury tokens can't vote, and the frontend never
|
|
311
|
+
* lists it (the remainder is minted to the DAO implicitly). Listing it inflates
|
|
312
|
+
* `sum(amounts)`, hides an unreachable quorum, and diverges from the frontend
|
|
313
|
+
* calldata shape.
|
|
314
|
+
*/
|
|
315
|
+
export function checkNoTreasuryRecipient(users, predictedGovPool) {
|
|
316
|
+
if (!predictedGovPool)
|
|
317
|
+
return pass("deploy.no-treasury-recipient");
|
|
318
|
+
const gp = predictedGovPool.toLowerCase();
|
|
319
|
+
if (users.some((u) => u.toLowerCase() === gp)) {
|
|
320
|
+
return fail("deploy.no-treasury-recipient", `Do not list the DAO treasury (predicted govPool ${predictedGovPool}) in tokenParams.users. Treasury tokens ` +
|
|
321
|
+
"cannot vote. Leave the treasury as an IMPLICIT remainder: set mintedTotal = full supply and users/amounts = " +
|
|
322
|
+
"external holders only (sum(amounts) < mintedTotal); the contract mints the remainder to the DAO. " +
|
|
323
|
+
"(matches frontend useCreateDAO — govPool is never in users[])");
|
|
183
324
|
}
|
|
184
|
-
return
|
|
325
|
+
return pass("deploy.no-treasury-recipient");
|
|
185
326
|
}
|
|
186
327
|
// ==========================================================================
|
|
187
328
|
// Mode 10 — edge cases (avatar, offchain, blacklist)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/lib/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAYhE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAe,EAAmB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAChG,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,WAAmB,EAAE,MAAe,EAAmB,EAAE,CAAC,CAAC;IACtF,KAAK;IACL,EAAE,EAAE,KAAK;IACT,WAAW;IACX,MAAM;CACP,CAAC,CAAC;AAEH,6DAA6D;AAC7D,MAAM,UAAU,YAAY,CAAC,OAA0B;IACrD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;AAC5C,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,OAA0B;IACxD,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,GAAG;QAAE,MAAM,IAAI,KAAK,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tG,IAAI,EAAE,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;IAChH,OAAO,IAAI,CAAC,qBAAqB,EAAE,2BAA2B,CAAC,CAAC;AAClE,CAAC"}
|
package/dist/lib/qr.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR rendering for WalletConnect pairing URIs.
|
|
3
|
+
*
|
|
4
|
+
* `qrcode` is **lazily imported** (mirrors the WalletConnect provider in
|
|
5
|
+
* `walletconnect.ts`) so read-only / EOA installs that never pair pay no cost,
|
|
6
|
+
* and a missing/broken install degrades gracefully to `null` — callers then
|
|
7
|
+
* fall back to the raw `uri` string plus the external QR-image URL.
|
|
8
|
+
*/
|
|
9
|
+
export interface RenderedQr {
|
|
10
|
+
/** Scannable ASCII/half-block QR for a monospace terminal, or null. */
|
|
11
|
+
ascii: string | null;
|
|
12
|
+
/** Base64 PNG (no data-URL prefix) for an MCP `image` content block, or null. */
|
|
13
|
+
pngBase64: string | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Render `text` (a WalletConnect `wc:` URI) as both a terminal ASCII QR and a
|
|
17
|
+
* base64 PNG. Never throws — any failure yields `{ ascii: null, pngBase64: null }`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderQr(text: string): Promise<RenderedQr>;
|
|
20
|
+
/** External fallback image URL for clients that can render neither ASCII nor an image block. */
|
|
21
|
+
export declare function qrFallbackUrl(uri: string): string;
|
|
22
|
+
/** One MCP `content[]` item — text or image. Kept loose to match the tool call sites. */
|
|
23
|
+
type PairingContent = {
|
|
24
|
+
type: "text";
|
|
25
|
+
text: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: "image";
|
|
28
|
+
data: string;
|
|
29
|
+
mimeType: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Build the MCP `content[]` for a WalletConnect pairing response, shared by
|
|
33
|
+
* `dexe_wc_connect` and `dexe_tx_send`'s auto-pairing branch so the QR + the
|
|
34
|
+
* fallbacks stay identical everywhere.
|
|
35
|
+
*
|
|
36
|
+
* 1. An ASCII QR text block (captioned) — scannable in a bare terminal.
|
|
37
|
+
* 2. An `image/png` block — a crisp QR in GUI MCP clients.
|
|
38
|
+
* 3. A JSON block with `uri`, `chainId`, the external fallback URL, and a
|
|
39
|
+
* `renderHint` telling the assistant to echo the ASCII block verbatim.
|
|
40
|
+
*/
|
|
41
|
+
export declare function wcPairingContent(uri: string, chainId: number, extra?: Record<string, unknown>): Promise<PairingContent[]>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=qr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr.d.ts","sourceRoot":"","sources":["../../src/lib/qr.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,MAAM,WAAW,UAAU;IACzB,uEAAuE;IACvE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,iFAAiF;IACjF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAqBD;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAmBhE;AAED,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,yFAAyF;AACzF,KAAK,cAAc,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,cAAc,EAAE,CAAC,CAkC3B"}
|