@elizaos/plugin-elizamaker 2.0.3-beta.6 → 2.0.3-beta.7
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/dist/drop-routes.d.ts +22 -0
- package/dist/drop-routes.d.ts.map +1 -0
- package/dist/drop-routes.js +162 -0
- package/dist/drop-routes.js.map +1 -0
- package/dist/drop-service-registry.d.ts +4 -0
- package/dist/drop-service-registry.d.ts.map +1 -0
- package/dist/drop-service-registry.js +12 -0
- package/dist/drop-service-registry.js.map +1 -0
- package/dist/drop-service.d.ts +46 -0
- package/dist/drop-service.d.ts.map +1 -0
- package/dist/drop-service.js +136 -0
- package/dist/drop-service.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/init-registry-services.d.ts +18 -0
- package/dist/init-registry-services.d.ts.map +1 -0
- package/dist/init-registry-services.js +64 -0
- package/dist/init-registry-services.js.map +1 -0
- package/dist/merkle-tree.d.ts +90 -0
- package/dist/merkle-tree.d.ts.map +1 -0
- package/dist/merkle-tree.js +118 -0
- package/dist/merkle-tree.js.map +1 -0
- package/dist/nft-verify.d.ts +16 -0
- package/dist/nft-verify.d.ts.map +1 -0
- package/dist/nft-verify.js +94 -0
- package/dist/nft-verify.js.map +1 -0
- package/dist/og-tracker.d.ts +29 -0
- package/dist/og-tracker.d.ts.map +1 -0
- package/dist/og-tracker.js +41 -0
- package/dist/og-tracker.js.map +1 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +105 -0
- package/dist/plugin.js.map +1 -0
- package/dist/registry-service-registry.d.ts +4 -0
- package/dist/registry-service-registry.d.ts.map +1 -0
- package/dist/registry-service-registry.js +12 -0
- package/dist/registry-service-registry.js.map +1 -0
- package/dist/twitter-verify.d.ts +29 -0
- package/dist/twitter-verify.d.ts.map +1 -0
- package/dist/twitter-verify.js +164 -0
- package/dist/twitter-verify.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type http from "node:http";
|
|
2
|
+
import type { ReadJsonBodyOptions } from "@elizaos/core";
|
|
3
|
+
import type { DropService } from "./drop-service.js";
|
|
4
|
+
export interface DropRouteContext {
|
|
5
|
+
req: http.IncomingMessage;
|
|
6
|
+
res: http.ServerResponse;
|
|
7
|
+
method: string;
|
|
8
|
+
pathname: string;
|
|
9
|
+
url: URL;
|
|
10
|
+
json: (res: http.ServerResponse, data: unknown, status?: number) => void;
|
|
11
|
+
error: (res: http.ServerResponse, message: string, status?: number) => void;
|
|
12
|
+
readJsonBody: <T extends object>(req: http.IncomingMessage, res: http.ServerResponse, options?: ReadJsonBodyOptions) => Promise<T | null>;
|
|
13
|
+
dropService: DropService | null;
|
|
14
|
+
agentName: string;
|
|
15
|
+
getWalletAddresses: () => {
|
|
16
|
+
evmAddress?: string;
|
|
17
|
+
solanaAddress?: string;
|
|
18
|
+
};
|
|
19
|
+
readOGCodeFromState: () => string | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function handleDropRoutes(ctx: DropRouteContext): Promise<boolean>;
|
|
22
|
+
//# sourceMappingURL=drop-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-routes.d.ts","sourceRoot":"","sources":["../src/drop-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAarD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC;IAC1B,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,YAAY,EAAE,CAAC,CAAC,SAAS,MAAM,EAC7B,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,OAAO,CAAC,EAAE,mBAAmB,KAC1B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1E,mBAAmB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;CAC1C;AAMD,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,OAAO,CAAC,CA4LlB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { buildWhitelistTree, generateProof } from "./merkle-tree.js";
|
|
2
|
+
import {
|
|
3
|
+
generateVerificationMessage,
|
|
4
|
+
isAddressWhitelisted,
|
|
5
|
+
markAddressVerified,
|
|
6
|
+
verifyTweet
|
|
7
|
+
} from "./twitter-verify.js";
|
|
8
|
+
async function handleDropRoutes(ctx) {
|
|
9
|
+
const {
|
|
10
|
+
req,
|
|
11
|
+
res,
|
|
12
|
+
method,
|
|
13
|
+
pathname,
|
|
14
|
+
json,
|
|
15
|
+
error,
|
|
16
|
+
readJsonBody,
|
|
17
|
+
dropService,
|
|
18
|
+
agentName,
|
|
19
|
+
getWalletAddresses,
|
|
20
|
+
readOGCodeFromState
|
|
21
|
+
} = ctx;
|
|
22
|
+
if (method === "GET" && pathname === "/api/drop/status") {
|
|
23
|
+
if (!dropService) {
|
|
24
|
+
json(res, {
|
|
25
|
+
dropEnabled: false,
|
|
26
|
+
publicMintOpen: false,
|
|
27
|
+
whitelistMintOpen: false,
|
|
28
|
+
mintedOut: false,
|
|
29
|
+
currentSupply: 0,
|
|
30
|
+
maxSupply: 2138,
|
|
31
|
+
shinyPrice: "0.1",
|
|
32
|
+
userHasMinted: false
|
|
33
|
+
});
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
const status = await dropService.getStatus();
|
|
37
|
+
json(res, status);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (method === "POST" && pathname === "/api/drop/mint") {
|
|
41
|
+
if (!dropService) {
|
|
42
|
+
error(res, "Drop service not configured.", 503);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const body = await readJsonBody(req, res);
|
|
46
|
+
if (!body) return true;
|
|
47
|
+
const name = body.name || agentName || "Eliza";
|
|
48
|
+
const endpoint = body.endpoint || "";
|
|
49
|
+
const result = body.shiny ? await dropService.mintShiny(name, endpoint) : await dropService.mint(name, endpoint);
|
|
50
|
+
json(res, result);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (method === "POST" && pathname === "/api/drop/mint-whitelist") {
|
|
54
|
+
if (!dropService) {
|
|
55
|
+
error(res, "Drop service not configured.", 503);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const body = await readJsonBody(req, res);
|
|
59
|
+
if (!body) return true;
|
|
60
|
+
let proof = body.proof;
|
|
61
|
+
if (!proof || proof.length === 0) {
|
|
62
|
+
const addrs = getWalletAddresses();
|
|
63
|
+
const walletAddress = addrs.evmAddress ?? "";
|
|
64
|
+
if (!walletAddress) {
|
|
65
|
+
error(res, "EVM wallet not configured.");
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const proofResult = generateProof(walletAddress);
|
|
69
|
+
if (!proofResult.isWhitelisted) {
|
|
70
|
+
error(
|
|
71
|
+
res,
|
|
72
|
+
"Address not whitelisted. Complete Twitter or NFT verification first."
|
|
73
|
+
);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
proof = proofResult.proof;
|
|
77
|
+
}
|
|
78
|
+
const name = body.name || agentName || "Eliza";
|
|
79
|
+
const endpoint = body.endpoint || "";
|
|
80
|
+
const result = await dropService.mintWithWhitelist(name, endpoint, proof);
|
|
81
|
+
json(res, result);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
if (method === "GET" && pathname === "/api/whitelist/status") {
|
|
85
|
+
const addrs = getWalletAddresses();
|
|
86
|
+
const walletAddress = addrs.evmAddress ?? "";
|
|
87
|
+
const twitterVerified = walletAddress ? isAddressWhitelisted(walletAddress) : false;
|
|
88
|
+
const ogCode = readOGCodeFromState();
|
|
89
|
+
const { info } = buildWhitelistTree();
|
|
90
|
+
const proofReady = walletAddress ? generateProof(walletAddress).isWhitelisted : false;
|
|
91
|
+
json(res, {
|
|
92
|
+
eligible: twitterVerified,
|
|
93
|
+
twitterVerified,
|
|
94
|
+
nftVerified: twitterVerified,
|
|
95
|
+
whitelisted: walletAddress ? isAddressWhitelisted(walletAddress) : false,
|
|
96
|
+
ogCode: ogCode ?? null,
|
|
97
|
+
walletAddress,
|
|
98
|
+
merkle: {
|
|
99
|
+
root: info.root,
|
|
100
|
+
addressCount: info.addressCount,
|
|
101
|
+
proofReady
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (method === "POST" && pathname === "/api/whitelist/twitter/message") {
|
|
107
|
+
const addrs = getWalletAddresses();
|
|
108
|
+
const walletAddress = addrs.evmAddress ?? "";
|
|
109
|
+
if (!walletAddress) {
|
|
110
|
+
error(res, "EVM wallet not configured. Complete onboarding first.");
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
const name = agentName || "Eliza";
|
|
114
|
+
const message = generateVerificationMessage(name, walletAddress);
|
|
115
|
+
json(res, { message, walletAddress });
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (method === "POST" && pathname === "/api/whitelist/twitter/verify") {
|
|
119
|
+
const body = await readJsonBody(req, res);
|
|
120
|
+
if (!body?.tweetUrl) {
|
|
121
|
+
error(res, "tweetUrl is required");
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
const addrs = getWalletAddresses();
|
|
125
|
+
const walletAddress = addrs.evmAddress ?? "";
|
|
126
|
+
if (!walletAddress) {
|
|
127
|
+
error(res, "EVM wallet not configured.");
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
const result = await verifyTweet(body.tweetUrl, walletAddress);
|
|
131
|
+
if (result.verified && result.handle) {
|
|
132
|
+
markAddressVerified(walletAddress, body.tweetUrl, result.handle);
|
|
133
|
+
}
|
|
134
|
+
json(res, result);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
if (method === "GET" && pathname === "/api/whitelist/merkle/root") {
|
|
138
|
+
const { info } = buildWhitelistTree();
|
|
139
|
+
json(res, {
|
|
140
|
+
root: info.root,
|
|
141
|
+
addressCount: info.addressCount,
|
|
142
|
+
proofReady: true
|
|
143
|
+
});
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
if (method === "GET" && pathname === "/api/whitelist/merkle/proof") {
|
|
147
|
+
const reqUrl = new URL(req.url ?? "", `http://${req.headers.host}`);
|
|
148
|
+
const addr = reqUrl.searchParams.get("address");
|
|
149
|
+
if (!addr) {
|
|
150
|
+
error(res, "address query parameter is required", 400);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
const result = generateProof(addr);
|
|
154
|
+
json(res, result);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
handleDropRoutes
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=drop-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/drop-routes.ts"],"sourcesContent":["import type http from \"node:http\";\nimport type { ReadJsonBodyOptions } from \"@elizaos/core\";\nimport type { DropService } from \"./drop-service.js\";\nimport { buildWhitelistTree, generateProof } from \"./merkle-tree.js\";\nimport {\n generateVerificationMessage,\n isAddressWhitelisted,\n markAddressVerified,\n verifyTweet,\n} from \"./twitter-verify.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface DropRouteContext {\n req: http.IncomingMessage;\n res: http.ServerResponse;\n method: string;\n pathname: string;\n url: URL;\n json: (res: http.ServerResponse, data: unknown, status?: number) => void;\n error: (res: http.ServerResponse, message: string, status?: number) => void;\n readJsonBody: <T extends object>(\n req: http.IncomingMessage,\n res: http.ServerResponse,\n options?: ReadJsonBodyOptions,\n ) => Promise<T | null>;\n dropService: DropService | null;\n agentName: string;\n getWalletAddresses: () => { evmAddress?: string; solanaAddress?: string };\n readOGCodeFromState: () => string | null;\n}\n\n// ---------------------------------------------------------------------------\n// Route handler\n// ---------------------------------------------------------------------------\n\nexport async function handleDropRoutes(\n ctx: DropRouteContext,\n): Promise<boolean> {\n const {\n req,\n res,\n method,\n pathname,\n json,\n error,\n readJsonBody,\n dropService,\n agentName,\n getWalletAddresses,\n readOGCodeFromState,\n } = ctx;\n\n // ═══════════════════════════════════════════════════════════════════════\n // Drop / Mint Routes\n // ═══════════════════════════════════════════════════════════════════════\n\n if (method === \"GET\" && pathname === \"/api/drop/status\") {\n if (!dropService) {\n json(res, {\n dropEnabled: false,\n publicMintOpen: false,\n whitelistMintOpen: false,\n mintedOut: false,\n currentSupply: 0,\n maxSupply: 2138,\n shinyPrice: \"0.1\",\n userHasMinted: false,\n });\n return true;\n }\n const status = await dropService.getStatus();\n json(res, status);\n return true;\n }\n\n if (method === \"POST\" && pathname === \"/api/drop/mint\") {\n if (!dropService) {\n error(res, \"Drop service not configured.\", 503);\n return true;\n }\n const body = await readJsonBody<{\n name?: string;\n endpoint?: string;\n shiny?: boolean;\n }>(req, res);\n if (!body) return true;\n\n const name = body.name || agentName || \"Eliza\";\n const endpoint = body.endpoint || \"\";\n\n const result = body.shiny\n ? await dropService.mintShiny(name, endpoint)\n : await dropService.mint(name, endpoint);\n json(res, result);\n return true;\n }\n\n if (method === \"POST\" && pathname === \"/api/drop/mint-whitelist\") {\n if (!dropService) {\n error(res, \"Drop service not configured.\", 503);\n return true;\n }\n const body = await readJsonBody<{\n name?: string;\n endpoint?: string;\n proof?: string[];\n }>(req, res);\n if (!body) return true;\n let proof = body.proof;\n if (!proof || proof.length === 0) {\n const addrs = getWalletAddresses();\n const walletAddress = addrs.evmAddress ?? \"\";\n if (!walletAddress) {\n error(res, \"EVM wallet not configured.\");\n return true;\n }\n const proofResult = generateProof(walletAddress);\n if (!proofResult.isWhitelisted) {\n error(\n res,\n \"Address not whitelisted. Complete Twitter or NFT verification first.\",\n );\n return true;\n }\n proof = proofResult.proof;\n }\n\n const name = body.name || agentName || \"Eliza\";\n const endpoint = body.endpoint || \"\";\n const result = await dropService.mintWithWhitelist(name, endpoint, proof);\n json(res, result);\n return true;\n }\n\n // ═══════════════════════════════════════════════════════════════════════\n // Whitelist Routes\n // ═══════════════════════════════════════════════════════════════════════\n\n if (method === \"GET\" && pathname === \"/api/whitelist/status\") {\n const addrs = getWalletAddresses();\n const walletAddress = addrs.evmAddress ?? \"\";\n const twitterVerified = walletAddress\n ? isAddressWhitelisted(walletAddress)\n : false;\n const ogCode = readOGCodeFromState();\n\n const { info } = buildWhitelistTree();\n const proofReady = walletAddress\n ? generateProof(walletAddress).isWhitelisted\n : false;\n\n json(res, {\n eligible: twitterVerified,\n twitterVerified,\n nftVerified: twitterVerified,\n whitelisted: walletAddress ? isAddressWhitelisted(walletAddress) : false,\n ogCode: ogCode ?? null,\n walletAddress,\n merkle: {\n root: info.root,\n addressCount: info.addressCount,\n proofReady,\n },\n });\n return true;\n }\n\n if (method === \"POST\" && pathname === \"/api/whitelist/twitter/message\") {\n const addrs = getWalletAddresses();\n const walletAddress = addrs.evmAddress ?? \"\";\n if (!walletAddress) {\n error(res, \"EVM wallet not configured. Complete onboarding first.\");\n return true;\n }\n const name = agentName || \"Eliza\";\n const message = generateVerificationMessage(name, walletAddress);\n json(res, { message, walletAddress });\n return true;\n }\n\n if (method === \"POST\" && pathname === \"/api/whitelist/twitter/verify\") {\n const body = await readJsonBody<{ tweetUrl?: string }>(req, res);\n if (!body?.tweetUrl) {\n error(res, \"tweetUrl is required\");\n return true;\n }\n\n const addrs = getWalletAddresses();\n const walletAddress = addrs.evmAddress ?? \"\";\n if (!walletAddress) {\n error(res, \"EVM wallet not configured.\");\n return true;\n }\n\n const result = await verifyTweet(body.tweetUrl, walletAddress);\n if (result.verified && result.handle) {\n markAddressVerified(walletAddress, body.tweetUrl, result.handle);\n }\n json(res, result);\n return true;\n }\n\n if (method === \"GET\" && pathname === \"/api/whitelist/merkle/root\") {\n const { info } = buildWhitelistTree();\n json(res, {\n root: info.root,\n addressCount: info.addressCount,\n proofReady: true,\n });\n return true;\n }\n\n if (method === \"GET\" && pathname === \"/api/whitelist/merkle/proof\") {\n const reqUrl = new URL(req.url ?? \"\", `http://${req.headers.host}`);\n const addr = reqUrl.searchParams.get(\"address\");\n if (!addr) {\n error(res, \"address query parameter is required\", 400);\n return true;\n }\n const result = generateProof(addr);\n json(res, result);\n return true;\n }\n\n return false;\n}\n"],"mappings":"AAGA,SAAS,oBAAoB,qBAAqB;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA6BP,eAAsB,iBACpB,KACkB;AAClB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAMJ,MAAI,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AM,QAAQ,mBAAmB;AACjC,UAAM,gBAAgB,MAAM,cAAc;AAC1C,QAAI,CAAC,eAAe;AAClB,YAAM,KAAK,4BAA4B;AACvC,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,MAAM,YAAY,KAAK,UAAU,aAAa;AAC7D,QAAI,OAAO,YAAY,OAAO,QAAQ;AACpC,0BAAoB,eAAe,KAAK,UAAU,OAAO,MAAM;AAAA,IACjE;AACA,SAAK,KAAK,MAAM;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,SAAS,aAAa,8BAA8B;AACjE,UAAM,EAAE,KAAK,IAAI,mBAAmB;AACpC,SAAK,KAAK;AAAA,MACR,MAAM,KAAK;AAAA,MACX,cAAc,KAAK;AAAA,MACnB,YAAY;AAAA,IACd,CAAC;AACD,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,SAAS,aAAa,+BAA+B;AAClE,UAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,UAAU,IAAI,QAAQ,IAAI,EAAE;AAClE,UAAM,OAAO,OAAO,aAAa,IAAI,SAAS;AAC9C,QAAI,CAAC,MAAM;AACT,YAAM,KAAK,uCAAuC,GAAG;AACrD,aAAO;AAAA,IACT;AACA,UAAM,SAAS,cAAc,IAAI;AACjC,SAAK,KAAK,MAAM;AAChB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-service-registry.d.ts","sourceRoot":"","sources":["../src/drop-service-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAE1E;AAED,wBAAgB,wBAAwB,IAAI,WAAW,GAAG,IAAI,CAE7D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
let activeDropService = null;
|
|
2
|
+
function setElizaMakerDropService(service) {
|
|
3
|
+
activeDropService = service;
|
|
4
|
+
}
|
|
5
|
+
function getElizaMakerDropService() {
|
|
6
|
+
return activeDropService;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
getElizaMakerDropService,
|
|
10
|
+
setElizaMakerDropService
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=drop-service-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/drop-service-registry.ts"],"sourcesContent":["import type { DropService } from \"./drop-service.js\";\n\nlet activeDropService: DropService | null = null;\n\nexport function setElizaMakerDropService(service: DropService | null): void {\n activeDropService = service;\n}\n\nexport function getElizaMakerDropService(): DropService | null {\n return activeDropService;\n}\n"],"mappings":"AAEA,IAAI,oBAAwC;AAErC,SAAS,yBAAyB,SAAmC;AAC1E,sBAAoB;AACtB;AAEO,SAAS,2BAA+C;AAC7D,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ElizaMaker drop/mint service.
|
|
3
|
+
*
|
|
4
|
+
* Handles the ERC-8041 fixed-supply collection minting:
|
|
5
|
+
* - Public free mint (user pays gas)
|
|
6
|
+
* - Shiny mint (0.1 ETH + gas)
|
|
7
|
+
* - Whitelist mint (Merkle proof)
|
|
8
|
+
* - Supply tracking and status
|
|
9
|
+
*/
|
|
10
|
+
import * as ethers from "ethers";
|
|
11
|
+
export interface DropStatus {
|
|
12
|
+
dropEnabled: boolean;
|
|
13
|
+
publicMintOpen: boolean;
|
|
14
|
+
whitelistMintOpen: boolean;
|
|
15
|
+
mintedOut: boolean;
|
|
16
|
+
currentSupply: number;
|
|
17
|
+
maxSupply: number;
|
|
18
|
+
shinyPrice: string;
|
|
19
|
+
userHasMinted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface MintResult {
|
|
22
|
+
agentId: number;
|
|
23
|
+
mintNumber: number;
|
|
24
|
+
txHash: string;
|
|
25
|
+
isShiny: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface DropTxService {
|
|
28
|
+
readonly address: string;
|
|
29
|
+
getContract(address: string, abi: ethers.InterfaceAbi): ethers.Contract;
|
|
30
|
+
getFreshNonce(): Promise<number>;
|
|
31
|
+
}
|
|
32
|
+
export declare class DropService {
|
|
33
|
+
private readonly contract;
|
|
34
|
+
private readonly txService;
|
|
35
|
+
private readonly dropEnabled;
|
|
36
|
+
constructor(txService: DropTxService, collectionAddress: string, dropEnabled: boolean);
|
|
37
|
+
getStatus(): Promise<DropStatus>;
|
|
38
|
+
mint(name: string, endpoint: string, capabilitiesHash?: string): Promise<MintResult>;
|
|
39
|
+
mintShiny(name: string, endpoint: string, capabilitiesHash?: string): Promise<MintResult>;
|
|
40
|
+
mintWithWhitelist(name: string, endpoint: string, proof: string[], capabilitiesHash?: string): Promise<MintResult>;
|
|
41
|
+
getMintNumber(agentId: number): Promise<number>;
|
|
42
|
+
checkIsShiny(agentId: number): Promise<boolean>;
|
|
43
|
+
private parseMintReceipt;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=drop-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-service.d.ts","sourceRoot":"","sources":["../src/drop-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MA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ECTION_ABI = [
|
|
4
|
+
"function mint(string,string,bytes32) external returns (uint256)",
|
|
5
|
+
"function mintShiny(string,string,bytes32) external payable returns (uint256)",
|
|
6
|
+
"function mintWhitelist(string,string,bytes32,bytes32[]) external returns (uint256)",
|
|
7
|
+
"function mintFor(address,string,string,bytes32,bool) external returns (uint256)",
|
|
8
|
+
"function currentSupply() view returns (uint256)",
|
|
9
|
+
"function publicMintOpen() view returns (bool)",
|
|
10
|
+
"function whitelistMintOpen() view returns (bool)",
|
|
11
|
+
"function hasMinted(address) view returns (bool)",
|
|
12
|
+
"function getAgentMintNumber(uint256) view returns (uint256)",
|
|
13
|
+
"function isShiny(uint256) view returns (bool)",
|
|
14
|
+
"function getCollectionDetails() view returns (uint256,uint256,bool)",
|
|
15
|
+
"function MAX_SUPPLY() view returns (uint256)",
|
|
16
|
+
"function SHINY_PRICE() view returns (uint256)",
|
|
17
|
+
"function merkleRoot() view returns (bytes32)",
|
|
18
|
+
"event AgentMinted(uint256 indexed agentId, uint256 indexed mintNumber, address indexed owner, bool shiny)",
|
|
19
|
+
"event CollectionUpdated(uint256 maxSupply, uint256 currentSupply, bool publicOpen, bool whitelistOpen)"
|
|
20
|
+
];
|
|
21
|
+
const DEFAULT_CAP_HASH = ethers.id("eliza-agent");
|
|
22
|
+
class DropService {
|
|
23
|
+
contract;
|
|
24
|
+
txService;
|
|
25
|
+
dropEnabled;
|
|
26
|
+
constructor(txService, collectionAddress, dropEnabled) {
|
|
27
|
+
this.txService = txService;
|
|
28
|
+
this.contract = txService.getContract(collectionAddress, COLLECTION_ABI);
|
|
29
|
+
this.dropEnabled = dropEnabled;
|
|
30
|
+
}
|
|
31
|
+
async getStatus() {
|
|
32
|
+
if (!this.dropEnabled) {
|
|
33
|
+
return {
|
|
34
|
+
dropEnabled: false,
|
|
35
|
+
publicMintOpen: false,
|
|
36
|
+
whitelistMintOpen: false,
|
|
37
|
+
mintedOut: false,
|
|
38
|
+
currentSupply: 0,
|
|
39
|
+
maxSupply: 2138,
|
|
40
|
+
shinyPrice: "0.1",
|
|
41
|
+
userHasMinted: false
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const [collectionDetails, whitelistOpen, hasMinted, shinyPriceBN] = await Promise.all([
|
|
45
|
+
this.contract.getCollectionDetails(),
|
|
46
|
+
this.contract.whitelistMintOpen(),
|
|
47
|
+
this.contract.hasMinted(this.txService.address),
|
|
48
|
+
this.contract.SHINY_PRICE()
|
|
49
|
+
]);
|
|
50
|
+
const [maxSupply, currentSupply, publicOpen] = collectionDetails;
|
|
51
|
+
const maxSupplyNum = Number(maxSupply);
|
|
52
|
+
const currentSupplyNum = Number(currentSupply);
|
|
53
|
+
return {
|
|
54
|
+
dropEnabled: true,
|
|
55
|
+
publicMintOpen: publicOpen,
|
|
56
|
+
whitelistMintOpen: whitelistOpen,
|
|
57
|
+
mintedOut: currentSupplyNum >= maxSupplyNum,
|
|
58
|
+
currentSupply: currentSupplyNum,
|
|
59
|
+
maxSupply: maxSupplyNum,
|
|
60
|
+
shinyPrice: ethers.formatEther(shinyPriceBN),
|
|
61
|
+
userHasMinted: hasMinted
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async mint(name, endpoint, capabilitiesHash) {
|
|
65
|
+
const capHash = capabilitiesHash || DEFAULT_CAP_HASH;
|
|
66
|
+
logger.info(`[drop] Minting agent "${name}" for ${this.txService.address}`);
|
|
67
|
+
const nonce = await this.txService.getFreshNonce();
|
|
68
|
+
const tx = await this.contract.mint(name, endpoint, capHash, { nonce });
|
|
69
|
+
logger.info(`[drop] Mint tx submitted: ${tx.hash}`);
|
|
70
|
+
const receipt = await tx.wait();
|
|
71
|
+
return this.parseMintReceipt(receipt, false);
|
|
72
|
+
}
|
|
73
|
+
async mintShiny(name, endpoint, capabilitiesHash) {
|
|
74
|
+
const capHash = capabilitiesHash || DEFAULT_CAP_HASH;
|
|
75
|
+
const shinyPrice = await this.contract.SHINY_PRICE();
|
|
76
|
+
logger.info(
|
|
77
|
+
`[drop] Minting SHINY agent "${name}" for ${this.txService.address} (${ethers.formatEther(shinyPrice)} ETH)`
|
|
78
|
+
);
|
|
79
|
+
const nonce = await this.txService.getFreshNonce();
|
|
80
|
+
const tx = await this.contract.mintShiny(name, endpoint, capHash, {
|
|
81
|
+
value: shinyPrice,
|
|
82
|
+
nonce
|
|
83
|
+
});
|
|
84
|
+
logger.info(`[drop] Shiny mint tx submitted: ${tx.hash}`);
|
|
85
|
+
const receipt = await tx.wait();
|
|
86
|
+
return this.parseMintReceipt(receipt, true);
|
|
87
|
+
}
|
|
88
|
+
async mintWithWhitelist(name, endpoint, proof, capabilitiesHash) {
|
|
89
|
+
const capHash = capabilitiesHash || DEFAULT_CAP_HASH;
|
|
90
|
+
logger.info(
|
|
91
|
+
`[drop] Whitelist minting agent "${name}" for ${this.txService.address}`
|
|
92
|
+
);
|
|
93
|
+
const nonce = await this.txService.getFreshNonce();
|
|
94
|
+
const tx = await this.contract.mintWhitelist(
|
|
95
|
+
name,
|
|
96
|
+
endpoint,
|
|
97
|
+
capHash,
|
|
98
|
+
proof,
|
|
99
|
+
{ nonce }
|
|
100
|
+
);
|
|
101
|
+
logger.info(`[drop] Whitelist mint tx submitted: ${tx.hash}`);
|
|
102
|
+
const receipt = await tx.wait();
|
|
103
|
+
return this.parseMintReceipt(receipt, false);
|
|
104
|
+
}
|
|
105
|
+
async getMintNumber(agentId) {
|
|
106
|
+
return Number(await this.contract.getAgentMintNumber(agentId));
|
|
107
|
+
}
|
|
108
|
+
async checkIsShiny(agentId) {
|
|
109
|
+
return this.contract.isShiny(agentId);
|
|
110
|
+
}
|
|
111
|
+
parseMintReceipt(receipt, shiny) {
|
|
112
|
+
const iface = new ethers.Interface(COLLECTION_ABI);
|
|
113
|
+
let agentId = 0;
|
|
114
|
+
let mintNumber = 0;
|
|
115
|
+
for (const log of receipt.logs) {
|
|
116
|
+
const parsed = iface.parseLog({
|
|
117
|
+
topics: log.topics,
|
|
118
|
+
data: log.data
|
|
119
|
+
});
|
|
120
|
+
if (parsed && parsed.name === "AgentMinted") {
|
|
121
|
+
agentId = Number(parsed.args[0]);
|
|
122
|
+
mintNumber = Number(parsed.args[1]);
|
|
123
|
+
shiny = parsed.args[3];
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
logger.info(
|
|
128
|
+
`[drop] Minted: agentId=${agentId} mintNumber=${mintNumber} shiny=${shiny} txHash=${receipt.hash}`
|
|
129
|
+
);
|
|
130
|
+
return { agentId, mintNumber, txHash: receipt.hash, isShiny: shiny };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
DropService
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=drop-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/drop-service.ts"],"sourcesContent":["/**\n * ElizaMaker drop/mint service.\n *\n * Handles the ERC-8041 fixed-supply collection minting:\n * - Public free mint (user pays gas)\n * - Shiny mint (0.1 ETH + gas)\n * - Whitelist mint (Merkle proof)\n * - Supply tracking and status\n */\n\nimport { logger } from \"@elizaos/core\";\nimport * as ethers from \"ethers\";\n\nexport interface DropStatus {\n dropEnabled: boolean;\n publicMintOpen: boolean;\n whitelistMintOpen: boolean;\n mintedOut: boolean;\n currentSupply: number;\n maxSupply: number;\n shinyPrice: string;\n userHasMinted: boolean;\n}\n\nexport interface MintResult {\n agentId: number;\n mintNumber: number;\n txHash: string;\n isShiny: boolean;\n}\n\n// ── ABI ──────────────────────────────────────────────────────────────────\n\nconst COLLECTION_ABI = [\n \"function mint(string,string,bytes32) external returns (uint256)\",\n \"function mintShiny(string,string,bytes32) external payable returns (uint256)\",\n \"function mintWhitelist(string,string,bytes32,bytes32[]) external returns (uint256)\",\n \"function mintFor(address,string,string,bytes32,bool) external returns (uint256)\",\n \"function currentSupply() view returns (uint256)\",\n \"function publicMintOpen() view returns (bool)\",\n \"function whitelistMintOpen() view returns (bool)\",\n \"function hasMinted(address) view returns (bool)\",\n \"function getAgentMintNumber(uint256) view returns (uint256)\",\n \"function isShiny(uint256) view returns (bool)\",\n \"function getCollectionDetails() view returns (uint256,uint256,bool)\",\n \"function MAX_SUPPLY() view returns (uint256)\",\n \"function SHINY_PRICE() view returns (uint256)\",\n \"function merkleRoot() view returns (bytes32)\",\n \"event AgentMinted(uint256 indexed agentId, uint256 indexed mintNumber, address indexed owner, bool shiny)\",\n \"event CollectionUpdated(uint256 maxSupply, uint256 currentSupply, bool publicOpen, bool whitelistOpen)\",\n] as const;\n\nconst DEFAULT_CAP_HASH = ethers.id(\"eliza-agent\");\n\ninterface DropTxService {\n readonly address: string;\n getContract(address: string, abi: ethers.InterfaceAbi): ethers.Contract;\n getFreshNonce(): Promise<number>;\n}\n\n// ── Service ──────────────────────────────────────────────────────────────\n\nexport class DropService {\n private readonly contract: ethers.Contract;\n private readonly txService: DropTxService;\n private readonly dropEnabled: boolean;\n\n constructor(\n txService: DropTxService,\n collectionAddress: string,\n dropEnabled: boolean,\n ) {\n this.txService = txService;\n this.contract = txService.getContract(collectionAddress, COLLECTION_ABI);\n this.dropEnabled = dropEnabled;\n }\n\n async getStatus(): Promise<DropStatus> {\n if (!this.dropEnabled) {\n return {\n dropEnabled: false,\n publicMintOpen: false,\n whitelistMintOpen: false,\n mintedOut: false,\n currentSupply: 0,\n maxSupply: 2138,\n shinyPrice: \"0.1\",\n userHasMinted: false,\n };\n }\n\n const [collectionDetails, whitelistOpen, hasMinted, shinyPriceBN] =\n await Promise.all([\n this.contract.getCollectionDetails() as Promise<\n [bigint, bigint, boolean]\n >,\n this.contract.whitelistMintOpen() as Promise<boolean>,\n this.contract.hasMinted(this.txService.address) as Promise<boolean>,\n this.contract.SHINY_PRICE() as Promise<bigint>,\n ]);\n\n const [maxSupply, currentSupply, publicOpen] = collectionDetails;\n const maxSupplyNum = Number(maxSupply);\n const currentSupplyNum = Number(currentSupply);\n\n return {\n dropEnabled: true,\n publicMintOpen: publicOpen,\n whitelistMintOpen: whitelistOpen,\n mintedOut: currentSupplyNum >= maxSupplyNum,\n currentSupply: currentSupplyNum,\n maxSupply: maxSupplyNum,\n shinyPrice: ethers.formatEther(shinyPriceBN),\n userHasMinted: hasMinted,\n };\n }\n\n async mint(\n name: string,\n endpoint: string,\n capabilitiesHash?: string,\n ): Promise<MintResult> {\n const capHash = capabilitiesHash || DEFAULT_CAP_HASH;\n\n logger.info(`[drop] Minting agent \"${name}\" for ${this.txService.address}`);\n\n // Get fresh nonce before transaction\n const nonce = await this.txService.getFreshNonce();\n\n const tx = await this.contract.mint(name, endpoint, capHash, { nonce });\n logger.info(`[drop] Mint tx submitted: ${tx.hash}`);\n\n const receipt = await tx.wait();\n return this.parseMintReceipt(receipt, false);\n }\n\n async mintShiny(\n name: string,\n endpoint: string,\n capabilitiesHash?: string,\n ): Promise<MintResult> {\n const capHash = capabilitiesHash || DEFAULT_CAP_HASH;\n const shinyPrice = (await this.contract.SHINY_PRICE()) as bigint;\n\n logger.info(\n `[drop] Minting SHINY agent \"${name}\" for ${this.txService.address} (${ethers.formatEther(shinyPrice)} ETH)`,\n );\n\n // Get fresh nonce before transaction\n const nonce = await this.txService.getFreshNonce();\n\n const tx = await this.contract.mintShiny(name, endpoint, capHash, {\n value: shinyPrice,\n nonce,\n });\n logger.info(`[drop] Shiny mint tx submitted: ${tx.hash}`);\n\n const receipt = await tx.wait();\n return this.parseMintReceipt(receipt, true);\n }\n\n async mintWithWhitelist(\n name: string,\n endpoint: string,\n proof: string[],\n capabilitiesHash?: string,\n ): Promise<MintResult> {\n const capHash = capabilitiesHash || DEFAULT_CAP_HASH;\n\n logger.info(\n `[drop] Whitelist minting agent \"${name}\" for ${this.txService.address}`,\n );\n\n // Get fresh nonce before transaction\n const nonce = await this.txService.getFreshNonce();\n\n const tx = await this.contract.mintWhitelist(\n name,\n endpoint,\n capHash,\n proof,\n { nonce },\n );\n logger.info(`[drop] Whitelist mint tx submitted: ${tx.hash}`);\n\n const receipt = await tx.wait();\n return this.parseMintReceipt(receipt, false);\n }\n\n async getMintNumber(agentId: number): Promise<number> {\n return Number(await this.contract.getAgentMintNumber(agentId));\n }\n\n async checkIsShiny(agentId: number): Promise<boolean> {\n return this.contract.isShiny(agentId) as Promise<boolean>;\n }\n\n private parseMintReceipt(\n receipt: ethers.TransactionReceipt,\n shiny: boolean,\n ): MintResult {\n const iface = new ethers.Interface(COLLECTION_ABI);\n let agentId = 0;\n let mintNumber = 0;\n\n for (const log of receipt.logs) {\n const parsed = iface.parseLog({\n topics: log.topics as string[],\n data: log.data,\n });\n if (parsed && parsed.name === \"AgentMinted\") {\n agentId = Number(parsed.args[0]);\n mintNumber = Number(parsed.args[1]);\n shiny = parsed.args[3] as boolean;\n break;\n }\n }\n\n logger.info(\n `[drop] Minted: agentId=${agentId} mintNumber=${mintNumber} shiny=${shiny} txHash=${receipt.hash}`,\n );\n\n return { agentId, mintNumber, txHash: receipt.hash, isShiny: shiny };\n }\n}\n"],"mappings":"AAUA,SAAS,cAAc;AACvB,YAAY,YAAY;AAsBxB,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,mBAAmB,OAAO,GAAG,aAAa;AAUzC,MAAM,YAAY;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YACE,WACA,mBACA,aACA;AACA,SAAK,YAAY;AACjB,SAAK,WAAW,UAAU,YAAY,mBAAmB,cAAc;AACvE,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,YAAiC;AACrC,QAAI,CAAC,KAAK,aAAa;AACrB,aAAO;AAAA,QACL,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,WAAW;AAAA,QACX,eAAe;AAAA,QACf,WAAW;A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AK,CAAC,CAAC;AAClC,gBAAQ,OAAO,KAAK,CAAC;AACrB;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,MACL,0BAA0B,OAAO,eAAe,UAAU,UAAU,KAAK,WAAW,QAAQ,IAAI;AAAA,IAClG;AAEA,WAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,MAAM,SAAS,MAAM;AAAA,EACrE;AACF;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { handleDropRoutes } from "./drop-routes.js";
|
|
2
|
+
export type { DropStatus, MintResult } from "./drop-service.js";
|
|
3
|
+
export { DropService } from "./drop-service.js";
|
|
4
|
+
export { getElizaMakerDropService, setElizaMakerDropService, } from "./drop-service-registry.js";
|
|
5
|
+
export { initializeRegistryAndDropServices } from "./init-registry-services.js";
|
|
6
|
+
export { buildWhitelistTree, generateProof } from "./merkle-tree.js";
|
|
7
|
+
export * from "./nft-verify.js";
|
|
8
|
+
export { initializeOGCode } from "./og-tracker.js";
|
|
9
|
+
export { default, elizaMakerPlugin } from "./plugin.js";
|
|
10
|
+
export { getElizaMakerRegistryService, setElizaMakerRegistryService, } from "./registry-service-registry.js";
|
|
11
|
+
export type { VerificationResult } from "./twitter-verify.js";
|
|
12
|
+
export { generateVerificationMessage, getVerifiedAddresses, isAddressWhitelisted, markAddressVerified, verifyTweet, } from "./twitter-verify.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { handleDropRoutes } from "./drop-routes.js";
|
|
2
|
+
import { DropService } from "./drop-service.js";
|
|
3
|
+
import {
|
|
4
|
+
getElizaMakerDropService,
|
|
5
|
+
setElizaMakerDropService
|
|
6
|
+
} from "./drop-service-registry.js";
|
|
7
|
+
import { initializeRegistryAndDropServices } from "./init-registry-services.js";
|
|
8
|
+
import { buildWhitelistTree, generateProof } from "./merkle-tree.js";
|
|
9
|
+
export * from "./nft-verify.js";
|
|
10
|
+
import { initializeOGCode } from "./og-tracker.js";
|
|
11
|
+
import { default as default2, elizaMakerPlugin } from "./plugin.js";
|
|
12
|
+
import {
|
|
13
|
+
getElizaMakerRegistryService,
|
|
14
|
+
setElizaMakerRegistryService
|
|
15
|
+
} from "./registry-service-registry.js";
|
|
16
|
+
import {
|
|
17
|
+
generateVerificationMessage,
|
|
18
|
+
getVerifiedAddresses,
|
|
19
|
+
isAddressWhitelisted,
|
|
20
|
+
markAddressVerified,
|
|
21
|
+
verifyTweet
|
|
22
|
+
} from "./twitter-verify.js";
|
|
23
|
+
export {
|
|
24
|
+
DropService,
|
|
25
|
+
buildWhitelistTree,
|
|
26
|
+
default2 as default,
|
|
27
|
+
elizaMakerPlugin,
|
|
28
|
+
generateProof,
|
|
29
|
+
generateVerificationMessage,
|
|
30
|
+
getElizaMakerDropService,
|
|
31
|
+
getElizaMakerRegistryService,
|
|
32
|
+
getVerifiedAddresses,
|
|
33
|
+
handleDropRoutes,
|
|
34
|
+
initializeOGCode,
|
|
35
|
+
initializeRegistryAndDropServices,
|
|
36
|
+
isAddressWhitelisted,
|
|
37
|
+
markAddressVerified,
|
|
38
|
+
setElizaMakerDropService,
|
|
39
|
+
setElizaMakerRegistryService,
|
|
40
|
+
verifyTweet
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { handleDropRoutes } from \"./drop-routes.js\";\nexport type { DropStatus, MintResult } from \"./drop-service.js\";\nexport { DropService } from \"./drop-service.js\";\nexport {\n getElizaMakerDropService,\n setElizaMakerDropService,\n} from \"./drop-service-registry.js\";\nexport { initializeRegistryAndDropServices } from \"./init-registry-services.js\";\nexport { buildWhitelistTree, generateProof } from \"./merkle-tree.js\";\nexport * from \"./nft-verify.js\";\nexport { initializeOGCode } from \"./og-tracker.js\";\nexport { default, elizaMakerPlugin } from \"./plugin.js\";\nexport {\n getElizaMakerRegistryService,\n setElizaMakerRegistryService,\n} from \"./registry-service-registry.js\";\nexport type { VerificationResult } from \"./twitter-verify.js\";\nexport {\n generateVerificationMessage,\n getVerifiedAddresses,\n isAddressWhitelisted,\n markAddressVerified,\n verifyTweet,\n} from \"./twitter-verify.js\";\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,yCAAyC;AAClD,SAAS,oBAAoB,qBAAqB;AAClD,cAAc;AACd,SAAS,wBAAwB;AACjC,SAAS,WAAAA,UAAS,wBAAwB;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["default"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ERC-8004 RegistryService + DropService bootstrap.
|
|
3
|
+
*
|
|
4
|
+
* Previously inlined in `packages/agent/src/api/server.ts`
|
|
5
|
+
* (`startDeferredStartupWork`). Moving the construction here keeps the
|
|
6
|
+
* agent server out of the ERC-8004 contract wiring; consumers that need
|
|
7
|
+
* the live services read them through the in-process registries
|
|
8
|
+
* (drop-service-registry / registry-service-registry).
|
|
9
|
+
*
|
|
10
|
+
* Timing: the original block ran post-listen via setImmediate-equivalent
|
|
11
|
+
* deferred startup. This function preserves that behavior by spawning the
|
|
12
|
+
* actual work asynchronously — callers invoke it without awaiting from
|
|
13
|
+
* within Plugin.init, which lets the runtime finish booting before the
|
|
14
|
+
* outbound RPC probe runs.
|
|
15
|
+
*/
|
|
16
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
17
|
+
export declare function initializeRegistryAndDropServices(runtime: IAgentRuntime): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=init-registry-services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-registry-services.d.ts","sourceRoot":"","sources":["../src/init-registry-services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA+BnD,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAuDf"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadElizaConfig,
|
|
3
|
+
normalizeJsonRpcUrl,
|
|
4
|
+
probeJsonRpcEndpoint,
|
|
5
|
+
RegistryService,
|
|
6
|
+
TxService
|
|
7
|
+
} from "@elizaos/agent";
|
|
8
|
+
import { logger } from "@elizaos/core";
|
|
9
|
+
import { DropService } from "./drop-service.js";
|
|
10
|
+
import { setElizaMakerDropService } from "./drop-service-registry.js";
|
|
11
|
+
import { initializeOGCode } from "./og-tracker.js";
|
|
12
|
+
import { setElizaMakerRegistryService } from "./registry-service-registry.js";
|
|
13
|
+
function readRuntimeSetting(runtime, key) {
|
|
14
|
+
const value = runtime.getSetting?.(key);
|
|
15
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
16
|
+
}
|
|
17
|
+
async function initializeRegistryAndDropServices(runtime) {
|
|
18
|
+
initializeOGCode();
|
|
19
|
+
const config = loadElizaConfig();
|
|
20
|
+
const evmKey = readRuntimeSetting(runtime, "EVM_PRIVATE_KEY") ?? config.env?.EVM_PRIVATE_KEY;
|
|
21
|
+
const registryConfig = config.registry;
|
|
22
|
+
if (!evmKey || !registryConfig?.registryAddress || !registryConfig.mainnetRpc) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const registryRpcUrl = normalizeJsonRpcUrl(registryConfig.mainnetRpc);
|
|
27
|
+
const registryRpcProbe = await probeJsonRpcEndpoint(registryRpcUrl);
|
|
28
|
+
if (!registryRpcProbe.ok) {
|
|
29
|
+
logger.warn(
|
|
30
|
+
{
|
|
31
|
+
reason: registryRpcProbe.reason
|
|
32
|
+
},
|
|
33
|
+
"ERC-8004 registry service disabled because mainnetRpc is unavailable"
|
|
34
|
+
);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const txService = new TxService(registryRpcUrl, evmKey);
|
|
38
|
+
const registryService = new RegistryService(
|
|
39
|
+
txService,
|
|
40
|
+
registryConfig.registryAddress
|
|
41
|
+
);
|
|
42
|
+
setElizaMakerRegistryService(registryService);
|
|
43
|
+
if (registryConfig.collectionAddress) {
|
|
44
|
+
const dropEnabled = config.features?.dropEnabled === true;
|
|
45
|
+
const dropService = new DropService(
|
|
46
|
+
txService,
|
|
47
|
+
registryConfig.collectionAddress,
|
|
48
|
+
dropEnabled
|
|
49
|
+
);
|
|
50
|
+
setElizaMakerDropService(dropService);
|
|
51
|
+
} else {
|
|
52
|
+
setElizaMakerDropService(null);
|
|
53
|
+
}
|
|
54
|
+
logger.info(
|
|
55
|
+
`ERC-8004 registry service initialised (${registryConfig.registryAddress})`
|
|
56
|
+
);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
logger.warn({ err }, "Failed to initialize ERC-8004 registry service");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
initializeRegistryAndDropServices
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=init-registry-services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/init-registry-services.ts"],"sourcesContent":["/**\n * ERC-8004 RegistryService + DropService bootstrap.\n *\n * Previously inlined in `packages/agent/src/api/server.ts`\n * (`startDeferredStartupWork`). Moving the construction here keeps the\n * agent server out of the ERC-8004 contract wiring; consumers that need\n * the live services read them through the in-process registries\n * (drop-service-registry / registry-service-registry).\n *\n * Timing: the original block ran post-listen via setImmediate-equivalent\n * deferred startup. This function preserves that behavior by spawning the\n * actual work asynchronously — callers invoke it without awaiting from\n * within Plugin.init, which lets the runtime finish booting before the\n * outbound RPC probe runs.\n */\n\nimport {\n loadElizaConfig,\n normalizeJsonRpcUrl,\n probeJsonRpcEndpoint,\n RegistryService,\n TxService,\n} from \"@elizaos/agent\";\nimport type { IAgentRuntime } from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport { DropService } from \"./drop-service.js\";\nimport { setElizaMakerDropService } from \"./drop-service-registry.js\";\nimport { initializeOGCode } from \"./og-tracker.js\";\nimport { setElizaMakerRegistryService } from \"./registry-service-registry.js\";\n\ninterface RegistryConfigShape {\n registryAddress?: string;\n collectionAddress?: string;\n mainnetRpc?: string;\n}\n\ninterface FeaturesShape {\n dropEnabled?: boolean;\n}\n\ninterface ElizaConfigShape {\n registry?: RegistryConfigShape;\n features?: FeaturesShape;\n env?: Record<string, string>;\n}\n\nfunction readRuntimeSetting(\n runtime: IAgentRuntime,\n key: string,\n): string | undefined {\n const value = runtime.getSetting?.(key);\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nexport async function initializeRegistryAndDropServices(\n runtime: IAgentRuntime,\n): Promise<void> {\n initializeOGCode();\n\n const config = loadElizaConfig() as ElizaConfigShape;\n\n const evmKey =\n readRuntimeSetting(runtime, \"EVM_PRIVATE_KEY\") ??\n config.env?.EVM_PRIVATE_KEY;\n const registryConfig = config.registry;\n if (\n !evmKey ||\n !registryConfig?.registryAddress ||\n !registryConfig.mainnetRpc\n ) {\n return;\n }\n\n try {\n const registryRpcUrl = normalizeJsonRpcUrl(registryConfig.mainnetRpc);\n const registryRpcProbe = await probeJsonRpcEndpoint(registryRpcUrl);\n if (!registryRpcProbe.ok) {\n logger.warn(\n {\n reason: registryRpcProbe.reason,\n },\n \"ERC-8004 registry service disabled because mainnetRpc is unavailable\",\n );\n return;\n }\n\n const txService = new TxService(registryRpcUrl, evmKey);\n const registryService = new RegistryService(\n txService,\n registryConfig.registryAddress,\n );\n setElizaMakerRegistryService(registryService);\n\n if (registryConfig.collectionAddress) {\n const dropEnabled = config.features?.dropEnabled === true;\n const dropService = new DropService(\n txService,\n registryConfig.collectionAddress,\n dropEnabled,\n );\n setElizaMakerDropService(dropService);\n } else {\n setElizaMakerDropService(null);\n }\n\n logger.info(\n `ERC-8004 registry service initialised (${registryConfig.registryAddress})`,\n );\n } catch (err) {\n logger.warn({ err }, \"Failed to initialize ERC-8004 registry service\");\n }\n}\n"],"mappings":"AAgBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,wBAAwB;AACjC,SAAS,oCAAoC;AAkB7C,SAAS,mBACP,SACA,KACoB;AACpB,QAAM,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