@zoralabs/coins-sdk 0.2.3 → 0.2.5
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 +13 -0
- package/dist/actions/createCoin.d.ts +11 -4
- package/dist/actions/createCoin.d.ts.map +1 -1
- package/dist/actions/updateCoinURI.d.ts +1 -1
- package/dist/actions/updateCoinURI.d.ts.map +1 -1
- package/dist/actions/updatePayoutRecipient.d.ts +1 -1
- package/dist/actions/updatePayoutRecipient.d.ts.map +1 -1
- package/dist/api/api-key.d.ts +2 -1
- package/dist/api/api-key.d.ts.map +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/internal.d.ts +2 -2
- package/dist/api/internal.d.ts.map +1 -1
- package/dist/index.cjs +301 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +320 -122
- package/dist/index.js.map +1 -1
- package/dist/metadata/cleanAndValidateMetadataURI.d.ts +1 -1
- package/dist/metadata/cleanAndValidateMetadataURI.d.ts.map +1 -1
- package/dist/metadata/index.d.ts +1 -1
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/validateMetadataURIContent.d.ts +1 -1
- package/dist/metadata/validateMetadataURIContent.d.ts.map +1 -1
- package/dist/uploader/index.d.ts +10 -0
- package/dist/uploader/index.d.ts.map +1 -0
- package/dist/uploader/metadata.d.ts +44 -0
- package/dist/uploader/metadata.d.ts.map +1 -0
- package/dist/uploader/providers/zora.d.ts +18 -0
- package/dist/uploader/providers/zora.d.ts.map +1 -0
- package/dist/uploader/types.d.ts +21 -0
- package/dist/uploader/types.d.ts.map +1 -0
- package/dist/utils/getPrepurchaseHook.d.ts +16 -0
- package/dist/utils/getPrepurchaseHook.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/actions/createCoin.ts +33 -7
- package/src/actions/updateCoinURI.ts +1 -1
- package/src/actions/updatePayoutRecipient.ts +1 -1
- package/src/api/api-key.ts +5 -1
- package/src/api/index.ts +1 -0
- package/src/api/internal.ts +3 -3
- package/src/index.ts +9 -9
- package/src/metadata/cleanAndValidateMetadataURI.ts +1 -5
- package/src/metadata/index.ts +1 -4
- package/src/metadata/validateMetadataURIContent.ts +2 -4
- package/src/uploader/index.ts +16 -0
- package/src/uploader/metadata.ts +214 -0
- package/src/uploader/providers/zora.ts +86 -0
- package/src/uploader/tests/metadata.test.ts +331 -0
- package/src/uploader/tests/providers.test.ts +131 -0
- package/src/uploader/types.ts +27 -0
- package/src/utils/getPrepurchaseHook.ts +59 -0
- package/dist/actions/tradeCoin.d.ts +0 -75
- package/dist/actions/tradeCoin.d.ts.map +0 -1
- package/src/actions/tradeCoin.ts +0 -182
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @zoralabs/coins-sdk
|
|
2
2
|
|
|
3
|
+
## 0.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4153eddc: Added metadata uploading feature
|
|
8
|
+
|
|
9
|
+
## 0.2.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3d5f9152: Removing `tradeCoin` function as its currently incompatible with UniswapV4 backed coins
|
|
14
|
+
- d8727949: Add create coin $ZORA initial buy
|
|
15
|
+
|
|
3
16
|
## 0.2.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import { coinFactoryABI as zoraFactoryImplABI } from "@zoralabs/protocol-deployments";
|
|
2
2
|
import { Address, TransactionReceipt, WalletClient, SimulateContractParameters, ContractEventArgsFromTopics, Account } from "viem";
|
|
3
|
-
import { GenericPublicClient } from "
|
|
4
|
-
import { ValidMetadataURI } from "
|
|
3
|
+
import { GenericPublicClient } from "../utils/genericPublicClient";
|
|
4
|
+
import { ValidMetadataURI } from "../uploader/types";
|
|
5
5
|
export type CoinDeploymentLogArgs = ContractEventArgsFromTopics<typeof zoraFactoryImplABI, "CoinCreatedV4">;
|
|
6
6
|
export declare enum DeployCurrency {
|
|
7
7
|
ZORA = 1,
|
|
8
8
|
ETH = 2
|
|
9
9
|
}
|
|
10
|
+
export declare enum InitialPurchaseCurrency {
|
|
11
|
+
ETH = 1
|
|
12
|
+
}
|
|
10
13
|
export type CreateCoinArgs = {
|
|
11
14
|
name: string;
|
|
12
15
|
symbol: string;
|
|
13
16
|
uri: ValidMetadataURI;
|
|
14
|
-
chainId
|
|
17
|
+
chainId?: number;
|
|
15
18
|
owners?: Address[];
|
|
16
19
|
payoutRecipient: Address;
|
|
17
20
|
platformReferrer?: Address;
|
|
18
21
|
currency?: DeployCurrency;
|
|
22
|
+
initialPurchase?: {
|
|
23
|
+
currency: InitialPurchaseCurrency;
|
|
24
|
+
amount: bigint;
|
|
25
|
+
};
|
|
19
26
|
};
|
|
20
|
-
export declare function createCoinCall({ name, symbol, uri, owners, payoutRecipient, currency, chainId, platformReferrer, }: CreateCoinArgs): Promise<SimulateContractParameters<typeof zoraFactoryImplABI, "deploy">>;
|
|
27
|
+
export declare function createCoinCall({ name, symbol, uri, owners, payoutRecipient, currency, chainId, platformReferrer, initialPurchase, }: CreateCoinArgs): Promise<SimulateContractParameters<typeof zoraFactoryImplABI, "deploy">>;
|
|
21
28
|
/**
|
|
22
29
|
* Gets the deployed coin address from transaction receipt logs
|
|
23
30
|
* @param receipt Transaction receipt containing the CoinCreated event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCoin.d.ts","sourceRoot":"","sources":["../../src/actions/createCoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,0BAA0B,EAC1B,2BAA2B,EAM3B,OAAO,EACR,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"createCoin.d.ts","sourceRoot":"","sources":["../../src/actions/createCoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,0BAA0B,EAC1B,2BAA2B,EAM3B,OAAO,EACR,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQrD,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAC7D,OAAO,kBAAkB,EACzB,eAAe,CAChB,CAAC;AAEF,oBAAY,cAAc;IACxB,IAAI,IAAI;IACR,GAAG,IAAI;CACR;AAED,oBAAY,uBAAuB;IACjC,GAAG,IAAI;CAER;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,gBAAgB,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,eAAe,CAAC,EAAE;QAChB,QAAQ,EAAE,uBAAuB,CAAC;QAClC,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAqBF,wBAAsB,cAAc,CAAC,EACnC,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,EACN,eAAe,EACf,QAAQ,EACR,OAAiB,EACjB,gBAA+D,EAC/D,eAAe,GAChB,EAAE,cAAc,GAAG,OAAO,CACzB,0BAA0B,CAAC,OAAO,kBAAkB,EAAE,QAAQ,CAAC,CAChE,CA8CA;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,kBAAkB,GAC1B,qBAAqB,GAAG,SAAS,CAOnC;AAGD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;;GAyBF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, SimulateContractParameters, WalletClient } from "viem";
|
|
2
|
-
import { GenericPublicClient } from "
|
|
2
|
+
import { GenericPublicClient } from "../utils/genericPublicClient";
|
|
3
3
|
export type UpdateCoinURIArgs = {
|
|
4
4
|
coin: Address;
|
|
5
5
|
newURI: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateCoinURI.d.ts","sourceRoot":"","sources":["../../src/actions/updateCoinURI.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,0BAA0B,EAC1B,YAAY,EACb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"updateCoinURI.d.ts","sourceRoot":"","sources":["../../src/actions/updateCoinURI.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,0BAA0B,EAC1B,YAAY,EACb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,IAAI,GACL,EAAE,iBAAiB,GAAG,0BAA0B,CAYhD;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,mBAAmB;;;;;;;;;;;;;;;;;GAgBlC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, SimulateContractParameters, WalletClient } from "viem";
|
|
2
|
-
import { GenericPublicClient } from "
|
|
2
|
+
import { GenericPublicClient } from "../utils/genericPublicClient";
|
|
3
3
|
export type UpdatePayoutRecipientArgs = {
|
|
4
4
|
coin: Address;
|
|
5
5
|
newPayoutRecipient: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updatePayoutRecipient.d.ts","sourceRoot":"","sources":["../../src/actions/updatePayoutRecipient.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,0BAA0B,EAC1B,YAAY,EACb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"updatePayoutRecipient.d.ts","sourceRoot":"","sources":["../../src/actions/updatePayoutRecipient.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,0BAA0B,EAC1B,YAAY,EACb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,EACxC,kBAAkB,EAClB,IAAI,GACL,EAAE,yBAAyB,GAAG,0BAA0B,CAQxD;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,yBAAyB,EAC/B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;GAgBlC"}
|
package/dist/api/api-key.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/api/api-key.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/api/api-key.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,QAEhD;AAED,wBAAgB,SAAS,uBAExB;AAED,wBAAgB,aAAa;;;;;;EAS5B"}
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC;AAC1B,mBAAmB,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC;AAC1B,mBAAmB,WAAW,CAAC;AAG/B,cAAc,WAAW,CAAC;AAC1B,mBAAmB,WAAW,CAAC;AAI/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/api/internal.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SetCreateUploadJwtData, SetCreateUploadJwtResponse } from "../client/types.gen";
|
|
2
2
|
import { RequestOptionsType } from "./query-types";
|
|
3
3
|
import { RequestResult } from "@hey-api/client-fetch";
|
|
4
|
-
type SetCreateUploadJwtQuery = SetCreateUploadJwtData["
|
|
4
|
+
type SetCreateUploadJwtQuery = SetCreateUploadJwtData["body"];
|
|
5
5
|
export type { SetCreateUploadJwtQuery, SetCreateUploadJwtData };
|
|
6
6
|
export type { SetCreateUploadJwtResponse } from "../client/types.gen";
|
|
7
|
-
export declare const setCreateUploadJwt: (
|
|
7
|
+
export declare const setCreateUploadJwt: (body: SetCreateUploadJwtQuery, options?: RequestOptionsType<SetCreateUploadJwtData>) => Promise<RequestResult<SetCreateUploadJwtResponse>>;
|
|
8
8
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/api/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,KAAK,uBAAuB,GAAG,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/api/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,KAAK,uBAAuB,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC9D,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,CAAC;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEtE,eAAO,MAAM,kBAAkB,GAC7B,MAAM,uBAAuB,EAC7B,UAAU,kBAAkB,CAAC,sBAAsB,CAAC,KACnD,OAAO,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAMnD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,11 @@ var _protocoldeployments = require('@zoralabs/protocol-deployments');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _viem = require('viem');
|
|
9
|
+
var _chains = require('viem/chains');
|
|
9
10
|
|
|
10
11
|
// src/constants.ts
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
var COIN_FACTORY_ADDRESS = _protocoldeployments.coinFactoryAddress["8453"];
|
|
14
15
|
var SUPERCHAIN_WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
|
|
15
16
|
var USDC_WETH_POOLS_BY_CHAIN = {
|
|
@@ -133,9 +134,6 @@ function getAttribution() {
|
|
|
133
134
|
return _viem.slice.call(void 0, hash, 0, 4);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
// src/actions/createCoin.ts
|
|
137
|
-
|
|
138
|
-
|
|
139
137
|
// src/utils/poolConfigUtils.ts
|
|
140
138
|
|
|
141
139
|
|
|
@@ -179,12 +177,54 @@ var COIN_ZORA_PAIR_POOL_CONFIG = {
|
|
|
179
177
|
})
|
|
180
178
|
};
|
|
181
179
|
|
|
180
|
+
// src/utils/getPrepurchaseHook.ts
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
var BASE_UDSC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
188
|
+
var USDC_ZORA_FEE = 3e3;
|
|
189
|
+
var WETH_BASE_FEE = 3e3;
|
|
190
|
+
var encodeFee = (fee) => _viem.pad.call(void 0, _viem.toHex.call(void 0, fee), { size: 3 });
|
|
191
|
+
var getPrepurchaseHook = async ({
|
|
192
|
+
payoutRecipient,
|
|
193
|
+
initialPurchase,
|
|
194
|
+
chainId
|
|
195
|
+
}) => {
|
|
196
|
+
if (initialPurchase.currency !== 1 /* ETH */ && chainId !== _chains.base.id) {
|
|
197
|
+
throw new Error("Initial purchase currency and/or chain not supported");
|
|
198
|
+
}
|
|
199
|
+
const path = _viem.concat.call(void 0, [
|
|
200
|
+
_protocoldeployments.wethAddress[_chains.base.id],
|
|
201
|
+
encodeFee(WETH_BASE_FEE),
|
|
202
|
+
BASE_UDSC_ADDRESS,
|
|
203
|
+
encodeFee(USDC_ZORA_FEE),
|
|
204
|
+
ZORA_ADDRESS
|
|
205
|
+
]);
|
|
206
|
+
return _protocoldeployments.encodeBuySupplyWithMultiHopSwapRouterHookCall.call(void 0, {
|
|
207
|
+
ethValue: initialPurchase.amount,
|
|
208
|
+
buyRecipient: payoutRecipient,
|
|
209
|
+
exactInputParams: {
|
|
210
|
+
path,
|
|
211
|
+
amountIn: initialPurchase.amount,
|
|
212
|
+
amountOutMinimum: initialPurchase.amountOutMinimum || 0n
|
|
213
|
+
},
|
|
214
|
+
chainId: _chains.base.id
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
182
218
|
// src/actions/createCoin.ts
|
|
183
219
|
var DeployCurrency = /* @__PURE__ */ ((DeployCurrency2) => {
|
|
184
220
|
DeployCurrency2[DeployCurrency2["ZORA"] = 1] = "ZORA";
|
|
185
221
|
DeployCurrency2[DeployCurrency2["ETH"] = 2] = "ETH";
|
|
186
222
|
return DeployCurrency2;
|
|
187
223
|
})(DeployCurrency || {});
|
|
224
|
+
var InitialPurchaseCurrency = /* @__PURE__ */ ((InitialPurchaseCurrency2) => {
|
|
225
|
+
InitialPurchaseCurrency2[InitialPurchaseCurrency2["ETH"] = 1] = "ETH";
|
|
226
|
+
return InitialPurchaseCurrency2;
|
|
227
|
+
})(InitialPurchaseCurrency || {});
|
|
188
228
|
function getPoolConfig(currency, chainId) {
|
|
189
229
|
if (currency === 1 /* ZORA */ && chainId == _chains.baseSepolia.id) {
|
|
190
230
|
throw new Error("ZORA is not supported on Base Sepolia");
|
|
@@ -206,7 +246,8 @@ async function createCoinCall({
|
|
|
206
246
|
payoutRecipient,
|
|
207
247
|
currency,
|
|
208
248
|
chainId = _chains.base.id,
|
|
209
|
-
platformReferrer = "0x0000000000000000000000000000000000000000"
|
|
249
|
+
platformReferrer = "0x0000000000000000000000000000000000000000",
|
|
250
|
+
initialPurchase
|
|
210
251
|
}) {
|
|
211
252
|
if (!owners) {
|
|
212
253
|
owners = [payoutRecipient];
|
|
@@ -216,6 +257,18 @@ async function createCoinCall({
|
|
|
216
257
|
}
|
|
217
258
|
const poolConfig = getPoolConfig(currency, chainId);
|
|
218
259
|
await validateMetadataURIContent(uri);
|
|
260
|
+
let deployHook = {
|
|
261
|
+
hook: _viem.zeroAddress,
|
|
262
|
+
hookData: "0x",
|
|
263
|
+
value: 0n
|
|
264
|
+
};
|
|
265
|
+
if (initialPurchase) {
|
|
266
|
+
deployHook = await getPrepurchaseHook({
|
|
267
|
+
initialPurchase,
|
|
268
|
+
payoutRecipient,
|
|
269
|
+
chainId
|
|
270
|
+
});
|
|
271
|
+
}
|
|
219
272
|
return {
|
|
220
273
|
abi: _protocoldeployments.coinFactoryABI,
|
|
221
274
|
functionName: "deploy",
|
|
@@ -228,13 +281,12 @@ async function createCoinCall({
|
|
|
228
281
|
symbol,
|
|
229
282
|
poolConfig,
|
|
230
283
|
platformReferrer,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
"0x",
|
|
234
|
-
// hookData
|
|
284
|
+
deployHook.hook,
|
|
285
|
+
deployHook.hookData,
|
|
235
286
|
_viem.keccak256.call(void 0, _viem.toBytes.call(void 0, Math.random().toString()))
|
|
236
287
|
// coinSalt
|
|
237
288
|
],
|
|
289
|
+
value: deployHook.value,
|
|
238
290
|
dataSuffix: getAttribution()
|
|
239
291
|
};
|
|
240
292
|
}
|
|
@@ -266,98 +318,6 @@ async function createCoin(call, walletClient, publicClient, options) {
|
|
|
266
318
|
};
|
|
267
319
|
}
|
|
268
320
|
|
|
269
|
-
// src/actions/tradeCoin.ts
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var OP_BRIDGE_ADDRESS = "0x4200000000000000000000000000000000000016";
|
|
278
|
-
async function simulateBuy({
|
|
279
|
-
target,
|
|
280
|
-
requestedOrderSize,
|
|
281
|
-
publicClient
|
|
282
|
-
}) {
|
|
283
|
-
const numberResult = await publicClient.simulateContract({
|
|
284
|
-
address: target,
|
|
285
|
-
abi: _protocoldeployments.coinABI,
|
|
286
|
-
functionName: "buy",
|
|
287
|
-
dataSuffix: getAttribution(),
|
|
288
|
-
args: [
|
|
289
|
-
OP_BRIDGE_ADDRESS,
|
|
290
|
-
requestedOrderSize,
|
|
291
|
-
0n,
|
|
292
|
-
// minAmountOut
|
|
293
|
-
0n,
|
|
294
|
-
// sqrtPriceLimitX96
|
|
295
|
-
_viem.zeroAddress
|
|
296
|
-
// tradeReferrer
|
|
297
|
-
],
|
|
298
|
-
// We want to ensure that the multicall3 contract has enough ETH to buy in the simulation
|
|
299
|
-
stateOverride: [
|
|
300
|
-
{
|
|
301
|
-
address: _chains.baseSepolia.contracts.multicall3.address,
|
|
302
|
-
balance: _viem.parseEther.call(void 0, "10000000")
|
|
303
|
-
}
|
|
304
|
-
]
|
|
305
|
-
});
|
|
306
|
-
const orderSize = numberResult.result[0];
|
|
307
|
-
const amountOut = numberResult.result[1];
|
|
308
|
-
return { orderSize, amountOut };
|
|
309
|
-
}
|
|
310
|
-
function tradeCoinCall({
|
|
311
|
-
target,
|
|
312
|
-
direction,
|
|
313
|
-
args: {
|
|
314
|
-
recipient,
|
|
315
|
-
orderSize,
|
|
316
|
-
minAmountOut = 0n,
|
|
317
|
-
sqrtPriceLimitX96 = 0n,
|
|
318
|
-
tradeReferrer = _viem.zeroAddress
|
|
319
|
-
}
|
|
320
|
-
}) {
|
|
321
|
-
return {
|
|
322
|
-
abi: _protocoldeployments.coinABI,
|
|
323
|
-
functionName: direction,
|
|
324
|
-
address: target,
|
|
325
|
-
args: [
|
|
326
|
-
recipient,
|
|
327
|
-
orderSize,
|
|
328
|
-
minAmountOut,
|
|
329
|
-
sqrtPriceLimitX96,
|
|
330
|
-
tradeReferrer
|
|
331
|
-
],
|
|
332
|
-
value: direction === "buy" ? orderSize : 0n
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
function getTradeFromLogs(receipt, direction) {
|
|
336
|
-
const eventLogs = _viem.parseEventLogs.call(void 0, {
|
|
337
|
-
abi: _protocoldeployments.coinABI,
|
|
338
|
-
logs: receipt.logs
|
|
339
|
-
});
|
|
340
|
-
if (direction === "buy") {
|
|
341
|
-
return _optionalChain([eventLogs, 'access', _9 => _9.find, 'call', _10 => _10((log) => log.eventName === "CoinBuy"), 'optionalAccess', _11 => _11.args]);
|
|
342
|
-
}
|
|
343
|
-
return _optionalChain([eventLogs, 'access', _12 => _12.find, 'call', _13 => _13((log) => log.eventName === "CoinSell"), 'optionalAccess', _14 => _14.args]);
|
|
344
|
-
}
|
|
345
|
-
async function tradeCoin(params, walletClient, publicClient) {
|
|
346
|
-
validateClientNetwork(publicClient);
|
|
347
|
-
const { request } = await publicClient.simulateContract({
|
|
348
|
-
...tradeCoinCall(params),
|
|
349
|
-
account: walletClient.account
|
|
350
|
-
});
|
|
351
|
-
const hash = await walletClient.writeContract(request);
|
|
352
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
353
|
-
const trade = getTradeFromLogs(receipt, params.direction);
|
|
354
|
-
return {
|
|
355
|
-
hash,
|
|
356
|
-
receipt,
|
|
357
|
-
trade
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
321
|
// src/actions/getOnchainCoinDetails.ts
|
|
362
322
|
|
|
363
323
|
|
|
@@ -400,7 +360,7 @@ async function getOnchainCoinDetails({
|
|
|
400
360
|
allowFailure: false
|
|
401
361
|
}
|
|
402
362
|
);
|
|
403
|
-
const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[_optionalChain([publicClient, 'access',
|
|
363
|
+
const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[_optionalChain([publicClient, 'access', _9 => _9.chain, 'optionalAccess', _10 => _10.id]) || 0];
|
|
404
364
|
const [
|
|
405
365
|
coinWethPoolSlot0,
|
|
406
366
|
coinWethPoolToken0,
|
|
@@ -620,6 +580,22 @@ var getCoins = (options) => {
|
|
|
620
580
|
...options
|
|
621
581
|
});
|
|
622
582
|
};
|
|
583
|
+
var setCreateUploadJwt = (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: "/createUploadJWT",
|
|
592
|
+
...options,
|
|
593
|
+
headers: {
|
|
594
|
+
"Content-Type": "application/json",
|
|
595
|
+
..._optionalChain([options, 'optionalAccess', _12 => _12.headers])
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
};
|
|
623
599
|
var getExplore = (options) => {
|
|
624
600
|
return (_nullishCoalesce(options.client, () => ( client))).get({
|
|
625
601
|
security: [
|
|
@@ -674,6 +650,9 @@ var apiKey;
|
|
|
674
650
|
function setApiKey(key) {
|
|
675
651
|
apiKey = key;
|
|
676
652
|
}
|
|
653
|
+
function getApiKey() {
|
|
654
|
+
return apiKey;
|
|
655
|
+
}
|
|
677
656
|
function getApiKeyMeta() {
|
|
678
657
|
if (!apiKey) {
|
|
679
658
|
return {};
|
|
@@ -744,6 +723,225 @@ var getCoinsNew = (query = {}, options) => createExploreQuery(query, "NEW", opti
|
|
|
744
723
|
var getCoinsLastTraded = (query = {}, options) => createExploreQuery(query, "LAST_TRADED", options);
|
|
745
724
|
var getCoinsLastTradedUnique = (query = {}, options) => createExploreQuery(query, "LAST_TRADED_UNIQUE", options);
|
|
746
725
|
|
|
726
|
+
// src/uploader/metadata.ts
|
|
727
|
+
function validateImageMimeType(mimeType) {
|
|
728
|
+
if (![
|
|
729
|
+
"image/png",
|
|
730
|
+
"image/jpeg",
|
|
731
|
+
"image/jpg",
|
|
732
|
+
"image/gif",
|
|
733
|
+
"image/svg+xml"
|
|
734
|
+
].includes(mimeType)) {
|
|
735
|
+
throw new Error("Image must be a PNG, JPEG, JPG, GIF or SVG");
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function getURLFromUploadResult(uploadResult) {
|
|
739
|
+
return new URL(uploadResult.url);
|
|
740
|
+
}
|
|
741
|
+
var CoinMetadataBuilder = class {
|
|
742
|
+
withName(name) {
|
|
743
|
+
this.name = name;
|
|
744
|
+
if (typeof name !== "string") {
|
|
745
|
+
throw new Error("Name must be a string");
|
|
746
|
+
}
|
|
747
|
+
return this;
|
|
748
|
+
}
|
|
749
|
+
withSymbol(symbol) {
|
|
750
|
+
this.symbol = symbol;
|
|
751
|
+
if (typeof symbol !== "string") {
|
|
752
|
+
throw new Error("Symbol must be a string");
|
|
753
|
+
}
|
|
754
|
+
return this;
|
|
755
|
+
}
|
|
756
|
+
withDescription(description) {
|
|
757
|
+
this.description = description;
|
|
758
|
+
if (typeof description !== "string") {
|
|
759
|
+
throw new Error("Description must be a string");
|
|
760
|
+
}
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
763
|
+
withImage(image) {
|
|
764
|
+
if (this.imageURL) {
|
|
765
|
+
throw new Error("Image URL already set");
|
|
766
|
+
}
|
|
767
|
+
if (!(image instanceof File)) {
|
|
768
|
+
throw new Error("Image must be a File");
|
|
769
|
+
}
|
|
770
|
+
validateImageMimeType(image.type);
|
|
771
|
+
this.imageFile = image;
|
|
772
|
+
return this;
|
|
773
|
+
}
|
|
774
|
+
withImageURI(imageURI) {
|
|
775
|
+
if (this.imageFile) {
|
|
776
|
+
throw new Error("Image file already set");
|
|
777
|
+
}
|
|
778
|
+
if (typeof imageURI !== "string") {
|
|
779
|
+
throw new Error("Image URI must be a string");
|
|
780
|
+
}
|
|
781
|
+
const url = new URL(imageURI);
|
|
782
|
+
this.imageURL = url;
|
|
783
|
+
return this;
|
|
784
|
+
}
|
|
785
|
+
withProperties(properties) {
|
|
786
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
787
|
+
if (typeof key !== "string") {
|
|
788
|
+
throw new Error("Property key must be a string");
|
|
789
|
+
}
|
|
790
|
+
if (typeof value !== "string") {
|
|
791
|
+
throw new Error("Property value must be a string");
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (!this.properties) {
|
|
795
|
+
this.properties = {};
|
|
796
|
+
}
|
|
797
|
+
this.properties = { ...this.properties, ...properties };
|
|
798
|
+
return this;
|
|
799
|
+
}
|
|
800
|
+
withMedia(media) {
|
|
801
|
+
if (this.mediaURL) {
|
|
802
|
+
throw new Error("Media URL already set");
|
|
803
|
+
}
|
|
804
|
+
if (!(media instanceof File)) {
|
|
805
|
+
throw new Error("Media must be a File");
|
|
806
|
+
}
|
|
807
|
+
this.mediaMimeType = media.type;
|
|
808
|
+
this.mediaFile = media;
|
|
809
|
+
return this;
|
|
810
|
+
}
|
|
811
|
+
withMediaURI(mediaURI, mediaMimeType) {
|
|
812
|
+
if (this.mediaFile) {
|
|
813
|
+
throw new Error("Media file already set");
|
|
814
|
+
}
|
|
815
|
+
if (typeof mediaURI !== "string") {
|
|
816
|
+
throw new Error("Media URI must be a string");
|
|
817
|
+
}
|
|
818
|
+
const url = new URL(mediaURI);
|
|
819
|
+
this.mediaURL = url;
|
|
820
|
+
this.mediaMimeType = mediaMimeType;
|
|
821
|
+
return this;
|
|
822
|
+
}
|
|
823
|
+
validate() {
|
|
824
|
+
if (!this.name) {
|
|
825
|
+
throw new Error("Name is required");
|
|
826
|
+
}
|
|
827
|
+
if (!this.symbol) {
|
|
828
|
+
throw new Error("Symbol is required");
|
|
829
|
+
}
|
|
830
|
+
if (!this.imageFile && !this.imageURL) {
|
|
831
|
+
throw new Error("Image is required");
|
|
832
|
+
}
|
|
833
|
+
return this;
|
|
834
|
+
}
|
|
835
|
+
generateMetadata() {
|
|
836
|
+
return {
|
|
837
|
+
name: this.name,
|
|
838
|
+
symbol: this.symbol,
|
|
839
|
+
description: this.description,
|
|
840
|
+
image: this.imageURL.toString(),
|
|
841
|
+
animation_url: _optionalChain([this, 'access', _13 => _13.mediaURL, 'optionalAccess', _14 => _14.toString, 'call', _15 => _15()]),
|
|
842
|
+
content: this.mediaURL ? {
|
|
843
|
+
uri: _optionalChain([this, 'access', _16 => _16.mediaURL, 'optionalAccess', _17 => _17.toString, 'call', _18 => _18()]),
|
|
844
|
+
mime: this.mediaMimeType
|
|
845
|
+
} : void 0,
|
|
846
|
+
properties: this.properties
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
async upload(uploader) {
|
|
850
|
+
this.validate();
|
|
851
|
+
if (this.imageFile) {
|
|
852
|
+
const uploadResult2 = await uploader.upload(this.imageFile);
|
|
853
|
+
this.imageURL = getURLFromUploadResult(uploadResult2);
|
|
854
|
+
}
|
|
855
|
+
if (this.mediaFile) {
|
|
856
|
+
const uploadResult2 = await uploader.upload(this.mediaFile);
|
|
857
|
+
this.mediaURL = getURLFromUploadResult(uploadResult2);
|
|
858
|
+
}
|
|
859
|
+
const metadata = this.generateMetadata();
|
|
860
|
+
const uploadResult = await uploader.upload(
|
|
861
|
+
new File([JSON.stringify(metadata)], "metadata.json", {
|
|
862
|
+
type: "application/json"
|
|
863
|
+
})
|
|
864
|
+
);
|
|
865
|
+
return {
|
|
866
|
+
url: getURLFromUploadResult(uploadResult).toString(),
|
|
867
|
+
createMetadataParameters: {
|
|
868
|
+
name: this.name,
|
|
869
|
+
symbol: this.symbol,
|
|
870
|
+
uri: uploadResult.url
|
|
871
|
+
},
|
|
872
|
+
metadata
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
function createMetadataBuilder() {
|
|
877
|
+
return new CoinMetadataBuilder();
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// src/api/internal.ts
|
|
881
|
+
var setCreateUploadJwt2 = async (body, options) => {
|
|
882
|
+
return await setCreateUploadJwt({
|
|
883
|
+
body,
|
|
884
|
+
...getApiKeyMeta(),
|
|
885
|
+
...options
|
|
886
|
+
});
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
// src/uploader/providers/zora.ts
|
|
890
|
+
var ZoraUploader = class {
|
|
891
|
+
constructor(creatorAddress) {
|
|
892
|
+
this.creatorAddress = creatorAddress;
|
|
893
|
+
if (!getApiKey()) {
|
|
894
|
+
throw new Error("API key is required for metadata interactions");
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
async getJWTApiKey() {
|
|
898
|
+
if (this.jwtApiKey && this.jwtApiKeyExpiresAt && this.jwtApiKeyExpiresAt > Date.now()) {
|
|
899
|
+
return this.jwtApiKey;
|
|
900
|
+
}
|
|
901
|
+
this.jwtApiKeyExpiresAt = Date.now() + 1e3 * 60 * 60;
|
|
902
|
+
const response = await setCreateUploadJwt2({
|
|
903
|
+
creatorAddress: this.creatorAddress
|
|
904
|
+
});
|
|
905
|
+
this.jwtApiKey = _optionalChain([response, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.createUploadJwtFromApiKey]);
|
|
906
|
+
if (!this.jwtApiKey) {
|
|
907
|
+
throw new Error("Failed to create upload JWT");
|
|
908
|
+
}
|
|
909
|
+
return this.jwtApiKey;
|
|
910
|
+
}
|
|
911
|
+
async upload(file) {
|
|
912
|
+
const jwtApiKey = await this.getJWTApiKey();
|
|
913
|
+
const formData = new FormData();
|
|
914
|
+
formData.append("file", file, file.name);
|
|
915
|
+
const response = await fetch(
|
|
916
|
+
"https://ipfs-uploader.zora.co/api/v0/add?cid-version=1",
|
|
917
|
+
{
|
|
918
|
+
method: "POST",
|
|
919
|
+
headers: {
|
|
920
|
+
Authorization: `Bearer ${jwtApiKey}`,
|
|
921
|
+
Accept: "*/*"
|
|
922
|
+
},
|
|
923
|
+
body: formData
|
|
924
|
+
}
|
|
925
|
+
);
|
|
926
|
+
if (!response.ok) {
|
|
927
|
+
console.error(await response.text());
|
|
928
|
+
throw new Error(`Failed to upload file: ${response.statusText}`);
|
|
929
|
+
}
|
|
930
|
+
const data = await response.json();
|
|
931
|
+
return {
|
|
932
|
+
url: `ipfs://${data.cid}`,
|
|
933
|
+
size: data.size,
|
|
934
|
+
mimeType: data.mimeType
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
function createZoraUploaderForCreator(creatorAddress) {
|
|
939
|
+
return new ZoraUploader(creatorAddress);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
747
945
|
|
|
748
946
|
|
|
749
947
|
|
|
@@ -773,5 +971,5 @@ var getCoinsLastTradedUnique = (query = {}, options) => createExploreQuery(query
|
|
|
773
971
|
|
|
774
972
|
|
|
775
973
|
|
|
776
|
-
exports.DeployCurrency = DeployCurrency; exports.cleanAndValidateMetadataURI = cleanAndValidateMetadataURI; exports.createCoin = createCoin; exports.createCoinCall = createCoinCall; exports.getCoin = getCoin2; exports.getCoinComments = getCoinComments2; exports.getCoinCreateFromLogs = getCoinCreateFromLogs; exports.getCoins = getCoins2; exports.getCoinsLastTraded = getCoinsLastTraded; exports.getCoinsLastTradedUnique = getCoinsLastTradedUnique; exports.getCoinsMostValuable = getCoinsMostValuable; exports.getCoinsNew = getCoinsNew; exports.getCoinsTopGainers = getCoinsTopGainers; exports.getCoinsTopVolume24h = getCoinsTopVolume24h; exports.getOnchainCoinDetails = getOnchainCoinDetails; exports.getProfile = getProfile2; exports.getProfileBalances = getProfileBalances2; exports.getProfileCoins = getProfileCoins2; exports.
|
|
974
|
+
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.createZoraUploaderForCreator = createZoraUploaderForCreator; exports.getCoin = getCoin2; exports.getCoinComments = getCoinComments2; exports.getCoinCreateFromLogs = getCoinCreateFromLogs; exports.getCoins = getCoins2; exports.getCoinsLastTraded = getCoinsLastTraded; exports.getCoinsLastTradedUnique = getCoinsLastTradedUnique; exports.getCoinsMostValuable = getCoinsMostValuable; exports.getCoinsNew = getCoinsNew; exports.getCoinsTopGainers = getCoinsTopGainers; exports.getCoinsTopVolume24h = getCoinsTopVolume24h; exports.getOnchainCoinDetails = getOnchainCoinDetails; exports.getProfile = getProfile2; exports.getProfileBalances = getProfileBalances2; exports.getProfileCoins = getProfileCoins2; exports.getURLFromUploadResult = getURLFromUploadResult; exports.setApiKey = setApiKey; exports.updateCoinURI = updateCoinURI; exports.updateCoinURICall = updateCoinURICall; exports.updatePayoutRecipient = updatePayoutRecipient; exports.updatePayoutRecipientCall = updatePayoutRecipientCall; exports.validateImageMimeType = validateImageMimeType; exports.validateMetadataJSON = validateMetadataJSON; exports.validateMetadataURIContent = validateMetadataURIContent;
|
|
777
975
|
//# sourceMappingURL=index.cjs.map
|