@zoralabs/coins-sdk 0.2.11 → 0.3.1

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/actions/createCoin.d.ts +52 -21
  3. package/dist/actions/createCoin.d.ts.map +1 -1
  4. package/dist/actions/updateCoinURI.d.ts +2 -2
  5. package/dist/actions/updateCoinURI.d.ts.map +1 -1
  6. package/dist/actions/updatePayoutRecipient.d.ts +2 -2
  7. package/dist/actions/updatePayoutRecipient.d.ts.map +1 -1
  8. package/dist/api/create.d.ts +8 -0
  9. package/dist/api/create.d.ts.map +1 -0
  10. package/dist/api/index.d.ts +4 -0
  11. package/dist/api/index.d.ts.map +1 -1
  12. package/dist/api/pool-config.d.ts +5 -0
  13. package/dist/api/pool-config.d.ts.map +1 -0
  14. package/dist/client/sdk.gen.d.ts +194 -1
  15. package/dist/client/sdk.gen.d.ts.map +1 -1
  16. package/dist/client/types.gen.d.ts +567 -0
  17. package/dist/client/types.gen.d.ts.map +1 -1
  18. package/dist/index.cjs +423 -464
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +2 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +393 -434
  23. package/dist/index.js.map +1 -1
  24. package/dist/uploader/metadata.d.ts.map +1 -1
  25. package/dist/uploader/types.d.ts +4 -1
  26. package/dist/uploader/types.d.ts.map +1 -1
  27. package/dist/utils/rethrowDecodedRevert.d.ts +3 -0
  28. package/dist/utils/rethrowDecodedRevert.d.ts.map +1 -0
  29. package/package.json +2 -1
  30. package/src/actions/createCoin.ts +158 -111
  31. package/src/actions/tradeCoin.ts +2 -2
  32. package/src/actions/updateCoinURI.ts +3 -1
  33. package/src/actions/updatePayoutRecipient.ts +3 -1
  34. package/src/api/create.ts +24 -0
  35. package/src/api/index.ts +8 -0
  36. package/src/api/pool-config.ts +17 -0
  37. package/src/client/sdk.gen.ts +50 -0
  38. package/src/client/types.gen.ts +581 -0
  39. package/src/index.ts +4 -6
  40. package/src/uploader/metadata.ts +4 -1
  41. package/src/uploader/types.ts +4 -1
  42. package/src/utils/rethrowDecodedRevert.ts +50 -0
  43. package/dist/actions/getOnchainCoinDetails.d.ts +0 -32
  44. package/dist/actions/getOnchainCoinDetails.d.ts.map +0 -1
  45. package/dist/utils/getPrepurchaseHook.d.ts +0 -16
  46. package/dist/utils/getPrepurchaseHook.d.ts.map +0 -1
  47. package/src/actions/getOnchainCoinDetails.ts +0 -68
  48. package/src/utils/getPrepurchaseHook.ts +0 -59
package/dist/index.cjs CHANGED
@@ -1,21 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/actions/createCoin.ts
2
- var _protocoldeployments = require('@zoralabs/protocol-deployments');
3
2
 
4
3
 
5
4
 
5
+ var _protocoldeployments = require('@zoralabs/protocol-deployments');
6
+
6
7
 
7
8
 
8
9
  var _viem = require('viem');
9
10
  var _chains = require('viem/chains');
10
11
 
11
- // src/constants.ts
12
-
13
-
14
- var COIN_FACTORY_ADDRESS = _protocoldeployments.coinFactoryAddress["8453"];
15
- var USDC_WETH_POOLS_BY_CHAIN = {
16
- [_chains.base.id]: "0xd0b53D9277642d899DF5C87A3966A349A798F224"
17
- };
18
-
19
12
  // src/utils/validateClientNetwork.ts
20
13
 
21
14
  var validateClientNetwork = (publicClient) => {
@@ -126,252 +119,466 @@ async function validateMetadataURIContent(metadataURI) {
126
119
  return validateMetadataJSON(metadataJson);
127
120
  }
128
121
 
129
- // src/utils/attribution.ts
122
+ // src/utils/getChainFromId.ts
130
123
 
131
- function getAttribution() {
132
- const hash = _viem.keccak256.call(void 0, _viem.toHex.call(void 0, "api-sdk.zora.engineering"));
133
- return _viem.slice.call(void 0, hash, 0, 4);
124
+ function getChainFromId(chainId) {
125
+ if (chainId === _chains.base.id) {
126
+ return _chains.base;
127
+ }
128
+ if (chainId === _chains.baseSepolia.id) {
129
+ return _chains.baseSepolia;
130
+ }
131
+ throw new Error(`Chain ID ${chainId} not supported`);
134
132
  }
135
133
 
136
- // src/utils/poolConfigUtils.ts
137
-
138
-
139
-
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 = _viem.parseUnits.call(void 0, "0.05", 18);
146
- var COIN_ETH_PAIR_POOL_CONFIG = {
147
- [_chains.base.id]: _protocoldeployments.encodeMultiCurvePoolConfig.call(void 0, {
148
- currency: _viem.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
- [_chains.baseSepolia.id]: _protocoldeployments.encodeMultiCurvePoolConfig.call(void 0, {
155
- currency: _viem.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 = _viem.parseUnits.call(void 0,
166
- "0.05",
167
- ZORA_DECIMALS
168
- );
169
- var COIN_ZORA_PAIR_POOL_CONFIG = {
170
- [_chains.base.id]: _protocoldeployments.encodeMultiCurvePoolConfig.call(void 0, {
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
- };
134
+ // src/client/client.gen.ts
178
135
 
179
- // src/utils/getPrepurchaseHook.ts
180
136
 
181
137
 
138
+ var _clientfetch = require('@hey-api/client-fetch');
139
+ var client = _clientfetch.createClient.call(void 0,
140
+ _clientfetch.createConfig.call(void 0, {
141
+ baseUrl: "https://api-sdk.zora.engineering/"
142
+ })
143
+ );
182
144
 
145
+ // src/client/sdk.gen.ts
146
+ var getCoin = (options) => {
147
+ return (_nullishCoalesce(options.client, () => ( client))).get({
148
+ security: [
149
+ {
150
+ name: "api-key",
151
+ type: "apiKey"
152
+ }
153
+ ],
154
+ url: "/coin",
155
+ ...options
156
+ });
157
+ };
158
+ var getCoinComments = (options) => {
159
+ return (_nullishCoalesce(options.client, () => ( client))).get({
160
+ security: [
161
+ {
162
+ name: "api-key",
163
+ type: "apiKey"
164
+ }
165
+ ],
166
+ url: "/coinComments",
167
+ ...options
168
+ });
169
+ };
170
+ var getCoinHolders = (options) => {
171
+ return (_nullishCoalesce(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 (_nullishCoalesce(options.client, () => ( client))).get({
184
+ security: [
185
+ {
186
+ name: "api-key",
187
+ type: "apiKey"
188
+ }
189
+ ],
190
+ url: "/coinSwaps",
191
+ ...options
192
+ });
193
+ };
194
+ var getCoins = (options) => {
195
+ return (_nullishCoalesce(options.client, () => ( client))).get({
196
+ security: [
197
+ {
198
+ name: "api-key",
199
+ type: "apiKey"
200
+ }
201
+ ],
202
+ url: "/coins",
203
+ ...options
204
+ });
205
+ };
206
+ var setCreateUploadJwt = (options) => {
207
+ return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _3 => _3.client]), () => ( client))).post({
208
+ security: [
209
+ {
210
+ name: "api-key",
211
+ type: "apiKey"
212
+ }
213
+ ],
214
+ url: "/createUploadJWT",
215
+ ...options,
216
+ headers: {
217
+ "Content-Type": "application/json",
218
+ ..._optionalChain([options, 'optionalAccess', _4 => _4.headers])
219
+ }
220
+ });
221
+ };
222
+ var getExplore = (options) => {
223
+ return (_nullishCoalesce(options.client, () => ( client))).get({
224
+ security: [
225
+ {
226
+ name: "api-key",
227
+ type: "apiKey"
228
+ }
229
+ ],
230
+ url: "/explore",
231
+ ...options
232
+ });
233
+ };
234
+ var getProfile = (options) => {
235
+ return (_nullishCoalesce(options.client, () => ( client))).get({
236
+ security: [
237
+ {
238
+ name: "api-key",
239
+ type: "apiKey"
240
+ }
241
+ ],
242
+ url: "/profile",
243
+ ...options
244
+ });
245
+ };
246
+ var getProfileBalances = (options) => {
247
+ return (_nullishCoalesce(options.client, () => ( client))).get({
248
+ security: [
249
+ {
250
+ name: "api-key",
251
+ type: "apiKey"
252
+ }
253
+ ],
254
+ url: "/profileBalances",
255
+ ...options
256
+ });
257
+ };
258
+ var getProfileCoins = (options) => {
259
+ return (_nullishCoalesce(options.client, () => ( client))).get({
260
+ security: [
261
+ {
262
+ name: "api-key",
263
+ type: "apiKey"
264
+ }
265
+ ],
266
+ url: "/profileCoins",
267
+ ...options
268
+ });
269
+ };
270
+ var postQuote = (options) => {
271
+ return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _5 => _5.client]), () => ( client))).post({
272
+ security: [
273
+ {
274
+ name: "api-key",
275
+ type: "apiKey"
276
+ }
277
+ ],
278
+ url: "/quote",
279
+ ...options,
280
+ headers: {
281
+ "Content-Type": "application/json",
282
+ ..._optionalChain([options, 'optionalAccess', _6 => _6.headers])
283
+ }
284
+ });
285
+ };
286
+ var postCreateContent = (options) => {
287
+ return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.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
+ ..._optionalChain([options, 'optionalAccess', _8 => _8.headers])
299
+ }
300
+ });
301
+ };
183
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
+ }
184
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);
185
336
 
186
- var BASE_UDSC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
187
- var USDC_ZORA_FEE = 3e3;
188
- var WETH_BASE_FEE = 3e3;
189
- var encodeFee = (fee) => _viem.pad.call(void 0, _viem.toHex.call(void 0, fee), { size: 3 });
190
- var getPrepurchaseHook = async ({
191
- payoutRecipient,
192
- initialPurchase,
193
- chainId
194
- }) => {
195
- if (initialPurchase.currency !== 1 /* ETH */ && chainId !== _chains.base.id) {
196
- throw new Error("Initial purchase currency and/or chain not supported");
197
- }
198
- const path = _viem.concat.call(void 0, [
199
- _protocoldeployments.wethAddress[_chains.base.id],
200
- encodeFee(WETH_BASE_FEE),
201
- BASE_UDSC_ADDRESS,
202
- encodeFee(USDC_ZORA_FEE),
203
- ZORA_ADDRESS
204
- ]);
205
- return _protocoldeployments.encodeBuySupplyWithMultiHopSwapRouterHookCall.call(void 0, {
206
- ethValue: initialPurchase.amount,
207
- buyRecipient: payoutRecipient,
208
- exactInputParams: {
209
- path,
210
- amountIn: initialPurchase.amount,
211
- amountOutMinimum: initialPurchase.amountOutMinimum || 0n
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))
212
349
  },
213
- chainId: _chains.base.id
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
214
394
  });
215
395
  };
216
396
 
217
- // src/utils/getChainFromId.ts
397
+ // src/api/create.ts
398
+ var postCreateContent2 = async (body, options) => {
399
+ return await postCreateContent({
400
+ ...options,
401
+ body,
402
+ ...getApiKeyMeta()
403
+ });
404
+ };
218
405
 
219
- function getChainFromId(chainId) {
220
- if (chainId === _chains.base.id) {
221
- return _chains.base;
222
- }
223
- if (chainId === _chains.baseSepolia.id) {
224
- return _chains.baseSepolia;
406
+ // src/utils/rethrowDecodedRevert.ts
407
+
408
+
409
+
410
+
411
+
412
+ function rethrowDecodedRevert(err, abi) {
413
+ if (err instanceof _viem.BaseError) {
414
+ const revertError = err.walk(
415
+ (e) => e instanceof _viem.ContractFunctionRevertedError
416
+ );
417
+ if (revertError instanceof _viem.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 = _viem.decodeErrorResult.call(void 0, {
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 (e2) {
429
+ const errorName = _optionalChain([revertError, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.errorName]);
430
+ if (errorName) {
431
+ const args = _optionalChain([revertError, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.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
+ }
225
437
  }
226
- throw new Error(`Chain ID ${chainId} not supported`);
438
+ throw err;
227
439
  }
228
440
 
229
441
  // 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 == _chains.baseSepolia.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
- }
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
+ };
252
456
  async function createCoinCall({
457
+ creator,
253
458
  name,
254
459
  symbol,
255
- uri,
256
- owners,
257
- payoutRecipient,
460
+ metadata,
258
461
  currency,
259
462
  chainId = _chains.base.id,
260
- platformReferrer = "0x0000000000000000000000000000000000000000",
261
- initialPurchase
463
+ payoutRecipientOverride,
464
+ additionalOwners,
465
+ platformReferrer,
466
+ skipMetadataValidation = false
262
467
  }) {
263
- if (!owners) {
264
- owners = [payoutRecipient];
468
+ if (!skipMetadataValidation) {
469
+ await validateMetadataURIContent(metadata.uri);
265
470
  }
266
- if (!currency) {
267
- currency = chainId !== _chains.base.id ? 2 /* ETH */ : 1 /* ZORA */;
268
- }
269
- const poolConfig = getPoolConfig(currency, chainId);
270
- await validateMetadataURIContent(uri);
271
- let deployHook = {
272
- hook: _viem.zeroAddress,
273
- hookData: "0x",
274
- value: 0n
275
- };
276
- if (initialPurchase) {
277
- deployHook = await getPrepurchaseHook({
278
- initialPurchase,
279
- payoutRecipient,
280
- chainId
281
- });
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 (!_optionalChain([createContentRequest, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.calls])) {
483
+ throw new Error("Failed to create content calldata");
282
484
  }
283
- return {
284
- abi: _protocoldeployments.coinFactoryABI,
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
- _viem.keccak256.call(void 0, _viem.toBytes.call(void 0, Math.random().toString()))
298
- // coinSalt
299
- ],
300
- value: deployHook.value,
301
- dataSuffix: getAttribution()
302
- };
485
+ return createContentRequest.data.calls.map((data) => ({
486
+ to: data.to,
487
+ data: data.data,
488
+ value: BigInt(data.value)
489
+ }));
303
490
  }
304
491
  function getCoinCreateFromLogs(receipt) {
305
492
  const eventLogs = _viem.parseEventLogs.call(void 0, {
306
493
  abi: _protocoldeployments.coinFactoryABI,
307
494
  logs: receipt.logs
308
495
  });
309
- return _optionalChain([eventLogs, 'access', _3 => _3.find, 'call', _4 => _4((log) => log.eventName === "CoinCreatedV4"), 'optionalAccess', _5 => _5.args]);
496
+ return _optionalChain([eventLogs, 'access', _15 => _15.find, 'call', _16 => _16((log) => log.eventName === "CoinCreatedV4"), 'optionalAccess', _17 => _17.args]);
310
497
  }
311
- async function createCoin(call, walletClient, publicClient, options) {
498
+ async function createCoin({
499
+ call,
500
+ walletClient,
501
+ publicClient,
502
+ options
503
+ }) {
312
504
  validateClientNetwork(publicClient);
313
- const createCoinRequest = await createCoinCall(call);
314
- const { request } = await publicClient.simulateContract({
315
- ...createCoinRequest,
316
- account: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.account]), () => ( walletClient.account))
505
+ const chainId = _nullishCoalesce(call.chainId, () => ( publicClient.chain.id));
506
+ const callRequest = await createCoinCall({
507
+ ...call,
508
+ chainId
317
509
  });
318
- if (request.gas) {
319
- request.gas = request.gas * BigInt(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.gasMultiplier]), () => ( 100))) / 100n;
510
+ if (callRequest.length !== 1) {
511
+ throw new Error("Only one call is supported for this SDK version");
320
512
  }
321
- const hash = await walletClient.writeContract(request);
322
- const receipt = await publicClient.waitForTransactionReceipt({ hash });
513
+ const createContentCall = callRequest[0];
514
+ if (!createContentCall) {
515
+ throw new Error("Failed to load create content calldata from API");
516
+ }
517
+ const coinFactoryAddressForChain = _protocoldeployments.coinFactoryAddress[call.chainId];
518
+ if (!_viem.isAddressEqual.call(void 0, createContentCall.to, coinFactoryAddressForChain)) {
519
+ throw new Error("Creator coin is not supported for this SDK version");
520
+ }
521
+ if (createContentCall.value !== 0n) {
522
+ throw new Error(
523
+ "Creator coin and purchase is not supported for this SDK version."
524
+ );
525
+ }
526
+ const selectedAccount = _nullishCoalesce((typeof _optionalChain([options, 'optionalAccess', _18 => _18.account]) === "string" ? void 0 : _optionalChain([options, 'optionalAccess', _19 => _19.account])), () => ( walletClient.account));
527
+ if (!selectedAccount) {
528
+ throw new Error("Account is required");
529
+ }
530
+ const viemCall = {
531
+ ...createContentCall,
532
+ account: selectedAccount
533
+ };
534
+ if (!_optionalChain([options, 'optionalAccess', _20 => _20.skipValidateTransaction])) {
535
+ try {
536
+ await publicClient.call(viemCall);
537
+ } catch (err) {
538
+ rethrowDecodedRevert(err, _protocoldeployments.coinFactoryABI);
539
+ }
540
+ }
541
+ const gasEstimate = _optionalChain([options, 'optionalAccess', _21 => _21.skipValidateTransaction]) ? 10000000n : await publicClient.estimateGas(viemCall);
542
+ const gasPrice = await publicClient.getGasPrice();
543
+ const hash = await (async () => {
544
+ try {
545
+ return await walletClient.sendTransaction({
546
+ ...viemCall,
547
+ gasPrice,
548
+ gas: gasEstimate,
549
+ chain: publicClient.chain
550
+ });
551
+ } catch (err) {
552
+ rethrowDecodedRevert(err, _protocoldeployments.coinFactoryABI);
553
+ }
554
+ })();
555
+ const receipt = await publicClient.waitForTransactionReceipt({
556
+ hash
557
+ });
323
558
  const deployment = getCoinCreateFromLogs(receipt);
324
559
  return {
325
560
  hash,
326
561
  receipt,
327
- address: _optionalChain([deployment, 'optionalAccess', _8 => _8.coin]),
562
+ address: _optionalChain([deployment, 'optionalAccess', _22 => _22.coin]),
328
563
  deployment,
329
564
  chain: getChainFromId(publicClient.chain.id)
330
565
  };
331
566
  }
332
567
 
333
- // src/actions/getOnchainCoinDetails.ts
568
+ // src/actions/updateCoinURI.ts
334
569
 
335
570
 
336
- async function getOnchainCoinDetails({
337
- coin,
338
- user = _viem.zeroAddress,
339
- publicClient
340
- }) {
341
- validateClientNetwork(publicClient);
342
- const [balance, owners, payoutRecipient] = await publicClient.multicall({
343
- contracts: [
344
- {
345
- address: coin,
346
- abi: _protocoldeployments.coinABI,
347
- functionName: "balanceOf",
348
- args: [user]
349
- },
350
- {
351
- address: coin,
352
- abi: _protocoldeployments.coinABI,
353
- functionName: "owners"
354
- },
355
- {
356
- address: coin,
357
- abi: _protocoldeployments.coinABI,
358
- functionName: "payoutRecipient"
359
- }
360
- ],
361
- allowFailure: false
362
- });
363
- return {
364
- balance,
365
- owners,
366
- payoutRecipient
367
- };
368
- }
369
571
 
370
- // src/actions/updateCoinURI.ts
371
572
 
372
573
 
574
+ // src/utils/attribution.ts
373
575
 
576
+ function getAttribution() {
577
+ const hash = _viem.keccak256.call(void 0, _viem.toHex.call(void 0, "api-sdk.zora.engineering"));
578
+ return _viem.slice.call(void 0, hash, 0, 4);
579
+ }
374
580
 
581
+ // src/actions/updateCoinURI.ts
375
582
  function updateCoinURICall({
376
583
  newURI,
377
584
  coin
@@ -387,12 +594,12 @@ function updateCoinURICall({
387
594
  dataSuffix: getAttribution()
388
595
  };
389
596
  }
390
- async function updateCoinURI(args, walletClient, publicClient) {
597
+ async function updateCoinURI(args, walletClient, publicClient, account) {
391
598
  validateClientNetwork(publicClient);
392
599
  const call = updateCoinURICall(args);
393
600
  const { request } = await publicClient.simulateContract({
394
601
  ...call,
395
- account: walletClient.account
602
+ account: _nullishCoalesce(account, () => ( walletClient.account))
396
603
  });
397
604
  const hash = await walletClient.writeContract(request);
398
605
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
@@ -420,12 +627,12 @@ function updatePayoutRecipientCall({
420
627
  dataSuffix: getAttribution()
421
628
  };
422
629
  }
423
- async function updatePayoutRecipient(args, walletClient, publicClient) {
630
+ async function updatePayoutRecipient(args, walletClient, publicClient, account) {
424
631
  validateClientNetwork(publicClient);
425
632
  const call = updatePayoutRecipientCall(args);
426
633
  const { request } = await publicClient.simulateContract({
427
634
  ...call,
428
- account: walletClient.account
635
+ account: _nullishCoalesce(account, () => ( walletClient.account))
429
636
  });
430
637
  const hash = await walletClient.writeContract(request);
431
638
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
@@ -443,161 +650,6 @@ async function updatePayoutRecipient(args, walletClient, publicClient) {
443
650
 
444
651
 
445
652
 
446
-
447
- // src/client/client.gen.ts
448
-
449
-
450
-
451
- var _clientfetch = require('@hey-api/client-fetch');
452
- var client = _clientfetch.createClient.call(void 0,
453
- _clientfetch.createConfig.call(void 0, {
454
- baseUrl: "https://api-sdk.zora.engineering/"
455
- })
456
- );
457
-
458
- // src/client/sdk.gen.ts
459
- var getCoin = (options) => {
460
- return (_nullishCoalesce(options.client, () => ( client))).get({
461
- security: [
462
- {
463
- name: "api-key",
464
- type: "apiKey"
465
- }
466
- ],
467
- url: "/coin",
468
- ...options
469
- });
470
- };
471
- var getCoinComments = (options) => {
472
- return (_nullishCoalesce(options.client, () => ( client))).get({
473
- security: [
474
- {
475
- name: "api-key",
476
- type: "apiKey"
477
- }
478
- ],
479
- url: "/coinComments",
480
- ...options
481
- });
482
- };
483
- var getCoinHolders = (options) => {
484
- return (_nullishCoalesce(options.client, () => ( client))).get({
485
- security: [
486
- {
487
- name: "api-key",
488
- type: "apiKey"
489
- }
490
- ],
491
- url: "/coinHolders",
492
- ...options
493
- });
494
- };
495
- var getCoinSwaps = (options) => {
496
- return (_nullishCoalesce(options.client, () => ( client))).get({
497
- security: [
498
- {
499
- name: "api-key",
500
- type: "apiKey"
501
- }
502
- ],
503
- url: "/coinSwaps",
504
- ...options
505
- });
506
- };
507
- var getCoins = (options) => {
508
- return (_nullishCoalesce(options.client, () => ( client))).get({
509
- security: [
510
- {
511
- name: "api-key",
512
- type: "apiKey"
513
- }
514
- ],
515
- url: "/coins",
516
- ...options
517
- });
518
- };
519
- var setCreateUploadJwt = (options) => {
520
- return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.client]), () => ( client))).post({
521
- security: [
522
- {
523
- name: "api-key",
524
- type: "apiKey"
525
- }
526
- ],
527
- url: "/createUploadJWT",
528
- ...options,
529
- headers: {
530
- "Content-Type": "application/json",
531
- ..._optionalChain([options, 'optionalAccess', _10 => _10.headers])
532
- }
533
- });
534
- };
535
- var getExplore = (options) => {
536
- return (_nullishCoalesce(options.client, () => ( client))).get({
537
- security: [
538
- {
539
- name: "api-key",
540
- type: "apiKey"
541
- }
542
- ],
543
- url: "/explore",
544
- ...options
545
- });
546
- };
547
- var getProfile = (options) => {
548
- return (_nullishCoalesce(options.client, () => ( client))).get({
549
- security: [
550
- {
551
- name: "api-key",
552
- type: "apiKey"
553
- }
554
- ],
555
- url: "/profile",
556
- ...options
557
- });
558
- };
559
- var getProfileBalances = (options) => {
560
- return (_nullishCoalesce(options.client, () => ( client))).get({
561
- security: [
562
- {
563
- name: "api-key",
564
- type: "apiKey"
565
- }
566
- ],
567
- url: "/profileBalances",
568
- ...options
569
- });
570
- };
571
- var getProfileCoins = (options) => {
572
- return (_nullishCoalesce(options.client, () => ( client))).get({
573
- security: [
574
- {
575
- name: "api-key",
576
- type: "apiKey"
577
- }
578
- ],
579
- url: "/profileCoins",
580
- ...options
581
- });
582
- };
583
- var postQuote = (options) => {
584
- return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.client]), () => ( client))).post({
585
- security: [
586
- {
587
- name: "api-key",
588
- type: "apiKey"
589
- }
590
- ],
591
- url: "/quote",
592
- ...options,
593
- headers: {
594
- "Content-Type": "application/json",
595
- ..._optionalChain([options, 'optionalAccess', _12 => _12.headers])
596
- }
597
- });
598
- };
599
-
600
- // src/actions/tradeCoin.ts
601
653
  function convertBigIntToString(permit) {
602
654
  return {
603
655
  ...permit,
@@ -646,8 +698,8 @@ async function tradeCoin({
646
698
  address: _protocoldeployments.permit2Address[_chains.base.id],
647
699
  functionName: "allowance",
648
700
  args: [
649
- permit.permit.details.token,
650
701
  typeof account === "string" ? account : account.address,
702
+ permit.permit.details.token,
651
703
  permit.permit.spender
652
704
  ]
653
705
  });
@@ -693,7 +745,7 @@ async function tradeCoin({
693
745
  primaryType: "PermitSingle",
694
746
  types: PERMIT_SINGLE_TYPES,
695
747
  message,
696
- account: typeof account === "string" ? account : account.address
748
+ account
697
749
  });
698
750
  signatures.push({
699
751
  signature,
@@ -753,100 +805,6 @@ async function createTradeCall(tradeParameters) {
753
805
  return quote.data;
754
806
  }
755
807
 
756
- // src/api/api-key.ts
757
- var apiKey;
758
- function setApiKey(key) {
759
- apiKey = key;
760
- }
761
- function getApiKey() {
762
- return apiKey;
763
- }
764
- function getApiKeyMeta() {
765
- if (!apiKey) {
766
- return {};
767
- }
768
- return {
769
- headers: {
770
- "api-key": apiKey
771
- }
772
- };
773
- }
774
-
775
- // src/api/queries.ts
776
- var getCoin2 = async (query, options) => {
777
- return await getCoin({
778
- ...options,
779
- query,
780
- ...getApiKeyMeta()
781
- });
782
- };
783
- var getCoins2 = async (query, options) => {
784
- return await getCoins({
785
- query: {
786
- coins: query.coins.map((coinData) => JSON.stringify(coinData))
787
- },
788
- ...getApiKeyMeta(),
789
- ...options
790
- });
791
- };
792
- var getCoinHolders2 = async (query, options) => {
793
- return await getCoinHolders({
794
- query,
795
- ...getApiKeyMeta(),
796
- ...options
797
- });
798
- };
799
- var getCoinSwaps2 = async (query, options) => {
800
- return await getCoinSwaps({
801
- query,
802
- ...getApiKeyMeta(),
803
- ...options
804
- });
805
- };
806
- var getCoinComments2 = async (query, options) => {
807
- return await getCoinComments({
808
- query,
809
- ...getApiKeyMeta(),
810
- ...options
811
- });
812
- };
813
- var getProfile2 = async (query, options) => {
814
- return await getProfile({
815
- query,
816
- ...getApiKeyMeta(),
817
- ...options
818
- });
819
- };
820
- var getProfileCoins2 = async (query, options) => {
821
- return await getProfileCoins({
822
- query,
823
- ...getApiKeyMeta(),
824
- ...options
825
- });
826
- };
827
- var getProfileBalances2 = async (query, options) => {
828
- return await getProfileBalances({
829
- query,
830
- ...getApiKeyMeta(),
831
- ...options
832
- });
833
- };
834
-
835
- // src/api/explore.ts
836
- var createExploreQuery = (query, listType, options) => getExplore({
837
- ...options,
838
- query: { ...query, listType },
839
- ...getApiKeyMeta()
840
- });
841
- var getCoinsTopGainers = (query = {}, options) => createExploreQuery(query, "TOP_GAINERS", options);
842
- var getCoinsTopVolume24h = (query = {}, options) => createExploreQuery(query, "TOP_VOLUME_24H", options);
843
- var getCoinsMostValuable = (query = {}, options) => createExploreQuery(query, "MOST_VALUABLE", options);
844
- var getCoinsNew = (query = {}, options) => createExploreQuery(query, "NEW", options);
845
- var getCoinsLastTraded = (query = {}, options) => createExploreQuery(query, "LAST_TRADED", options);
846
- var getCoinsLastTradedUnique = (query = {}, options) => createExploreQuery(query, "LAST_TRADED_UNIQUE", options);
847
- var getCreatorCoins = (query = {}, options) => createExploreQuery(query, "NEW_CREATORS", options);
848
- var getMostValuableCreatorCoins = (query = {}, options) => createExploreQuery(query, "MOST_VALUABLE_CREATORS", options);
849
-
850
808
  // src/uploader/metadata.ts
851
809
  function validateImageMimeType(mimeType) {
852
810
  if (![
@@ -962,9 +920,9 @@ var CoinMetadataBuilder = class {
962
920
  symbol: this.symbol,
963
921
  description: this.description,
964
922
  image: this.imageURL.toString(),
965
- animation_url: _optionalChain([this, 'access', _13 => _13.mediaURL, 'optionalAccess', _14 => _14.toString, 'call', _15 => _15()]),
923
+ animation_url: _optionalChain([this, 'access', _23 => _23.mediaURL, 'optionalAccess', _24 => _24.toString, 'call', _25 => _25()]),
966
924
  content: this.mediaURL ? {
967
- uri: _optionalChain([this, 'access', _16 => _16.mediaURL, 'optionalAccess', _17 => _17.toString, 'call', _18 => _18()]),
925
+ uri: _optionalChain([this, 'access', _26 => _26.mediaURL, 'optionalAccess', _27 => _27.toString, 'call', _28 => _28()]),
968
926
  mime: this.mediaMimeType
969
927
  } : void 0,
970
928
  properties: this.properties
@@ -991,7 +949,10 @@ var CoinMetadataBuilder = class {
991
949
  createMetadataParameters: {
992
950
  name: this.name,
993
951
  symbol: this.symbol,
994
- uri: uploadResult.url
952
+ metadata: {
953
+ type: "RAW_URI",
954
+ uri: uploadResult.url
955
+ }
995
956
  },
996
957
  metadata
997
958
  };
@@ -1026,7 +987,7 @@ var ZoraUploader = class {
1026
987
  const response = await setCreateUploadJwt2({
1027
988
  creatorAddress: this.creatorAddress
1028
989
  });
1029
- this.jwtApiKey = _optionalChain([response, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.createUploadJwtFromApiKey]);
990
+ this.jwtApiKey = _optionalChain([response, 'access', _29 => _29.data, 'optionalAccess', _30 => _30.createUploadJwtFromApiKey]);
1030
991
  if (!this.jwtApiKey) {
1031
992
  throw new Error("Failed to create upload JWT");
1032
993
  }
@@ -1099,7 +1060,5 @@ function createZoraUploaderForCreator(creatorAddress) {
1099
1060
 
1100
1061
 
1101
1062
 
1102
-
1103
-
1104
- exports.CoinMetadataBuilder = CoinMetadataBuilder; exports.DeployCurrency = DeployCurrency; exports.InitialPurchaseCurrency = InitialPurchaseCurrency; exports.ZoraUploader = ZoraUploader; exports.cleanAndValidateMetadataURI = cleanAndValidateMetadataURI; exports.createCoin = createCoin; exports.createCoinCall = createCoinCall; exports.createMetadataBuilder = createMetadataBuilder; exports.createTradeCall = createTradeCall; exports.createZoraUploaderForCreator = createZoraUploaderForCreator; exports.getCoin = getCoin2; exports.getCoinComments = getCoinComments2; exports.getCoinCreateFromLogs = getCoinCreateFromLogs; exports.getCoinHolders = getCoinHolders2; exports.getCoinSwaps = getCoinSwaps2; exports.getCoins = getCoins2; exports.getCoinsLastTraded = getCoinsLastTraded; exports.getCoinsLastTradedUnique = getCoinsLastTradedUnique; exports.getCoinsMostValuable = getCoinsMostValuable; exports.getCoinsNew = getCoinsNew; exports.getCoinsTopGainers = getCoinsTopGainers; exports.getCoinsTopVolume24h = getCoinsTopVolume24h; exports.getCreatorCoins = getCreatorCoins; exports.getMostValuableCreatorCoins = getMostValuableCreatorCoins; exports.getOnchainCoinDetails = getOnchainCoinDetails; exports.getProfile = getProfile2; exports.getProfileBalances = getProfileBalances2; exports.getProfileCoins = getProfileCoins2; exports.getURLFromUploadResult = getURLFromUploadResult; exports.setApiKey = setApiKey; exports.tradeCoin = tradeCoin; exports.updateCoinURI = updateCoinURI; exports.updateCoinURICall = updateCoinURICall; exports.updatePayoutRecipient = updatePayoutRecipient; exports.updatePayoutRecipientCall = updatePayoutRecipientCall; exports.validateImageMimeType = validateImageMimeType; exports.validateMetadataJSON = validateMetadataJSON; exports.validateMetadataURIContent = validateMetadataURIContent;
1063
+ exports.CoinMetadataBuilder = CoinMetadataBuilder; exports.CreateConstants = CreateConstants; exports.ZoraUploader = ZoraUploader; exports.cleanAndValidateMetadataURI = cleanAndValidateMetadataURI; exports.createCoin = createCoin; exports.createCoinCall = createCoinCall; exports.createMetadataBuilder = createMetadataBuilder; exports.createTradeCall = createTradeCall; exports.createZoraUploaderForCreator = createZoraUploaderForCreator; exports.getCoin = getCoin2; exports.getCoinComments = getCoinComments2; exports.getCoinCreateFromLogs = getCoinCreateFromLogs; exports.getCoinHolders = getCoinHolders2; exports.getCoinSwaps = getCoinSwaps2; exports.getCoins = getCoins2; exports.getCoinsLastTraded = getCoinsLastTraded; exports.getCoinsLastTradedUnique = getCoinsLastTradedUnique; exports.getCoinsMostValuable = getCoinsMostValuable; exports.getCoinsNew = getCoinsNew; exports.getCoinsTopGainers = getCoinsTopGainers; exports.getCoinsTopVolume24h = getCoinsTopVolume24h; exports.getCreatorCoins = getCreatorCoins; exports.getMostValuableCreatorCoins = getMostValuableCreatorCoins; exports.getProfile = getProfile2; exports.getProfileBalances = getProfileBalances2; exports.getProfileCoins = getProfileCoins2; exports.getURLFromUploadResult = getURLFromUploadResult; exports.setApiKey = setApiKey; exports.tradeCoin = tradeCoin; exports.updateCoinURI = updateCoinURI; exports.updateCoinURICall = updateCoinURICall; exports.updatePayoutRecipient = updatePayoutRecipient; exports.updatePayoutRecipientCall = updatePayoutRecipientCall; exports.validateImageMimeType = validateImageMimeType; exports.validateMetadataJSON = validateMetadataJSON; exports.validateMetadataURIContent = validateMetadataURIContent;
1105
1064
  //# sourceMappingURL=index.cjs.map