@zoralabs/coins-sdk 0.2.10 → 0.3.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 +60 -0
- package/dist/actions/createCoin.d.ts +52 -21
- package/dist/actions/createCoin.d.ts.map +1 -1
- package/dist/api/create.d.ts +8 -0
- package/dist/api/create.d.ts.map +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/pool-config.d.ts +5 -0
- package/dist/api/pool-config.d.ts.map +1 -0
- package/dist/api/queries.d.ts +9 -1
- package/dist/api/queries.d.ts.map +1 -1
- package/dist/client/sdk.gen.d.ts +307 -46
- package/dist/client/sdk.gen.d.ts.map +1 -1
- package/dist/client/types.gen.d.ts +874 -93
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/index.cjs +419 -424
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +413 -418
- package/dist/index.js.map +1 -1
- package/dist/uploader/metadata.d.ts.map +1 -1
- package/dist/uploader/types.d.ts +4 -1
- package/dist/uploader/types.d.ts.map +1 -1
- package/dist/utils/rethrowDecodedRevert.d.ts +3 -0
- package/dist/utils/rethrowDecodedRevert.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/actions/createCoin.ts +154 -112
- package/src/api/create.ts +24 -0
- package/src/api/index.ts +8 -0
- package/src/api/pool-config.ts +17 -0
- package/src/api/queries.ts +36 -0
- package/src/client/sdk.gen.ts +98 -0
- package/src/client/types.gen.ts +898 -93
- package/src/index.ts +4 -6
- package/src/uploader/metadata.ts +4 -1
- package/src/uploader/types.ts +4 -1
- package/src/utils/rethrowDecodedRevert.ts +50 -0
- package/dist/actions/getOnchainCoinDetails.d.ts +0 -32
- package/dist/actions/getOnchainCoinDetails.d.ts.map +0 -1
- package/dist/utils/getPrepurchaseHook.d.ts +0 -16
- package/dist/utils/getPrepurchaseHook.d.ts.map +0 -1
- package/src/actions/getOnchainCoinDetails.ts +0 -68
- package/src/utils/getPrepurchaseHook.ts +0 -59
package/dist/index.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
// src/actions/createCoin.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
coinFactoryAddress,
|
|
4
|
+
coinFactoryABI as zoraFactoryImplABI
|
|
5
|
+
} from "@zoralabs/protocol-deployments";
|
|
3
6
|
import {
|
|
4
7
|
parseEventLogs,
|
|
5
|
-
|
|
6
|
-
keccak256 as keccak2562,
|
|
7
|
-
toBytes
|
|
8
|
+
isAddressEqual
|
|
8
9
|
} from "viem";
|
|
9
|
-
import { base as
|
|
10
|
-
|
|
11
|
-
// src/constants.ts
|
|
12
|
-
import { coinFactoryAddress as zoraFactoryImplAddress } from "@zoralabs/protocol-deployments";
|
|
13
|
-
import { base } from "viem/chains";
|
|
14
|
-
var COIN_FACTORY_ADDRESS = zoraFactoryImplAddress["8453"];
|
|
15
|
-
var USDC_WETH_POOLS_BY_CHAIN = {
|
|
16
|
-
[base.id]: "0xd0b53D9277642d899DF5C87A3966A349A798F224"
|
|
17
|
-
};
|
|
10
|
+
import { base as base3 } from "viem/chains";
|
|
18
11
|
|
|
19
12
|
// src/utils/validateClientNetwork.ts
|
|
20
|
-
import { base
|
|
13
|
+
import { base, baseSepolia } from "viem/chains";
|
|
21
14
|
var validateClientNetwork = (publicClient) => {
|
|
22
15
|
const clientChainId = publicClient?.chain?.id;
|
|
23
|
-
if (clientChainId ===
|
|
16
|
+
if (clientChainId === base.id) {
|
|
24
17
|
return;
|
|
25
18
|
}
|
|
26
19
|
if (clientChainId === baseSepolia.id) {
|
|
@@ -126,324 +119,18 @@ async function validateMetadataURIContent(metadataURI) {
|
|
|
126
119
|
return validateMetadataJSON(metadataJson);
|
|
127
120
|
}
|
|
128
121
|
|
|
129
|
-
// src/utils/attribution.ts
|
|
130
|
-
import { keccak256, slice, toHex } from "viem";
|
|
131
|
-
function getAttribution() {
|
|
132
|
-
const hash = keccak256(toHex("api-sdk.zora.engineering"));
|
|
133
|
-
return slice(hash, 0, 4);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/utils/poolConfigUtils.ts
|
|
137
|
-
import { encodeMultiCurvePoolConfig } from "@zoralabs/protocol-deployments";
|
|
138
|
-
import { parseUnits, zeroAddress } from "viem";
|
|
139
|
-
import { base as base3, baseSepolia as baseSepolia2 } from "viem/chains";
|
|
140
|
-
var ZORA_DECIMALS = 18;
|
|
141
|
-
var ZORA_ADDRESS = "0x1111111111166b7fe7bd91427724b487980afc69";
|
|
142
|
-
var COIN_ETH_PAIR_LOWER_TICK = -25e4;
|
|
143
|
-
var COIN_ETH_PAIR_UPPER_TICK = -195e3;
|
|
144
|
-
var COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
145
|
-
var COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits("0.05", 18);
|
|
146
|
-
var COIN_ETH_PAIR_POOL_CONFIG = {
|
|
147
|
-
[base3.id]: encodeMultiCurvePoolConfig({
|
|
148
|
-
currency: zeroAddress,
|
|
149
|
-
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
150
|
-
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
151
|
-
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
152
|
-
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
153
|
-
}),
|
|
154
|
-
[baseSepolia2.id]: encodeMultiCurvePoolConfig({
|
|
155
|
-
currency: zeroAddress,
|
|
156
|
-
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
157
|
-
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
158
|
-
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
159
|
-
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
160
|
-
})
|
|
161
|
-
};
|
|
162
|
-
var COIN_ZORA_PAIR_LOWER_TICK = -138e3;
|
|
163
|
-
var COIN_ZORA_PAIR_UPPER_TICK = -81e3;
|
|
164
|
-
var COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
165
|
-
var COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits(
|
|
166
|
-
"0.05",
|
|
167
|
-
ZORA_DECIMALS
|
|
168
|
-
);
|
|
169
|
-
var COIN_ZORA_PAIR_POOL_CONFIG = {
|
|
170
|
-
[base3.id]: encodeMultiCurvePoolConfig({
|
|
171
|
-
currency: ZORA_ADDRESS,
|
|
172
|
-
tickLower: [COIN_ZORA_PAIR_LOWER_TICK],
|
|
173
|
-
tickUpper: [COIN_ZORA_PAIR_UPPER_TICK],
|
|
174
|
-
numDiscoveryPositions: [COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
175
|
-
maxDiscoverySupplyShare: [COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
176
|
-
})
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// src/utils/getPrepurchaseHook.ts
|
|
180
|
-
import {
|
|
181
|
-
encodeBuySupplyWithMultiHopSwapRouterHookCall,
|
|
182
|
-
wethAddress
|
|
183
|
-
} from "@zoralabs/protocol-deployments";
|
|
184
|
-
import { concat, pad, toHex as toHex2 } from "viem";
|
|
185
|
-
import { base as base4 } from "viem/chains";
|
|
186
|
-
var BASE_UDSC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
187
|
-
var USDC_ZORA_FEE = 3e3;
|
|
188
|
-
var WETH_BASE_FEE = 3e3;
|
|
189
|
-
var encodeFee = (fee) => pad(toHex2(fee), { size: 3 });
|
|
190
|
-
var getPrepurchaseHook = async ({
|
|
191
|
-
payoutRecipient,
|
|
192
|
-
initialPurchase,
|
|
193
|
-
chainId
|
|
194
|
-
}) => {
|
|
195
|
-
if (initialPurchase.currency !== 1 /* ETH */ && chainId !== base4.id) {
|
|
196
|
-
throw new Error("Initial purchase currency and/or chain not supported");
|
|
197
|
-
}
|
|
198
|
-
const path = concat([
|
|
199
|
-
wethAddress[base4.id],
|
|
200
|
-
encodeFee(WETH_BASE_FEE),
|
|
201
|
-
BASE_UDSC_ADDRESS,
|
|
202
|
-
encodeFee(USDC_ZORA_FEE),
|
|
203
|
-
ZORA_ADDRESS
|
|
204
|
-
]);
|
|
205
|
-
return encodeBuySupplyWithMultiHopSwapRouterHookCall({
|
|
206
|
-
ethValue: initialPurchase.amount,
|
|
207
|
-
buyRecipient: payoutRecipient,
|
|
208
|
-
exactInputParams: {
|
|
209
|
-
path,
|
|
210
|
-
amountIn: initialPurchase.amount,
|
|
211
|
-
amountOutMinimum: initialPurchase.amountOutMinimum || 0n
|
|
212
|
-
},
|
|
213
|
-
chainId: base4.id
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
|
|
217
122
|
// src/utils/getChainFromId.ts
|
|
218
|
-
import { base as
|
|
123
|
+
import { base as base2, baseSepolia as baseSepolia2 } from "viem/chains";
|
|
219
124
|
function getChainFromId(chainId) {
|
|
220
|
-
if (chainId ===
|
|
221
|
-
return
|
|
125
|
+
if (chainId === base2.id) {
|
|
126
|
+
return base2;
|
|
222
127
|
}
|
|
223
|
-
if (chainId ===
|
|
224
|
-
return
|
|
128
|
+
if (chainId === baseSepolia2.id) {
|
|
129
|
+
return baseSepolia2;
|
|
225
130
|
}
|
|
226
131
|
throw new Error(`Chain ID ${chainId} not supported`);
|
|
227
132
|
}
|
|
228
133
|
|
|
229
|
-
// src/actions/createCoin.ts
|
|
230
|
-
var DeployCurrency = /* @__PURE__ */ ((DeployCurrency2) => {
|
|
231
|
-
DeployCurrency2[DeployCurrency2["ZORA"] = 1] = "ZORA";
|
|
232
|
-
DeployCurrency2[DeployCurrency2["ETH"] = 2] = "ETH";
|
|
233
|
-
return DeployCurrency2;
|
|
234
|
-
})(DeployCurrency || {});
|
|
235
|
-
var InitialPurchaseCurrency = /* @__PURE__ */ ((InitialPurchaseCurrency2) => {
|
|
236
|
-
InitialPurchaseCurrency2[InitialPurchaseCurrency2["ETH"] = 1] = "ETH";
|
|
237
|
-
return InitialPurchaseCurrency2;
|
|
238
|
-
})(InitialPurchaseCurrency || {});
|
|
239
|
-
function getPoolConfig(currency, chainId) {
|
|
240
|
-
if (currency === 1 /* ZORA */ && chainId == baseSepolia4.id) {
|
|
241
|
-
throw new Error("ZORA is not supported on Base Sepolia");
|
|
242
|
-
}
|
|
243
|
-
switch (currency) {
|
|
244
|
-
case 1 /* ZORA */:
|
|
245
|
-
return COIN_ZORA_PAIR_POOL_CONFIG[chainId];
|
|
246
|
-
case 2 /* ETH */:
|
|
247
|
-
return COIN_ETH_PAIR_POOL_CONFIG[chainId];
|
|
248
|
-
default:
|
|
249
|
-
throw new Error("Invalid currency");
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
async function createCoinCall({
|
|
253
|
-
name,
|
|
254
|
-
symbol,
|
|
255
|
-
uri,
|
|
256
|
-
owners,
|
|
257
|
-
payoutRecipient,
|
|
258
|
-
currency,
|
|
259
|
-
chainId = base6.id,
|
|
260
|
-
platformReferrer = "0x0000000000000000000000000000000000000000",
|
|
261
|
-
initialPurchase
|
|
262
|
-
}) {
|
|
263
|
-
if (!owners) {
|
|
264
|
-
owners = [payoutRecipient];
|
|
265
|
-
}
|
|
266
|
-
if (!currency) {
|
|
267
|
-
currency = chainId !== base6.id ? 2 /* ETH */ : 1 /* ZORA */;
|
|
268
|
-
}
|
|
269
|
-
const poolConfig = getPoolConfig(currency, chainId);
|
|
270
|
-
await validateMetadataURIContent(uri);
|
|
271
|
-
let deployHook = {
|
|
272
|
-
hook: zeroAddress2,
|
|
273
|
-
hookData: "0x",
|
|
274
|
-
value: 0n
|
|
275
|
-
};
|
|
276
|
-
if (initialPurchase) {
|
|
277
|
-
deployHook = await getPrepurchaseHook({
|
|
278
|
-
initialPurchase,
|
|
279
|
-
payoutRecipient,
|
|
280
|
-
chainId
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
return {
|
|
284
|
-
abi: zoraFactoryImplABI,
|
|
285
|
-
functionName: "deploy",
|
|
286
|
-
address: COIN_FACTORY_ADDRESS,
|
|
287
|
-
args: [
|
|
288
|
-
payoutRecipient,
|
|
289
|
-
owners,
|
|
290
|
-
uri,
|
|
291
|
-
name,
|
|
292
|
-
symbol,
|
|
293
|
-
poolConfig,
|
|
294
|
-
platformReferrer,
|
|
295
|
-
deployHook.hook,
|
|
296
|
-
deployHook.hookData,
|
|
297
|
-
keccak2562(toBytes(Math.random().toString()))
|
|
298
|
-
// coinSalt
|
|
299
|
-
],
|
|
300
|
-
value: deployHook.value,
|
|
301
|
-
dataSuffix: getAttribution()
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
function getCoinCreateFromLogs(receipt) {
|
|
305
|
-
const eventLogs = parseEventLogs({
|
|
306
|
-
abi: zoraFactoryImplABI,
|
|
307
|
-
logs: receipt.logs
|
|
308
|
-
});
|
|
309
|
-
return eventLogs.find((log) => log.eventName === "CoinCreatedV4")?.args;
|
|
310
|
-
}
|
|
311
|
-
async function createCoin(call, walletClient, publicClient, options) {
|
|
312
|
-
validateClientNetwork(publicClient);
|
|
313
|
-
const createCoinRequest = await createCoinCall(call);
|
|
314
|
-
const { request } = await publicClient.simulateContract({
|
|
315
|
-
...createCoinRequest,
|
|
316
|
-
account: options?.account ?? walletClient.account
|
|
317
|
-
});
|
|
318
|
-
if (request.gas) {
|
|
319
|
-
request.gas = request.gas * BigInt(options?.gasMultiplier ?? 100) / 100n;
|
|
320
|
-
}
|
|
321
|
-
const hash = await walletClient.writeContract(request);
|
|
322
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
323
|
-
const deployment = getCoinCreateFromLogs(receipt);
|
|
324
|
-
return {
|
|
325
|
-
hash,
|
|
326
|
-
receipt,
|
|
327
|
-
address: deployment?.coin,
|
|
328
|
-
deployment,
|
|
329
|
-
chain: getChainFromId(publicClient.chain.id)
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// src/actions/getOnchainCoinDetails.ts
|
|
334
|
-
import { coinABI } from "@zoralabs/protocol-deployments";
|
|
335
|
-
import { zeroAddress as zeroAddress3 } from "viem";
|
|
336
|
-
async function getOnchainCoinDetails({
|
|
337
|
-
coin,
|
|
338
|
-
user = zeroAddress3,
|
|
339
|
-
publicClient
|
|
340
|
-
}) {
|
|
341
|
-
validateClientNetwork(publicClient);
|
|
342
|
-
const [balance, owners, payoutRecipient] = await publicClient.multicall({
|
|
343
|
-
contracts: [
|
|
344
|
-
{
|
|
345
|
-
address: coin,
|
|
346
|
-
abi: coinABI,
|
|
347
|
-
functionName: "balanceOf",
|
|
348
|
-
args: [user]
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
address: coin,
|
|
352
|
-
abi: coinABI,
|
|
353
|
-
functionName: "owners"
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
address: coin,
|
|
357
|
-
abi: coinABI,
|
|
358
|
-
functionName: "payoutRecipient"
|
|
359
|
-
}
|
|
360
|
-
],
|
|
361
|
-
allowFailure: false
|
|
362
|
-
});
|
|
363
|
-
return {
|
|
364
|
-
balance,
|
|
365
|
-
owners,
|
|
366
|
-
payoutRecipient
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// src/actions/updateCoinURI.ts
|
|
371
|
-
import { coinABI as coinABI2 } from "@zoralabs/protocol-deployments";
|
|
372
|
-
import {
|
|
373
|
-
parseEventLogs as parseEventLogs2
|
|
374
|
-
} from "viem";
|
|
375
|
-
function updateCoinURICall({
|
|
376
|
-
newURI,
|
|
377
|
-
coin
|
|
378
|
-
}) {
|
|
379
|
-
if (!newURI.startsWith("ipfs://")) {
|
|
380
|
-
throw new Error("URI needs to be an ipfs:// prefix uri");
|
|
381
|
-
}
|
|
382
|
-
return {
|
|
383
|
-
abi: coinABI2,
|
|
384
|
-
address: coin,
|
|
385
|
-
functionName: "setContractURI",
|
|
386
|
-
args: [newURI],
|
|
387
|
-
dataSuffix: getAttribution()
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
async function updateCoinURI(args, walletClient, publicClient) {
|
|
391
|
-
validateClientNetwork(publicClient);
|
|
392
|
-
const call = updateCoinURICall(args);
|
|
393
|
-
const { request } = await publicClient.simulateContract({
|
|
394
|
-
...call,
|
|
395
|
-
account: walletClient.account
|
|
396
|
-
});
|
|
397
|
-
const hash = await walletClient.writeContract(request);
|
|
398
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
399
|
-
const eventLogs = parseEventLogs2({ abi: coinABI2, logs: receipt.logs });
|
|
400
|
-
const uriUpdated = eventLogs.find(
|
|
401
|
-
(log) => log.eventName === "ContractURIUpdated"
|
|
402
|
-
);
|
|
403
|
-
return { hash, receipt, uriUpdated };
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// src/actions/updatePayoutRecipient.ts
|
|
407
|
-
import { coinABI as coinABI3 } from "@zoralabs/protocol-deployments";
|
|
408
|
-
import {
|
|
409
|
-
parseEventLogs as parseEventLogs3
|
|
410
|
-
} from "viem";
|
|
411
|
-
function updatePayoutRecipientCall({
|
|
412
|
-
newPayoutRecipient,
|
|
413
|
-
coin
|
|
414
|
-
}) {
|
|
415
|
-
return {
|
|
416
|
-
abi: coinABI3,
|
|
417
|
-
address: coin,
|
|
418
|
-
functionName: "setPayoutRecipient",
|
|
419
|
-
args: [newPayoutRecipient],
|
|
420
|
-
dataSuffix: getAttribution()
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
async function updatePayoutRecipient(args, walletClient, publicClient) {
|
|
424
|
-
validateClientNetwork(publicClient);
|
|
425
|
-
const call = updatePayoutRecipientCall(args);
|
|
426
|
-
const { request } = await publicClient.simulateContract({
|
|
427
|
-
...call,
|
|
428
|
-
account: walletClient.account
|
|
429
|
-
});
|
|
430
|
-
const hash = await walletClient.writeContract(request);
|
|
431
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
432
|
-
const eventLogs = parseEventLogs3({ abi: coinABI3, logs: receipt.logs });
|
|
433
|
-
const payoutRecipientUpdated = eventLogs.find(
|
|
434
|
-
(log) => log.eventName === "CoinPayoutRecipientUpdated"
|
|
435
|
-
);
|
|
436
|
-
return { hash, receipt, payoutRecipientUpdated };
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// src/actions/tradeCoin.ts
|
|
440
|
-
import { permit2ABI, permit2Address } from "@zoralabs/protocol-deployments";
|
|
441
|
-
import {
|
|
442
|
-
erc20Abi,
|
|
443
|
-
maxUint256
|
|
444
|
-
} from "viem";
|
|
445
|
-
import { base as base7 } from "viem/chains";
|
|
446
|
-
|
|
447
134
|
// src/client/client.gen.ts
|
|
448
135
|
import {
|
|
449
136
|
createClient,
|
|
@@ -480,6 +167,30 @@ var getCoinComments = (options) => {
|
|
|
480
167
|
...options
|
|
481
168
|
});
|
|
482
169
|
};
|
|
170
|
+
var getCoinHolders = (options) => {
|
|
171
|
+
return (options.client ?? client).get({
|
|
172
|
+
security: [
|
|
173
|
+
{
|
|
174
|
+
name: "api-key",
|
|
175
|
+
type: "apiKey"
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
url: "/coinHolders",
|
|
179
|
+
...options
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
var getCoinSwaps = (options) => {
|
|
183
|
+
return (options.client ?? client).get({
|
|
184
|
+
security: [
|
|
185
|
+
{
|
|
186
|
+
name: "api-key",
|
|
187
|
+
type: "apiKey"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
url: "/coinSwaps",
|
|
191
|
+
...options
|
|
192
|
+
});
|
|
193
|
+
};
|
|
483
194
|
var getCoins = (options) => {
|
|
484
195
|
return (options.client ?? client).get({
|
|
485
196
|
security: [
|
|
@@ -572,8 +283,369 @@ var postQuote = (options) => {
|
|
|
572
283
|
}
|
|
573
284
|
});
|
|
574
285
|
};
|
|
286
|
+
var postCreateContent = (options) => {
|
|
287
|
+
return (options?.client ?? client).post({
|
|
288
|
+
security: [
|
|
289
|
+
{
|
|
290
|
+
name: "api-key",
|
|
291
|
+
type: "apiKey"
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
url: "/create/content",
|
|
295
|
+
...options,
|
|
296
|
+
headers: {
|
|
297
|
+
"Content-Type": "application/json",
|
|
298
|
+
...options?.headers
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// src/api/api-key.ts
|
|
304
|
+
var apiKey;
|
|
305
|
+
function setApiKey(key) {
|
|
306
|
+
apiKey = key;
|
|
307
|
+
}
|
|
308
|
+
function getApiKey() {
|
|
309
|
+
return apiKey;
|
|
310
|
+
}
|
|
311
|
+
function getApiKeyMeta() {
|
|
312
|
+
if (!apiKey) {
|
|
313
|
+
return {};
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
headers: {
|
|
317
|
+
"api-key": apiKey
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// src/api/explore.ts
|
|
323
|
+
var createExploreQuery = (query, listType, options) => getExplore({
|
|
324
|
+
...options,
|
|
325
|
+
query: { ...query, listType },
|
|
326
|
+
...getApiKeyMeta()
|
|
327
|
+
});
|
|
328
|
+
var getCoinsTopGainers = (query = {}, options) => createExploreQuery(query, "TOP_GAINERS", options);
|
|
329
|
+
var getCoinsTopVolume24h = (query = {}, options) => createExploreQuery(query, "TOP_VOLUME_24H", options);
|
|
330
|
+
var getCoinsMostValuable = (query = {}, options) => createExploreQuery(query, "MOST_VALUABLE", options);
|
|
331
|
+
var getCoinsNew = (query = {}, options) => createExploreQuery(query, "NEW", options);
|
|
332
|
+
var getCoinsLastTraded = (query = {}, options) => createExploreQuery(query, "LAST_TRADED", options);
|
|
333
|
+
var getCoinsLastTradedUnique = (query = {}, options) => createExploreQuery(query, "LAST_TRADED_UNIQUE", options);
|
|
334
|
+
var getCreatorCoins = (query = {}, options) => createExploreQuery(query, "NEW_CREATORS", options);
|
|
335
|
+
var getMostValuableCreatorCoins = (query = {}, options) => createExploreQuery(query, "MOST_VALUABLE_CREATORS", options);
|
|
336
|
+
|
|
337
|
+
// src/api/queries.ts
|
|
338
|
+
var getCoin2 = async (query, options) => {
|
|
339
|
+
return await getCoin({
|
|
340
|
+
...options,
|
|
341
|
+
query,
|
|
342
|
+
...getApiKeyMeta()
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
var getCoins2 = async (query, options) => {
|
|
346
|
+
return await getCoins({
|
|
347
|
+
query: {
|
|
348
|
+
coins: query.coins.map((coinData) => JSON.stringify(coinData))
|
|
349
|
+
},
|
|
350
|
+
...getApiKeyMeta(),
|
|
351
|
+
...options
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
var getCoinHolders2 = async (query, options) => {
|
|
355
|
+
return await getCoinHolders({
|
|
356
|
+
query,
|
|
357
|
+
...getApiKeyMeta(),
|
|
358
|
+
...options
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
var getCoinSwaps2 = async (query, options) => {
|
|
362
|
+
return await getCoinSwaps({
|
|
363
|
+
query,
|
|
364
|
+
...getApiKeyMeta(),
|
|
365
|
+
...options
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
var getCoinComments2 = async (query, options) => {
|
|
369
|
+
return await getCoinComments({
|
|
370
|
+
query,
|
|
371
|
+
...getApiKeyMeta(),
|
|
372
|
+
...options
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
var getProfile2 = async (query, options) => {
|
|
376
|
+
return await getProfile({
|
|
377
|
+
query,
|
|
378
|
+
...getApiKeyMeta(),
|
|
379
|
+
...options
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
var getProfileCoins2 = async (query, options) => {
|
|
383
|
+
return await getProfileCoins({
|
|
384
|
+
query,
|
|
385
|
+
...getApiKeyMeta(),
|
|
386
|
+
...options
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
var getProfileBalances2 = async (query, options) => {
|
|
390
|
+
return await getProfileBalances({
|
|
391
|
+
query,
|
|
392
|
+
...getApiKeyMeta(),
|
|
393
|
+
...options
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// src/api/create.ts
|
|
398
|
+
var postCreateContent2 = async (body, options) => {
|
|
399
|
+
return await postCreateContent({
|
|
400
|
+
...options,
|
|
401
|
+
body,
|
|
402
|
+
...getApiKeyMeta()
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
// src/utils/rethrowDecodedRevert.ts
|
|
407
|
+
import {
|
|
408
|
+
BaseError,
|
|
409
|
+
ContractFunctionRevertedError,
|
|
410
|
+
decodeErrorResult
|
|
411
|
+
} from "viem";
|
|
412
|
+
function rethrowDecodedRevert(err, abi) {
|
|
413
|
+
if (err instanceof BaseError) {
|
|
414
|
+
const revertError = err.walk(
|
|
415
|
+
(e) => e instanceof ContractFunctionRevertedError
|
|
416
|
+
);
|
|
417
|
+
if (revertError instanceof ContractFunctionRevertedError) {
|
|
418
|
+
try {
|
|
419
|
+
const revertData = typeof revertError.data === "object" && revertError.data !== null && "data" in revertError.data ? revertError.data.data : revertError.data;
|
|
420
|
+
const decoded = decodeErrorResult({
|
|
421
|
+
abi,
|
|
422
|
+
data: revertData
|
|
423
|
+
});
|
|
424
|
+
const name = decoded.errorName;
|
|
425
|
+
const args = decoded.args;
|
|
426
|
+
const message = Array.isArray(args) && args.length > 0 ? `${name}(${args.map((a) => String(a)).join(", ")})` : name;
|
|
427
|
+
throw new Error(`Create coin transaction reverted: ${message}`);
|
|
428
|
+
} catch {
|
|
429
|
+
const errorName = revertError.data?.errorName;
|
|
430
|
+
if (errorName) {
|
|
431
|
+
const args = revertError.data?.args;
|
|
432
|
+
const message = Array.isArray(args) && args.length > 0 ? `${errorName}(${args.map((a) => String(a)).join(", ")})` : errorName;
|
|
433
|
+
throw new Error(`Create coin transaction reverted: ${message}`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
throw err;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/actions/createCoin.ts
|
|
442
|
+
var STARTING_MARKET_CAPS = {
|
|
443
|
+
LOW: "LOW",
|
|
444
|
+
HIGH: "HIGH"
|
|
445
|
+
};
|
|
446
|
+
var CONTENT_COIN_CURRENCIES = {
|
|
447
|
+
CREATOR_COIN: "CREATOR_COIN",
|
|
448
|
+
ZORA: "ZORA",
|
|
449
|
+
ETH: "ETH",
|
|
450
|
+
CREATOR_COIN_OR_ZORA: "CREATOR_COIN_OR_ZORA"
|
|
451
|
+
};
|
|
452
|
+
var CreateConstants = {
|
|
453
|
+
StartingMarketCaps: STARTING_MARKET_CAPS,
|
|
454
|
+
ContentCoinCurrencies: CONTENT_COIN_CURRENCIES
|
|
455
|
+
};
|
|
456
|
+
async function createCoinCall({
|
|
457
|
+
creator,
|
|
458
|
+
name,
|
|
459
|
+
symbol,
|
|
460
|
+
metadata,
|
|
461
|
+
currency,
|
|
462
|
+
chainId = base3.id,
|
|
463
|
+
payoutRecipientOverride,
|
|
464
|
+
additionalOwners,
|
|
465
|
+
platformReferrer,
|
|
466
|
+
skipMetadataValidation = false
|
|
467
|
+
}) {
|
|
468
|
+
if (!skipMetadataValidation) {
|
|
469
|
+
await validateMetadataURIContent(metadata.uri);
|
|
470
|
+
}
|
|
471
|
+
const createContentRequest = await postCreateContent2({
|
|
472
|
+
currency,
|
|
473
|
+
chainId,
|
|
474
|
+
metadata,
|
|
475
|
+
creator,
|
|
476
|
+
name,
|
|
477
|
+
symbol,
|
|
478
|
+
platformReferrer,
|
|
479
|
+
additionalOwners,
|
|
480
|
+
payoutRecipientOverride
|
|
481
|
+
});
|
|
482
|
+
if (!createContentRequest.data?.calls) {
|
|
483
|
+
throw new Error("Failed to create content calldata");
|
|
484
|
+
}
|
|
485
|
+
return createContentRequest.data.calls.map((data) => ({
|
|
486
|
+
to: data.to,
|
|
487
|
+
data: data.data,
|
|
488
|
+
value: BigInt(data.value)
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
function getCoinCreateFromLogs(receipt) {
|
|
492
|
+
const eventLogs = parseEventLogs({
|
|
493
|
+
abi: zoraFactoryImplABI,
|
|
494
|
+
logs: receipt.logs
|
|
495
|
+
});
|
|
496
|
+
return eventLogs.find((log) => log.eventName === "CoinCreatedV4")?.args;
|
|
497
|
+
}
|
|
498
|
+
async function createCoin({
|
|
499
|
+
call,
|
|
500
|
+
walletClient,
|
|
501
|
+
publicClient,
|
|
502
|
+
options
|
|
503
|
+
}) {
|
|
504
|
+
validateClientNetwork(publicClient);
|
|
505
|
+
const callRequest = await createCoinCall(call);
|
|
506
|
+
if (callRequest.length !== 1) {
|
|
507
|
+
throw new Error("Only one call is supported for this SDK version");
|
|
508
|
+
}
|
|
509
|
+
const createContentCall = callRequest[0];
|
|
510
|
+
if (!createContentCall) {
|
|
511
|
+
throw new Error("Failed to load create content calldata from API");
|
|
512
|
+
}
|
|
513
|
+
const coinFactoryAddressForChain = coinFactoryAddress[call.chainId];
|
|
514
|
+
if (!isAddressEqual(createContentCall.to, coinFactoryAddressForChain)) {
|
|
515
|
+
throw new Error("Creator coin is not supported for this SDK version");
|
|
516
|
+
}
|
|
517
|
+
if (createContentCall.value !== 0n) {
|
|
518
|
+
throw new Error(
|
|
519
|
+
"Creator coin and purchase is not supported for this SDK version."
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
const selectedAccount = (typeof options?.account === "string" ? void 0 : options?.account) ?? walletClient.account;
|
|
523
|
+
if (!selectedAccount) {
|
|
524
|
+
throw new Error("Account is required");
|
|
525
|
+
}
|
|
526
|
+
const viemCall = {
|
|
527
|
+
...createContentCall,
|
|
528
|
+
account: selectedAccount
|
|
529
|
+
};
|
|
530
|
+
if (!options?.skipValidateTransaction) {
|
|
531
|
+
try {
|
|
532
|
+
await publicClient.call(viemCall);
|
|
533
|
+
} catch (err) {
|
|
534
|
+
rethrowDecodedRevert(err, zoraFactoryImplABI);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const gasEstimate = options?.skipValidateTransaction ? 10000000n : await publicClient.estimateGas(viemCall);
|
|
538
|
+
const gasPrice = await publicClient.getGasPrice();
|
|
539
|
+
const hash = await (async () => {
|
|
540
|
+
try {
|
|
541
|
+
return await walletClient.sendTransaction({
|
|
542
|
+
...viemCall,
|
|
543
|
+
gasPrice,
|
|
544
|
+
gas: gasEstimate,
|
|
545
|
+
chain: publicClient.chain
|
|
546
|
+
});
|
|
547
|
+
} catch (err) {
|
|
548
|
+
rethrowDecodedRevert(err, zoraFactoryImplABI);
|
|
549
|
+
}
|
|
550
|
+
})();
|
|
551
|
+
const receipt = await publicClient.waitForTransactionReceipt({
|
|
552
|
+
hash
|
|
553
|
+
});
|
|
554
|
+
const deployment = getCoinCreateFromLogs(receipt);
|
|
555
|
+
return {
|
|
556
|
+
hash,
|
|
557
|
+
receipt,
|
|
558
|
+
address: deployment?.coin,
|
|
559
|
+
deployment,
|
|
560
|
+
chain: getChainFromId(publicClient.chain.id)
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/actions/updateCoinURI.ts
|
|
565
|
+
import { coinABI } from "@zoralabs/protocol-deployments";
|
|
566
|
+
import {
|
|
567
|
+
parseEventLogs as parseEventLogs2
|
|
568
|
+
} from "viem";
|
|
569
|
+
|
|
570
|
+
// src/utils/attribution.ts
|
|
571
|
+
import { keccak256, slice, toHex } from "viem";
|
|
572
|
+
function getAttribution() {
|
|
573
|
+
const hash = keccak256(toHex("api-sdk.zora.engineering"));
|
|
574
|
+
return slice(hash, 0, 4);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/actions/updateCoinURI.ts
|
|
578
|
+
function updateCoinURICall({
|
|
579
|
+
newURI,
|
|
580
|
+
coin
|
|
581
|
+
}) {
|
|
582
|
+
if (!newURI.startsWith("ipfs://")) {
|
|
583
|
+
throw new Error("URI needs to be an ipfs:// prefix uri");
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
abi: coinABI,
|
|
587
|
+
address: coin,
|
|
588
|
+
functionName: "setContractURI",
|
|
589
|
+
args: [newURI],
|
|
590
|
+
dataSuffix: getAttribution()
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
async function updateCoinURI(args, walletClient, publicClient) {
|
|
594
|
+
validateClientNetwork(publicClient);
|
|
595
|
+
const call = updateCoinURICall(args);
|
|
596
|
+
const { request } = await publicClient.simulateContract({
|
|
597
|
+
...call,
|
|
598
|
+
account: walletClient.account
|
|
599
|
+
});
|
|
600
|
+
const hash = await walletClient.writeContract(request);
|
|
601
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
602
|
+
const eventLogs = parseEventLogs2({ abi: coinABI, logs: receipt.logs });
|
|
603
|
+
const uriUpdated = eventLogs.find(
|
|
604
|
+
(log) => log.eventName === "ContractURIUpdated"
|
|
605
|
+
);
|
|
606
|
+
return { hash, receipt, uriUpdated };
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/actions/updatePayoutRecipient.ts
|
|
610
|
+
import { coinABI as coinABI2 } from "@zoralabs/protocol-deployments";
|
|
611
|
+
import {
|
|
612
|
+
parseEventLogs as parseEventLogs3
|
|
613
|
+
} from "viem";
|
|
614
|
+
function updatePayoutRecipientCall({
|
|
615
|
+
newPayoutRecipient,
|
|
616
|
+
coin
|
|
617
|
+
}) {
|
|
618
|
+
return {
|
|
619
|
+
abi: coinABI2,
|
|
620
|
+
address: coin,
|
|
621
|
+
functionName: "setPayoutRecipient",
|
|
622
|
+
args: [newPayoutRecipient],
|
|
623
|
+
dataSuffix: getAttribution()
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
async function updatePayoutRecipient(args, walletClient, publicClient) {
|
|
627
|
+
validateClientNetwork(publicClient);
|
|
628
|
+
const call = updatePayoutRecipientCall(args);
|
|
629
|
+
const { request } = await publicClient.simulateContract({
|
|
630
|
+
...call,
|
|
631
|
+
account: walletClient.account
|
|
632
|
+
});
|
|
633
|
+
const hash = await walletClient.writeContract(request);
|
|
634
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
635
|
+
const eventLogs = parseEventLogs3({ abi: coinABI2, logs: receipt.logs });
|
|
636
|
+
const payoutRecipientUpdated = eventLogs.find(
|
|
637
|
+
(log) => log.eventName === "CoinPayoutRecipientUpdated"
|
|
638
|
+
);
|
|
639
|
+
return { hash, receipt, payoutRecipientUpdated };
|
|
640
|
+
}
|
|
575
641
|
|
|
576
642
|
// src/actions/tradeCoin.ts
|
|
643
|
+
import { permit2ABI, permit2Address } from "@zoralabs/protocol-deployments";
|
|
644
|
+
import {
|
|
645
|
+
erc20Abi,
|
|
646
|
+
maxUint256
|
|
647
|
+
} from "viem";
|
|
648
|
+
import { base as base4 } from "viem/chains";
|
|
577
649
|
function convertBigIntToString(permit) {
|
|
578
650
|
return {
|
|
579
651
|
...permit,
|
|
@@ -619,7 +691,7 @@ async function tradeCoin({
|
|
|
619
691
|
for (const permit of quote.permits) {
|
|
620
692
|
const [, , nonce] = await publicClient.readContract({
|
|
621
693
|
abi: permit2ABI,
|
|
622
|
-
address: permit2Address[
|
|
694
|
+
address: permit2Address[base4.id],
|
|
623
695
|
functionName: "allowance",
|
|
624
696
|
args: [
|
|
625
697
|
permit.permit.details.token,
|
|
@@ -634,7 +706,7 @@ async function tradeCoin({
|
|
|
634
706
|
functionName: "allowance",
|
|
635
707
|
args: [
|
|
636
708
|
typeof account === "string" ? account : account.address,
|
|
637
|
-
permit2Address[
|
|
709
|
+
permit2Address[base4.id]
|
|
638
710
|
]
|
|
639
711
|
});
|
|
640
712
|
if (allowance < BigInt(permit.permit.details.amount)) {
|
|
@@ -642,8 +714,8 @@ async function tradeCoin({
|
|
|
642
714
|
abi: erc20Abi,
|
|
643
715
|
address: permitToken,
|
|
644
716
|
functionName: "approve",
|
|
645
|
-
chain:
|
|
646
|
-
args: [permit2Address[
|
|
717
|
+
chain: base4,
|
|
718
|
+
args: [permit2Address[base4.id], maxUint256],
|
|
647
719
|
account
|
|
648
720
|
});
|
|
649
721
|
await publicClient.waitForTransactionReceipt({
|
|
@@ -663,8 +735,8 @@ async function tradeCoin({
|
|
|
663
735
|
const signature = await walletClient.signTypedData({
|
|
664
736
|
domain: {
|
|
665
737
|
name: "Permit2",
|
|
666
|
-
chainId:
|
|
667
|
-
verifyingContract: permit2Address[
|
|
738
|
+
chainId: base4.id,
|
|
739
|
+
verifyingContract: permit2Address[base4.id]
|
|
668
740
|
},
|
|
669
741
|
primaryType: "PermitSingle",
|
|
670
742
|
types: PERMIT_SINGLE_TYPES,
|
|
@@ -685,7 +757,7 @@ async function tradeCoin({
|
|
|
685
757
|
to: newQuote.call.target,
|
|
686
758
|
data: newQuote.call.data,
|
|
687
759
|
value: BigInt(newQuote.call.value),
|
|
688
|
-
chain:
|
|
760
|
+
chain: base4,
|
|
689
761
|
account
|
|
690
762
|
};
|
|
691
763
|
if (validateTransaction) {
|
|
@@ -716,7 +788,7 @@ async function createTradeCall(tradeParameters) {
|
|
|
716
788
|
tokenOut: tradeParameters.buy,
|
|
717
789
|
amountIn: tradeParameters.amountIn.toString(),
|
|
718
790
|
slippage: tradeParameters.slippage,
|
|
719
|
-
chainId:
|
|
791
|
+
chainId: base4.id,
|
|
720
792
|
sender: tradeParameters.sender,
|
|
721
793
|
recipient: tradeParameters.recipient || tradeParameters.sender,
|
|
722
794
|
signatures: tradeParameters.signatures
|
|
@@ -729,86 +801,6 @@ async function createTradeCall(tradeParameters) {
|
|
|
729
801
|
return quote.data;
|
|
730
802
|
}
|
|
731
803
|
|
|
732
|
-
// src/api/api-key.ts
|
|
733
|
-
var apiKey;
|
|
734
|
-
function setApiKey(key) {
|
|
735
|
-
apiKey = key;
|
|
736
|
-
}
|
|
737
|
-
function getApiKey() {
|
|
738
|
-
return apiKey;
|
|
739
|
-
}
|
|
740
|
-
function getApiKeyMeta() {
|
|
741
|
-
if (!apiKey) {
|
|
742
|
-
return {};
|
|
743
|
-
}
|
|
744
|
-
return {
|
|
745
|
-
headers: {
|
|
746
|
-
"api-key": apiKey
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// src/api/queries.ts
|
|
752
|
-
var getCoin2 = async (query, options) => {
|
|
753
|
-
return await getCoin({
|
|
754
|
-
...options,
|
|
755
|
-
query,
|
|
756
|
-
...getApiKeyMeta()
|
|
757
|
-
});
|
|
758
|
-
};
|
|
759
|
-
var getCoins2 = async (query, options) => {
|
|
760
|
-
return await getCoins({
|
|
761
|
-
query: {
|
|
762
|
-
coins: query.coins.map((coinData) => JSON.stringify(coinData))
|
|
763
|
-
},
|
|
764
|
-
...getApiKeyMeta(),
|
|
765
|
-
...options
|
|
766
|
-
});
|
|
767
|
-
};
|
|
768
|
-
var getCoinComments2 = async (query, options) => {
|
|
769
|
-
return await getCoinComments({
|
|
770
|
-
query,
|
|
771
|
-
...getApiKeyMeta(),
|
|
772
|
-
...options
|
|
773
|
-
});
|
|
774
|
-
};
|
|
775
|
-
var getProfile2 = async (query, options) => {
|
|
776
|
-
return await getProfile({
|
|
777
|
-
query,
|
|
778
|
-
...getApiKeyMeta(),
|
|
779
|
-
...options
|
|
780
|
-
});
|
|
781
|
-
};
|
|
782
|
-
var getProfileCoins2 = async (query, options) => {
|
|
783
|
-
return await getProfileCoins({
|
|
784
|
-
query,
|
|
785
|
-
...getApiKeyMeta(),
|
|
786
|
-
...options
|
|
787
|
-
});
|
|
788
|
-
};
|
|
789
|
-
var getProfileBalances2 = async (query, options) => {
|
|
790
|
-
return await getProfileBalances({
|
|
791
|
-
query,
|
|
792
|
-
...getApiKeyMeta(),
|
|
793
|
-
...options
|
|
794
|
-
});
|
|
795
|
-
};
|
|
796
|
-
|
|
797
|
-
// src/api/explore.ts
|
|
798
|
-
var createExploreQuery = (query, listType, options) => getExplore({
|
|
799
|
-
...options,
|
|
800
|
-
query: { ...query, listType },
|
|
801
|
-
...getApiKeyMeta()
|
|
802
|
-
});
|
|
803
|
-
var getCoinsTopGainers = (query = {}, options) => createExploreQuery(query, "TOP_GAINERS", options);
|
|
804
|
-
var getCoinsTopVolume24h = (query = {}, options) => createExploreQuery(query, "TOP_VOLUME_24H", options);
|
|
805
|
-
var getCoinsMostValuable = (query = {}, options) => createExploreQuery(query, "MOST_VALUABLE", options);
|
|
806
|
-
var getCoinsNew = (query = {}, options) => createExploreQuery(query, "NEW", options);
|
|
807
|
-
var getCoinsLastTraded = (query = {}, options) => createExploreQuery(query, "LAST_TRADED", options);
|
|
808
|
-
var getCoinsLastTradedUnique = (query = {}, options) => createExploreQuery(query, "LAST_TRADED_UNIQUE", options);
|
|
809
|
-
var getCreatorCoins = (query = {}, options) => createExploreQuery(query, "NEW_CREATORS", options);
|
|
810
|
-
var getMostValuableCreatorCoins = (query = {}, options) => createExploreQuery(query, "MOST_VALUABLE_CREATORS", options);
|
|
811
|
-
|
|
812
804
|
// src/uploader/metadata.ts
|
|
813
805
|
function validateImageMimeType(mimeType) {
|
|
814
806
|
if (![
|
|
@@ -953,7 +945,10 @@ var CoinMetadataBuilder = class {
|
|
|
953
945
|
createMetadataParameters: {
|
|
954
946
|
name: this.name,
|
|
955
947
|
symbol: this.symbol,
|
|
956
|
-
|
|
948
|
+
metadata: {
|
|
949
|
+
type: "RAW_URI",
|
|
950
|
+
uri: uploadResult.url
|
|
951
|
+
}
|
|
957
952
|
},
|
|
958
953
|
metadata
|
|
959
954
|
};
|
|
@@ -1026,8 +1021,7 @@ function createZoraUploaderForCreator(creatorAddress) {
|
|
|
1026
1021
|
}
|
|
1027
1022
|
export {
|
|
1028
1023
|
CoinMetadataBuilder,
|
|
1029
|
-
|
|
1030
|
-
InitialPurchaseCurrency,
|
|
1024
|
+
CreateConstants,
|
|
1031
1025
|
ZoraUploader,
|
|
1032
1026
|
cleanAndValidateMetadataURI,
|
|
1033
1027
|
createCoin,
|
|
@@ -1038,6 +1032,8 @@ export {
|
|
|
1038
1032
|
getCoin2 as getCoin,
|
|
1039
1033
|
getCoinComments2 as getCoinComments,
|
|
1040
1034
|
getCoinCreateFromLogs,
|
|
1035
|
+
getCoinHolders2 as getCoinHolders,
|
|
1036
|
+
getCoinSwaps2 as getCoinSwaps,
|
|
1041
1037
|
getCoins2 as getCoins,
|
|
1042
1038
|
getCoinsLastTraded,
|
|
1043
1039
|
getCoinsLastTradedUnique,
|
|
@@ -1047,7 +1043,6 @@ export {
|
|
|
1047
1043
|
getCoinsTopVolume24h,
|
|
1048
1044
|
getCreatorCoins,
|
|
1049
1045
|
getMostValuableCreatorCoins,
|
|
1050
|
-
getOnchainCoinDetails,
|
|
1051
1046
|
getProfile2 as getProfile,
|
|
1052
1047
|
getProfileBalances2 as getProfileBalances,
|
|
1053
1048
|
getProfileCoins2 as getProfileCoins,
|