@coinbase/agentkit 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -23
- package/dist/action-providers/across/acrossActionProvider.js +3 -3
- package/dist/action-providers/across/schemas.d.ts +1 -1
- package/dist/action-providers/baseAccount/baseAccountActionProvider.d.ts +46 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.js +404 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.test.d.ts +1 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.test.js +325 -0
- package/dist/action-providers/baseAccount/index.d.ts +2 -0
- package/dist/action-providers/baseAccount/index.js +18 -0
- package/dist/action-providers/baseAccount/schemas.d.ts +43 -0
- package/dist/action-providers/baseAccount/schemas.js +62 -0
- package/dist/action-providers/baseAccount/types.d.ts +17 -0
- package/dist/action-providers/baseAccount/types.js +2 -0
- package/dist/action-providers/baseAccount/utils.d.ts +14 -0
- package/dist/action-providers/baseAccount/utils.js +57 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +3 -12
- package/dist/action-providers/cdp/cdpApiActionProvider.js +2 -81
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +0 -125
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +18 -3
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +224 -23
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +280 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +17 -2
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +224 -18
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +267 -1
- package/dist/action-providers/cdp/schemas.d.ts +12 -12
- package/dist/action-providers/cdp/schemas.js +17 -5
- package/dist/action-providers/cdp/swapUtils.d.ts +23 -0
- package/dist/action-providers/cdp/swapUtils.js +106 -0
- package/dist/action-providers/clanker/clankerActionProvider.d.ts +43 -0
- package/dist/action-providers/clanker/clankerActionProvider.js +130 -0
- package/dist/action-providers/clanker/clankerActionProvider.test.d.ts +4 -0
- package/dist/action-providers/clanker/clankerActionProvider.test.js +119 -0
- package/dist/action-providers/clanker/index.d.ts +2 -0
- package/dist/action-providers/clanker/index.js +18 -0
- package/dist/action-providers/clanker/schemas.d.ts +56 -0
- package/dist/action-providers/clanker/schemas.js +47 -0
- package/dist/action-providers/clanker/utils.d.ts +9 -0
- package/dist/action-providers/clanker/utils.js +23 -0
- package/dist/action-providers/compound/constants.d.ts +1 -1
- package/dist/action-providers/compound/constants.js +2 -2
- package/dist/action-providers/erc20/constants.d.ts +35 -135
- package/dist/action-providers/erc20/constants.js +37 -189
- package/dist/action-providers/erc20/erc20ActionProvider.d.ts +9 -1
- package/dist/action-providers/erc20/erc20ActionProvider.js +87 -35
- package/dist/action-providers/erc20/erc20ActionProvider.test.js +115 -52
- package/dist/action-providers/erc20/schemas.d.ts +25 -12
- package/dist/action-providers/erc20/schemas.js +34 -6
- package/dist/action-providers/erc20/utils.d.ts +19 -0
- package/dist/action-providers/erc20/utils.js +54 -0
- package/dist/action-providers/flaunch/client_utils.d.ts +25 -0
- package/dist/action-providers/flaunch/client_utils.js +62 -0
- package/dist/action-providers/flaunch/constants.d.ts +42 -21
- package/dist/action-providers/flaunch/constants.js +113 -38
- package/dist/action-providers/flaunch/flaunchActionProvider.d.ts +4 -43
- package/dist/action-providers/flaunch/flaunchActionProvider.js +133 -209
- package/dist/action-providers/flaunch/flaunchActionProvider.test.js +113 -13
- package/dist/action-providers/flaunch/metadata_utils.d.ts +12 -0
- package/dist/action-providers/flaunch/metadata_utils.js +216 -0
- package/dist/action-providers/flaunch/schemas.d.ts +39 -3
- package/dist/action-providers/flaunch/schemas.js +62 -10
- package/dist/action-providers/flaunch/{utils.d.ts → swap_utils.d.ts} +17 -19
- package/dist/action-providers/flaunch/{utils.js → swap_utils.js} +137 -172
- package/dist/action-providers/index.d.ts +4 -0
- package/dist/action-providers/index.js +4 -0
- package/dist/action-providers/jupiter/schemas.d.ts +1 -1
- package/dist/action-providers/moonwell/schemas.d.ts +2 -2
- package/dist/action-providers/morpho/morphoActionProvider.js +5 -5
- package/dist/action-providers/morpho/schemas.d.ts +2 -2
- package/dist/action-providers/pyth/pythActionProvider.d.ts +2 -2
- package/dist/action-providers/pyth/pythActionProvider.js +83 -26
- package/dist/action-providers/pyth/pythActionProvider.test.js +179 -23
- package/dist/action-providers/pyth/schemas.d.ts +6 -0
- package/dist/action-providers/pyth/schemas.js +9 -1
- package/dist/action-providers/superfluid/constants.d.ts +814 -0
- package/dist/action-providers/superfluid/constants.js +2826 -0
- package/dist/action-providers/superfluid/graphQueries/endpoints.d.ts +2 -0
- package/dist/action-providers/superfluid/graphQueries/endpoints.js +5 -0
- package/dist/action-providers/superfluid/graphQueries/queries.d.ts +1 -0
- package/dist/action-providers/superfluid/graphQueries/queries.js +35 -0
- package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.d.ts +8 -0
- package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.js +24 -0
- package/dist/action-providers/superfluid/graphQueries/types.d.ts +27 -0
- package/dist/action-providers/superfluid/graphQueries/types.js +2 -0
- package/dist/action-providers/superfluid/index.d.ts +7 -0
- package/dist/action-providers/superfluid/index.js +23 -0
- package/dist/action-providers/superfluid/schemas.d.ts +86 -0
- package/dist/action-providers/superfluid/schemas.js +103 -0
- package/dist/action-providers/superfluid/superfluidActionProvider.d.ts +20 -0
- package/dist/action-providers/superfluid/superfluidActionProvider.js +36 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.d.ts +46 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.js +143 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.js +92 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.d.ts +27 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.js +71 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.js +57 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.d.ts +56 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.js +191 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.js +80 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.d.ts +30 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +109 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.js +75 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.d.ts +32 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.js +101 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.js +85 -0
- package/dist/action-providers/superfluid/utils/parseLogs.d.ts +19 -0
- package/dist/action-providers/superfluid/utils/parseLogs.js +81 -0
- package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +4 -16
- package/dist/action-providers/truemarkets/truemarketsActionProvider.js +20 -41
- package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +11 -33
- package/dist/action-providers/wallet/walletActionProvider.js +24 -10
- package/dist/action-providers/wallet/walletActionProvider.test.js +6 -2
- package/dist/action-providers/x402/schemas.d.ts +7 -0
- package/dist/action-providers/x402/schemas.js +11 -1
- package/dist/action-providers/x402/utils.d.ts +55 -0
- package/dist/action-providers/x402/utils.js +160 -0
- package/dist/action-providers/x402/x402ActionProvider.d.ts +9 -9
- package/dist/action-providers/x402/x402ActionProvider.js +158 -39
- package/dist/action-providers/x402/x402ActionProvider.test.js +116 -10
- package/dist/action-providers/zeroX/index.d.ts +1 -0
- package/dist/action-providers/zeroX/index.js +17 -0
- package/dist/action-providers/zeroX/schemas.d.ts +51 -0
- package/dist/action-providers/zeroX/schemas.js +82 -0
- package/dist/action-providers/zeroX/utils.d.ts +23 -0
- package/dist/action-providers/zeroX/utils.js +106 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.d.ts +57 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.js +407 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.test.d.ts +1 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.test.js +445 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.js +43 -13
- package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +27 -2
- package/dist/wallet-providers/cdpEvmWalletProvider.js +54 -36
- package/dist/wallet-providers/cdpEvmWalletProvider.test.js +7 -0
- package/dist/wallet-providers/cdpShared.d.ts +5 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +29 -3
- package/dist/wallet-providers/cdpSmartWalletProvider.js +66 -25
- package/dist/wallet-providers/cdpSmartWalletProvider.test.js +6 -10
- package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +1 -1
- package/dist/wallet-providers/cdpSolanaWalletProvider.js +7 -7
- package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +15 -12
- package/dist/wallet-providers/evmWalletProvider.d.ts +13 -2
- package/dist/wallet-providers/evmWalletProvider.js +4 -0
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +18 -2
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +23 -2
- package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +19 -2
- package/dist/wallet-providers/legacyCdpWalletProvider.js +27 -2
- package/dist/wallet-providers/legacyCdpWalletProvider.test.js +6 -0
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +17 -2
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +39 -3
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -1
- package/dist/wallet-providers/privyEvmWalletProvider.d.ts +2 -0
- package/dist/wallet-providers/privyEvmWalletProvider.js +2 -1
- package/dist/wallet-providers/privyEvmWalletProvider.test.js +12 -1
- package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +1 -1
- package/dist/wallet-providers/solanaKeypairWalletProvider.js +3 -4
- package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +4 -2
- package/dist/wallet-providers/viemWalletProvider.d.ts +20 -3
- package/dist/wallet-providers/viemWalletProvider.js +33 -4
- package/dist/wallet-providers/viemWalletProvider.test.js +27 -6
- package/dist/wallet-providers/walletProvider.d.ts +1 -1
- package/dist/wallet-providers/zeroDevWalletProvider.d.ts +17 -2
- package/dist/wallet-providers/zeroDevWalletProvider.js +26 -5
- package/dist/wallet-providers/zeroDevWalletProvider.test.js +12 -2
- package/package.json +8 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface TokenUriParams {
|
|
2
|
+
metadata: {
|
|
3
|
+
image: string;
|
|
4
|
+
description: string;
|
|
5
|
+
websiteUrl?: string;
|
|
6
|
+
discordUrl?: string;
|
|
7
|
+
twitterUrl?: string;
|
|
8
|
+
telegramUrl?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare const generateTokenUri: (name: string, symbol: string, params: TokenUriParams) => Promise<string>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateTokenUri = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* Reads a local file and converts it to base64
|
|
11
|
+
*
|
|
12
|
+
* @param imageFileName - Path to the local file
|
|
13
|
+
* @returns Base64 encoded file and mime type
|
|
14
|
+
*/
|
|
15
|
+
async function readFileAsBase64(imageFileName) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
fs_1.default.readFile(imageFileName, (err, data) => {
|
|
18
|
+
if (err) {
|
|
19
|
+
reject(new Error(`Failed to read file: ${err.message}`));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// Determine mime type based on file extension
|
|
23
|
+
const extension = path_1.default.extname(imageFileName).toLowerCase();
|
|
24
|
+
let mimeType = "application/octet-stream"; // default
|
|
25
|
+
if (extension === ".png")
|
|
26
|
+
mimeType = "image/png";
|
|
27
|
+
else if (extension === ".jpg" || extension === ".jpeg")
|
|
28
|
+
mimeType = "image/jpeg";
|
|
29
|
+
else if (extension === ".gif")
|
|
30
|
+
mimeType = "image/gif";
|
|
31
|
+
else if (extension === ".svg")
|
|
32
|
+
mimeType = "image/svg+xml";
|
|
33
|
+
const base64 = data.toString("base64");
|
|
34
|
+
resolve({ base64, mimeType });
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Uploads a base64 image to IPFS using Flaunch API
|
|
40
|
+
* Rate Limit: Maximum 4 image uploads per minute per IP address
|
|
41
|
+
*
|
|
42
|
+
* @param params - Configuration and base64 image data
|
|
43
|
+
* @param params.base64Image - Base64 encoded image data
|
|
44
|
+
* @param params.name - Optional name for the uploaded file
|
|
45
|
+
* @param params.metadata - Optional metadata key-value pairs
|
|
46
|
+
* @returns Upload response with CID and other details
|
|
47
|
+
*/
|
|
48
|
+
const uploadImageToIPFS = async (params) => {
|
|
49
|
+
try {
|
|
50
|
+
const response = await fetch("https://web2-api.flaunch.gg/api/v1/upload-image", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify({ base64Image: params.base64Image }),
|
|
56
|
+
});
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
const error = await response.json();
|
|
59
|
+
throw new Error(`Failed to upload image to IPFS: ${error.message || response.statusText}`);
|
|
60
|
+
}
|
|
61
|
+
const data = await response.json();
|
|
62
|
+
if (!data.success) {
|
|
63
|
+
throw new Error(`Failed to upload image to IPFS: ${data.error || "Unknown error"}`);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
IpfsHash: data.ipfsHash,
|
|
67
|
+
tokenURI: data.tokenURI,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error instanceof Error) {
|
|
72
|
+
throw new Error(`Failed to upload image to IPFS: ${error.message}`);
|
|
73
|
+
}
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Uploads JSON data to IPFS using Flaunch API
|
|
79
|
+
*
|
|
80
|
+
* @param params - Configuration and JSON data
|
|
81
|
+
* @param params.json - JSON data to upload
|
|
82
|
+
* @param params.name - Optional name for the uploaded file
|
|
83
|
+
* @param params.metadata - Optional metadata key-value pairs
|
|
84
|
+
* @returns Upload response with CID and other details
|
|
85
|
+
*/
|
|
86
|
+
const uploadJsonToIPFS = async (params) => {
|
|
87
|
+
try {
|
|
88
|
+
const response = await fetch("https://web2-api.flaunch.gg/api/v1/upload-metadata", {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: {
|
|
91
|
+
"Content-Type": "application/json",
|
|
92
|
+
},
|
|
93
|
+
body: JSON.stringify({
|
|
94
|
+
name: params.json.name,
|
|
95
|
+
symbol: params.json.symbol,
|
|
96
|
+
description: params.json.description,
|
|
97
|
+
imageIpfs: params.json.image,
|
|
98
|
+
websiteUrl: params.json.external_link,
|
|
99
|
+
discordUrl: params.json.discordUrl,
|
|
100
|
+
twitterUrl: params.json.twitterUrl,
|
|
101
|
+
telegramUrl: params.json.telegramUrl,
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
const error = await response.json();
|
|
106
|
+
throw new Error(`Failed to upload JSON to IPFS: ${error.message || response.statusText}`);
|
|
107
|
+
}
|
|
108
|
+
const data = await response.json();
|
|
109
|
+
if (!data.success) {
|
|
110
|
+
throw new Error(`Failed to upload metadata: ${data.error}`);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
IpfsHash: data.ipfsHash,
|
|
114
|
+
tokenURI: data.tokenURI,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof Error) {
|
|
119
|
+
throw new Error(`Failed to upload JSON to IPFS: ${error.message}`);
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Converts a remote image URL to a properly formatted base64 data URL
|
|
126
|
+
*
|
|
127
|
+
* @param imageUrl - URL of the image to fetch and convert
|
|
128
|
+
* @returns Base64 data URL with proper MIME type detection
|
|
129
|
+
*/
|
|
130
|
+
const convertImageUrlToBase64 = async (imageUrl) => {
|
|
131
|
+
try {
|
|
132
|
+
const response = await fetch(imageUrl);
|
|
133
|
+
if (!response.ok) {
|
|
134
|
+
throw new Error(`Failed to fetch image: ${response.statusText}`);
|
|
135
|
+
}
|
|
136
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
137
|
+
const base64Data = Buffer.from(arrayBuffer).toString("base64");
|
|
138
|
+
// Detect MIME type from response headers
|
|
139
|
+
const contentType = response.headers.get("content-type");
|
|
140
|
+
let mimeType = "image/jpeg"; // default fallback
|
|
141
|
+
if (contentType && contentType.startsWith("image/")) {
|
|
142
|
+
mimeType = contentType;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// Try to detect from URL extension as fallback
|
|
146
|
+
const urlLower = imageUrl.toLowerCase();
|
|
147
|
+
if (urlLower.includes(".png")) {
|
|
148
|
+
mimeType = "image/png";
|
|
149
|
+
}
|
|
150
|
+
else if (urlLower.includes(".gif")) {
|
|
151
|
+
mimeType = "image/gif";
|
|
152
|
+
}
|
|
153
|
+
else if (urlLower.includes(".webp")) {
|
|
154
|
+
mimeType = "image/webp";
|
|
155
|
+
}
|
|
156
|
+
else if (urlLower.includes(".svg")) {
|
|
157
|
+
mimeType = "image/svg+xml";
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return `data:${mimeType};base64,${base64Data}`;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error instanceof Error) {
|
|
164
|
+
throw new Error(`Failed to convert image URL to base64: ${error.message}`);
|
|
165
|
+
}
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const generateTokenUriBase64Image = async (name, symbol, params) => {
|
|
170
|
+
// 1. upload image to IPFS
|
|
171
|
+
const imageRes = await uploadImageToIPFS({
|
|
172
|
+
base64Image: params.metadata.base64Image,
|
|
173
|
+
});
|
|
174
|
+
// 2. upload metadata to IPFS
|
|
175
|
+
const coinMetadata = {
|
|
176
|
+
name,
|
|
177
|
+
symbol,
|
|
178
|
+
description: params.metadata.description,
|
|
179
|
+
image: `ipfs://${imageRes.IpfsHash}`,
|
|
180
|
+
external_link: params.metadata.websiteUrl || "",
|
|
181
|
+
collaborators: [],
|
|
182
|
+
discordUrl: params.metadata.discordUrl || "",
|
|
183
|
+
twitterUrl: params.metadata.twitterUrl || "",
|
|
184
|
+
telegramUrl: params.metadata.telegramUrl || "",
|
|
185
|
+
};
|
|
186
|
+
const metadataRes = await uploadJsonToIPFS({
|
|
187
|
+
json: coinMetadata,
|
|
188
|
+
});
|
|
189
|
+
return `ipfs://${metadataRes.IpfsHash}`;
|
|
190
|
+
};
|
|
191
|
+
const generateTokenUri = async (name, symbol, params) => {
|
|
192
|
+
// 1. get base64Image from image (url or local path)
|
|
193
|
+
let base64Image;
|
|
194
|
+
const image = params.metadata.image;
|
|
195
|
+
if (image.startsWith("https://") || image.startsWith("http://")) {
|
|
196
|
+
base64Image = await convertImageUrlToBase64(image);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// assume local file
|
|
200
|
+
const { base64, mimeType } = await readFileAsBase64(image);
|
|
201
|
+
base64Image = `data:${mimeType};base64,${base64}`;
|
|
202
|
+
}
|
|
203
|
+
// 2. generate token uri
|
|
204
|
+
const tokenUri = await generateTokenUriBase64Image(name, symbol, {
|
|
205
|
+
metadata: {
|
|
206
|
+
base64Image,
|
|
207
|
+
description: params.metadata.description,
|
|
208
|
+
websiteUrl: params.metadata.websiteUrl,
|
|
209
|
+
discordUrl: params.metadata.discordUrl,
|
|
210
|
+
twitterUrl: params.metadata.twitterUrl,
|
|
211
|
+
telegramUrl: params.metadata.telegramUrl,
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
return tokenUri;
|
|
215
|
+
};
|
|
216
|
+
exports.generateTokenUri = generateTokenUri;
|
|
@@ -11,30 +11,66 @@ import { z } from "zod";
|
|
|
11
11
|
export declare const FlaunchSchema: z.ZodObject<{
|
|
12
12
|
name: z.ZodString;
|
|
13
13
|
symbol: z.ZodString;
|
|
14
|
-
|
|
14
|
+
image: z.ZodString;
|
|
15
15
|
description: z.ZodString;
|
|
16
16
|
websiteUrl: z.ZodOptional<z.ZodString>;
|
|
17
17
|
discordUrl: z.ZodOptional<z.ZodString>;
|
|
18
18
|
twitterUrl: z.ZodOptional<z.ZodString>;
|
|
19
19
|
telegramUrl: z.ZodOptional<z.ZodString>;
|
|
20
|
+
fairLaunchPercent: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
fairLaunchDuration: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
initialMarketCapUSD: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
creatorFeeAllocationPercent: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
creatorSplitPercent: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
splitReceivers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
26
|
+
address: z.ZodString;
|
|
27
|
+
percent: z.ZodNumber;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
address: string;
|
|
30
|
+
percent: number;
|
|
31
|
+
}, {
|
|
32
|
+
address: string;
|
|
33
|
+
percent: number;
|
|
34
|
+
}>, "many">>;
|
|
35
|
+
preminePercent: z.ZodDefault<z.ZodNumber>;
|
|
20
36
|
}, "strip", z.ZodTypeAny, {
|
|
21
37
|
symbol: string;
|
|
22
38
|
name: string;
|
|
23
39
|
description: string;
|
|
24
|
-
|
|
40
|
+
image: string;
|
|
41
|
+
fairLaunchPercent: number;
|
|
42
|
+
fairLaunchDuration: number;
|
|
43
|
+
initialMarketCapUSD: number;
|
|
44
|
+
creatorFeeAllocationPercent: number;
|
|
45
|
+
creatorSplitPercent: number;
|
|
46
|
+
preminePercent: number;
|
|
25
47
|
websiteUrl?: string | undefined;
|
|
26
48
|
discordUrl?: string | undefined;
|
|
27
49
|
twitterUrl?: string | undefined;
|
|
28
50
|
telegramUrl?: string | undefined;
|
|
51
|
+
splitReceivers?: {
|
|
52
|
+
address: string;
|
|
53
|
+
percent: number;
|
|
54
|
+
}[] | undefined;
|
|
29
55
|
}, {
|
|
30
56
|
symbol: string;
|
|
31
57
|
name: string;
|
|
32
58
|
description: string;
|
|
33
|
-
|
|
59
|
+
image: string;
|
|
34
60
|
websiteUrl?: string | undefined;
|
|
35
61
|
discordUrl?: string | undefined;
|
|
36
62
|
twitterUrl?: string | undefined;
|
|
37
63
|
telegramUrl?: string | undefined;
|
|
64
|
+
fairLaunchPercent?: number | undefined;
|
|
65
|
+
fairLaunchDuration?: number | undefined;
|
|
66
|
+
initialMarketCapUSD?: number | undefined;
|
|
67
|
+
creatorFeeAllocationPercent?: number | undefined;
|
|
68
|
+
creatorSplitPercent?: number | undefined;
|
|
69
|
+
splitReceivers?: {
|
|
70
|
+
address: string;
|
|
71
|
+
percent: number;
|
|
72
|
+
}[] | undefined;
|
|
73
|
+
preminePercent?: number | undefined;
|
|
38
74
|
}>;
|
|
39
75
|
export declare const BuyCoinWithETHInputSchema: z.ZodObject<{
|
|
40
76
|
coinAddress: z.ZodString;
|
|
@@ -11,16 +11,68 @@ const zod_1 = require("zod");
|
|
|
11
11
|
/**
|
|
12
12
|
* Schema for Flaunch token creation
|
|
13
13
|
*/
|
|
14
|
-
exports.FlaunchSchema = zod_1.z
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
exports.FlaunchSchema = zod_1.z
|
|
15
|
+
.object({
|
|
16
|
+
name: zod_1.z.string().min(1).describe("The name of the token to flaunch"),
|
|
17
|
+
symbol: zod_1.z.string().min(1).describe("The symbol of the token to flaunch"),
|
|
18
|
+
image: zod_1.z.string().describe("Local image file path or URL to the token image"),
|
|
19
|
+
description: zod_1.z.string().describe("Description of the token"),
|
|
20
|
+
websiteUrl: zod_1.z.string().optional().describe("URL to the token website"),
|
|
21
|
+
discordUrl: zod_1.z.string().optional().describe("URL to the token Discord"),
|
|
22
|
+
twitterUrl: zod_1.z.string().optional().describe("URL to the token Twitter"),
|
|
23
|
+
telegramUrl: zod_1.z.string().optional().describe("URL to the token Telegram"),
|
|
24
|
+
fairLaunchPercent: zod_1.z
|
|
25
|
+
.number()
|
|
26
|
+
.min(0)
|
|
27
|
+
.max(100)
|
|
28
|
+
.default(60)
|
|
29
|
+
.describe("The percentage of tokens for fair launch (defaults to 60%)"),
|
|
30
|
+
fairLaunchDuration: zod_1.z
|
|
31
|
+
.number()
|
|
32
|
+
.min(0)
|
|
33
|
+
.default(30)
|
|
34
|
+
.describe("The duration of the fair launch in minutes (defaults to 30 minutes)"),
|
|
35
|
+
initialMarketCapUSD: zod_1.z
|
|
36
|
+
.number()
|
|
37
|
+
.min(100)
|
|
38
|
+
.max(100000)
|
|
39
|
+
.default(10000)
|
|
40
|
+
.describe("The initial market cap in USD (defaults to 10000 USD)"),
|
|
41
|
+
creatorFeeAllocationPercent: zod_1.z
|
|
42
|
+
.number()
|
|
43
|
+
.min(0)
|
|
44
|
+
.max(100)
|
|
45
|
+
.default(80)
|
|
46
|
+
.describe("The percentage of the fees allocated to the creator and optional additional receivers (defaults to 80%). Remainder goes to community via token buy backs"),
|
|
47
|
+
creatorSplitPercent: zod_1.z
|
|
48
|
+
.number()
|
|
49
|
+
.min(0)
|
|
50
|
+
.max(100)
|
|
51
|
+
.default(100)
|
|
52
|
+
.describe("The percentage of the fees allocated to the creator. Defaults to 100%, set to smaller value if fees are to be distributed to additional receivers"),
|
|
53
|
+
splitReceivers: zod_1.z
|
|
54
|
+
.array(zod_1.z.object({
|
|
55
|
+
address: zod_1.z
|
|
56
|
+
.string()
|
|
57
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
58
|
+
.describe("The recipient's address"),
|
|
59
|
+
percent: zod_1.z
|
|
60
|
+
.number()
|
|
61
|
+
.min(0)
|
|
62
|
+
.max(100)
|
|
63
|
+
.describe("The percentage share for the recipient. All split receiver percentages must add up to 100%"),
|
|
64
|
+
}))
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("The recipients for the fee split (optional)"),
|
|
67
|
+
preminePercent: zod_1.z
|
|
68
|
+
.number()
|
|
69
|
+
.min(0)
|
|
70
|
+
.max(100)
|
|
71
|
+
.default(0)
|
|
72
|
+
.describe("The percentage of total supply to premine (defaults to 0%, max is equal to fairLaunchPercent)"),
|
|
73
|
+
})
|
|
74
|
+
.strip()
|
|
75
|
+
.describe("Instructions for creating a new memecoin using the flaunch protocol.");
|
|
24
76
|
exports.BuyCoinWithETHInputSchema = zod_1.z.object({
|
|
25
77
|
coinAddress: zod_1.z
|
|
26
78
|
.string()
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { Address, Hex, TransactionReceipt } from "viem";
|
|
2
2
|
import { BuySwapAmounts, SellSwapAmounts, PermitSingle, PoolSwapEventArgs } from "./types";
|
|
3
|
-
|
|
4
|
-
* Configuration for Pinata
|
|
5
|
-
*/
|
|
6
|
-
interface PinataConfig {
|
|
7
|
-
jwt: string;
|
|
8
|
-
}
|
|
9
|
-
interface TokenUriParams {
|
|
10
|
-
metadata: {
|
|
11
|
-
imageUrl: string;
|
|
12
|
-
description: string;
|
|
13
|
-
websiteUrl?: string;
|
|
14
|
-
discordUrl?: string;
|
|
15
|
-
twitterUrl?: string;
|
|
16
|
-
telegramUrl?: string;
|
|
17
|
-
};
|
|
18
|
-
pinataConfig: PinataConfig;
|
|
19
|
-
}
|
|
20
|
-
export declare const generateTokenUri: (name: string, params: TokenUriParams) => Promise<string>;
|
|
3
|
+
import { EvmWalletProvider } from "../../wallet-providers";
|
|
21
4
|
export declare const getAmountWithSlippage: (amount: bigint | undefined, slippage: string, swapType: "EXACT_IN" | "EXACT_OUT") => bigint;
|
|
22
5
|
export declare const ethToMemecoin: (params: {
|
|
23
6
|
sender: Address;
|
|
@@ -57,4 +40,19 @@ export declare const getSwapAmountsFromReceipt: ({ receipt, coinAddress, chainId
|
|
|
57
40
|
coinAddress: Address;
|
|
58
41
|
chainId: number;
|
|
59
42
|
}) => BuySwapAmounts | SellSwapAmounts;
|
|
60
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Buys a flaunch coin using ETH input.
|
|
45
|
+
*
|
|
46
|
+
* @param walletProvider - The wallet provider instance for blockchain interactions
|
|
47
|
+
* @param coinAddress - The address of the coin to buy
|
|
48
|
+
* @param swapType - The type of swap to perform
|
|
49
|
+
* @param swapParams - The parameters for the swap
|
|
50
|
+
* @param swapParams.amountIn - The amount of ETH to spend (for EXACT_IN)
|
|
51
|
+
* @param swapParams.amountOut - The amount of coins to buy (for EXACT_OUT)
|
|
52
|
+
* @param slippagePercent - The slippage percentage
|
|
53
|
+
* @returns A promise that resolves to a string describing the transaction result
|
|
54
|
+
*/
|
|
55
|
+
export declare function buyFlaunchCoin(walletProvider: EvmWalletProvider, coinAddress: string, swapType: "EXACT_IN" | "EXACT_OUT", swapParams: {
|
|
56
|
+
amountIn?: string;
|
|
57
|
+
amountOut?: string;
|
|
58
|
+
}, slippagePercent: number): Promise<string>;
|