clanker-sdk 4.0.21 → 4.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -18
- package/dist/cli/cli.js +190 -92
- package/dist/cli/create-clanker.js +177 -91
- package/dist/index.d.ts +4508 -82
- package/dist/index.js +180 -93
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Clanker SDK
|
|
2
2
|
|
|
3
|
-
The official TypeScript SDK for deploying tokens
|
|
3
|
+
The official TypeScript SDK for deploying tokens using Clanker.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -31,12 +31,13 @@ This will guide you through the token deployment process step by step.
|
|
|
31
31
|
|
|
32
32
|
1. Create a `.env` file with your configuration:
|
|
33
33
|
```env
|
|
34
|
-
PRIVATE_KEY
|
|
35
|
-
FACTORY_ADDRESS=factory_contract_address_here
|
|
34
|
+
PRIVATE_KEY=<your_private_key_here>
|
|
36
35
|
```
|
|
37
36
|
|
|
38
37
|
2. Create a deployment script:
|
|
39
38
|
```typescript
|
|
39
|
+
// deploy-script.ts
|
|
40
|
+
|
|
40
41
|
import { Clanker } from 'clanker-sdk';
|
|
41
42
|
import { createPublicClient, createWalletClient, http, PublicClient } from 'viem';
|
|
42
43
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
@@ -48,28 +49,23 @@ dotenv.config();
|
|
|
48
49
|
|
|
49
50
|
// Validate environment variables
|
|
50
51
|
const PRIVATE_KEY = process.env.PRIVATE_KEY as `0x${string}`;
|
|
51
|
-
const FACTORY_ADDRESS = process.env.FACTORY_ADDRESS as `0x${string}`;
|
|
52
|
-
const RPC_URL = process.env.RPC_URL;
|
|
53
52
|
|
|
54
|
-
if (!PRIVATE_KEY
|
|
55
|
-
throw new Error("Missing
|
|
53
|
+
if (!PRIVATE_KEY) {
|
|
54
|
+
throw new Error("Missing PRIVATE_KEY environment variable.");
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
// Initialize wallet with private key
|
|
59
58
|
const account = privateKeyToAccount(PRIVATE_KEY);
|
|
60
59
|
|
|
61
|
-
// Create transport with optional custom RPC
|
|
62
|
-
const transport = RPC_URL ? http(RPC_URL) : http();
|
|
63
|
-
|
|
64
60
|
const publicClient = createPublicClient({
|
|
65
61
|
chain: base,
|
|
66
|
-
transport,
|
|
62
|
+
transport: http(),
|
|
67
63
|
}) as PublicClient;
|
|
68
64
|
|
|
69
65
|
const wallet = createWalletClient({
|
|
70
66
|
account,
|
|
71
67
|
chain: base,
|
|
72
|
-
transport,
|
|
68
|
+
transport: http(),
|
|
73
69
|
});
|
|
74
70
|
|
|
75
71
|
// Initialize Clanker SDK
|
|
@@ -109,7 +105,7 @@ async function deployToken() {
|
|
|
109
105
|
durationInDays: 30, // 30-day vesting period
|
|
110
106
|
},
|
|
111
107
|
devBuy: {
|
|
112
|
-
ethAmount:
|
|
108
|
+
ethAmount: 0, // No initial buy
|
|
113
109
|
},
|
|
114
110
|
rewardsConfig: {
|
|
115
111
|
creatorReward: 75, // 75% creator reward
|
|
@@ -141,7 +137,7 @@ deployToken().catch(console.error);
|
|
|
141
137
|
|
|
142
138
|
3. Run the deployment script:
|
|
143
139
|
```bash
|
|
144
|
-
bun
|
|
140
|
+
bun deploy-script.ts
|
|
145
141
|
```
|
|
146
142
|
|
|
147
143
|
## Configuration Options
|
|
@@ -178,17 +174,38 @@ See the [examples](./examples) directory for more deployment scenarios:
|
|
|
178
174
|
- `deploy-token.ts`: Advanced token deployment with all options
|
|
179
175
|
- `deploy-full-sdk.ts`: Full SDK usage example
|
|
180
176
|
|
|
181
|
-
|
|
177
|
+
# SDK Development
|
|
178
|
+
|
|
179
|
+
## Setup
|
|
182
180
|
|
|
181
|
+
The SDK uses bun for development. Install bun following their instructions here: [https://bun.sh](https://bun.sh).
|
|
182
|
+
|
|
183
|
+
Once bun is installed, the project is ready for development
|
|
183
184
|
```bash
|
|
184
185
|
# Install dependencies
|
|
185
186
|
bun i
|
|
186
187
|
|
|
187
|
-
#
|
|
188
|
-
bun
|
|
188
|
+
# Run Examples
|
|
189
|
+
# bun <path_to_example>
|
|
190
|
+
bun examples/v4/availableRewards.ts
|
|
189
191
|
|
|
190
|
-
#
|
|
192
|
+
# Run Tests
|
|
191
193
|
bun test
|
|
194
|
+
|
|
195
|
+
# Lint
|
|
196
|
+
bun lint
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Publishing the package
|
|
200
|
+
```bash
|
|
201
|
+
# Log into npm
|
|
202
|
+
bunx npm login
|
|
203
|
+
|
|
204
|
+
# Dry run publishing
|
|
205
|
+
bun publish-package --dry-run
|
|
206
|
+
|
|
207
|
+
# Publish
|
|
208
|
+
bun publish-package
|
|
192
209
|
```
|
|
193
210
|
|
|
194
211
|
## License
|
package/dist/cli/cli.js
CHANGED
|
@@ -4300,7 +4300,8 @@ var init_Clanker6 = __esm({
|
|
|
4300
4300
|
});
|
|
4301
4301
|
|
|
4302
4302
|
// src/utils/clankers.ts
|
|
4303
|
-
|
|
4303
|
+
import { base as base2, baseSepolia as baseSepolia2 } from "viem/chains";
|
|
4304
|
+
var CLANKERS, Chains, ClankerDeployments;
|
|
4304
4305
|
var init_clankers = __esm({
|
|
4305
4306
|
"src/utils/clankers.ts"() {
|
|
4306
4307
|
"use strict";
|
|
@@ -4313,38 +4314,89 @@ var init_clankers = __esm({
|
|
|
4313
4314
|
init_Clanker6();
|
|
4314
4315
|
CLANKERS = {
|
|
4315
4316
|
clanker_v0: {
|
|
4316
|
-
// @note - this is a same as `proxy` in legacy uses
|
|
4317
4317
|
abi: Clanker_v0_abi,
|
|
4318
|
+
chainId: base2.id,
|
|
4318
4319
|
type: "proxy",
|
|
4319
|
-
address: "0x250c9FB2b411B48273f69879007803790A6AeA47"
|
|
4320
|
+
address: "0x250c9FB2b411B48273f69879007803790A6AeA47",
|
|
4321
|
+
related: void 0
|
|
4320
4322
|
},
|
|
4321
4323
|
clanker_v1: {
|
|
4322
|
-
// @note - this is a same as `clanker` in legacy uses
|
|
4323
4324
|
abi: Clanker_v1_abi,
|
|
4325
|
+
chainId: base2.id,
|
|
4324
4326
|
type: "clanker",
|
|
4325
|
-
address: "0x9B84fcE5Dcd9a38d2D01d5D72373F6b6b067c3e1"
|
|
4327
|
+
address: "0x9B84fcE5Dcd9a38d2D01d5D72373F6b6b067c3e1",
|
|
4328
|
+
related: void 0
|
|
4326
4329
|
},
|
|
4327
4330
|
clanker_v2: {
|
|
4328
4331
|
abi: Clanker_v2_abi,
|
|
4332
|
+
chainId: base2.id,
|
|
4329
4333
|
type: "clanker_v2",
|
|
4330
|
-
address: "0x732560fa1d1A76350b1A500155BA978031B53833"
|
|
4334
|
+
address: "0x732560fa1d1A76350b1A500155BA978031B53833",
|
|
4335
|
+
related: {
|
|
4336
|
+
locker: "0x618A9840691334eE8d24445a4AdA4284Bf42417D"
|
|
4337
|
+
}
|
|
4331
4338
|
},
|
|
4332
4339
|
clanker_v3: {
|
|
4333
4340
|
abi: Clanker_v3_abi,
|
|
4341
|
+
chainId: base2.id,
|
|
4334
4342
|
type: "clanker_v3",
|
|
4335
|
-
address: "0x375C15db32D28cEcdcAB5C03Ab889bf15cbD2c5E"
|
|
4343
|
+
address: "0x375C15db32D28cEcdcAB5C03Ab889bf15cbD2c5E",
|
|
4344
|
+
related: {
|
|
4345
|
+
locker: "0x5eC4f99F342038c67a312a166Ff56e6D70383D86"
|
|
4346
|
+
}
|
|
4336
4347
|
},
|
|
4337
4348
|
clanker_v3_1: {
|
|
4338
4349
|
abi: Clanker_v3_1_abi,
|
|
4350
|
+
chainId: base2.id,
|
|
4339
4351
|
type: "clanker_v3_1",
|
|
4340
|
-
address: "0x2A787b2362021cC3eEa3C24C4748a6cD5B687382"
|
|
4352
|
+
address: "0x2A787b2362021cC3eEa3C24C4748a6cD5B687382",
|
|
4353
|
+
related: {
|
|
4354
|
+
locker: "0x33e2Eda238edcF470309b8c6D228986A1204c8f9",
|
|
4355
|
+
vault: "0x42A95190B4088C88Dd904d930c79deC1158bF09D"
|
|
4356
|
+
}
|
|
4341
4357
|
},
|
|
4342
4358
|
clanker_v4: {
|
|
4343
4359
|
abi: Clanker_v4_abi,
|
|
4360
|
+
chainId: base2.id,
|
|
4344
4361
|
type: "clanker_v4",
|
|
4345
|
-
address: "0xE85A59c628F7d27878ACeB4bf3b35733630083a9"
|
|
4362
|
+
address: "0xE85A59c628F7d27878ACeB4bf3b35733630083a9",
|
|
4363
|
+
related: {
|
|
4364
|
+
locker: "0x29d17C1A8D851d7d4cA97FAe97AcAdb398D9cCE0",
|
|
4365
|
+
vault: "0x8E845EAd15737bF71904A30BdDD3aEE76d6ADF6C",
|
|
4366
|
+
airdrop: "0x56Fa0Da89eD94822e46734e736d34Cab72dF344F",
|
|
4367
|
+
devbuy: "0x1331f0788F9c08C8F38D52c7a1152250A9dE00be",
|
|
4368
|
+
mevModule: "0xE143f9872A33c955F23cF442BB4B1EFB3A7402A2",
|
|
4369
|
+
feeLocker: "0xF3622742b1E446D92e45E22923Ef11C2fcD55D68",
|
|
4370
|
+
feeStaticHook: "0xDd5EeaFf7BD481AD55Db083062b13a3cdf0A68CC",
|
|
4371
|
+
feeDynamicHook: "0x34a45c6B61876d739400Bd71228CbcbD4F53E8cC"
|
|
4372
|
+
}
|
|
4373
|
+
},
|
|
4374
|
+
clanker_v4_sepolia: {
|
|
4375
|
+
abi: Clanker_v4_abi,
|
|
4376
|
+
chainId: baseSepolia2.id,
|
|
4377
|
+
type: "clanker_v4",
|
|
4378
|
+
address: "0xE85A59c628F7d27878ACeB4bf3b35733630083a9",
|
|
4379
|
+
related: {
|
|
4380
|
+
locker: "0x33e2Eda238edcF470309b8c6D228986A1204c8f9",
|
|
4381
|
+
vault: "0xcC80d1226F899a78fC2E459a1500A13C373CE0A5",
|
|
4382
|
+
airdrop: "0x29d17C1A8D851d7d4cA97FAe97AcAdb398D9cCE0",
|
|
4383
|
+
devbuy: "0x691f97752E91feAcD7933F32a1FEdCeDae7bB59c",
|
|
4384
|
+
mevModule: "0x71DB365E93e170ba3B053339A917c11024e7a9d4",
|
|
4385
|
+
feeLocker: "0x42A95190B4088C88Dd904d930c79deC1158bF09D",
|
|
4386
|
+
feeStaticHook: "0x3eC2a26b6eF16c288561692AE8D9681fa773A8cc",
|
|
4387
|
+
feeDynamicHook: "0xE63b0A59100698f379F9B577441A561bAF9828cc"
|
|
4388
|
+
}
|
|
4346
4389
|
}
|
|
4347
4390
|
};
|
|
4391
|
+
Chains = [...new Set(Object.values(CLANKERS).map(({ chainId }) => chainId))];
|
|
4392
|
+
ClankerDeployments = Object.values(CLANKERS).reduce(
|
|
4393
|
+
(agg, cur) => {
|
|
4394
|
+
if (!agg[cur.chainId]) agg[cur.chainId] = {};
|
|
4395
|
+
agg[cur.chainId][cur.type] = cur;
|
|
4396
|
+
return agg;
|
|
4397
|
+
},
|
|
4398
|
+
{}
|
|
4399
|
+
);
|
|
4348
4400
|
}
|
|
4349
4401
|
});
|
|
4350
4402
|
|
|
@@ -4761,7 +4813,7 @@ import {
|
|
|
4761
4813
|
parseEventLogs as parseEventLogs2
|
|
4762
4814
|
} from "viem";
|
|
4763
4815
|
import { call } from "viem/actions";
|
|
4764
|
-
import { base as
|
|
4816
|
+
import { base as base3 } from "viem/chains";
|
|
4765
4817
|
function buildTokenV4(cfg, chainId, salt) {
|
|
4766
4818
|
const feeConfig = cfg.feeConfig;
|
|
4767
4819
|
const { hook, poolData } = encodeFeeConfig(feeConfig);
|
|
@@ -4856,6 +4908,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4856
4908
|
args: [deploymentConfig]
|
|
4857
4909
|
});
|
|
4858
4910
|
return {
|
|
4911
|
+
type: "v4",
|
|
4859
4912
|
transaction: {
|
|
4860
4913
|
to: CLANKER_FACTORY_V4,
|
|
4861
4914
|
data: deployCalldata,
|
|
@@ -4891,7 +4944,7 @@ async function withVanityAddress(cfg, chainId) {
|
|
|
4891
4944
|
};
|
|
4892
4945
|
}
|
|
4893
4946
|
async function simulateDeploy(cfg, account, publicClient) {
|
|
4894
|
-
const chain = publicClient.chain ||
|
|
4947
|
+
const chain = publicClient.chain || base3;
|
|
4895
4948
|
const { transaction } = "transaction" in cfg ? cfg : buildTokenV4(cfg, chain.id);
|
|
4896
4949
|
try {
|
|
4897
4950
|
const { data } = await call(publicClient, {
|
|
@@ -5010,10 +5063,10 @@ var init_v4 = __esm({
|
|
|
5010
5063
|
}
|
|
5011
5064
|
});
|
|
5012
5065
|
|
|
5013
|
-
// src/abi/ClankerFeeLocker.ts
|
|
5066
|
+
// src/abi/v4/ClankerFeeLocker.ts
|
|
5014
5067
|
var ClankerFeeLocker_abi;
|
|
5015
5068
|
var init_ClankerFeeLocker = __esm({
|
|
5016
|
-
"src/abi/ClankerFeeLocker.ts"() {
|
|
5069
|
+
"src/abi/v4/ClankerFeeLocker.ts"() {
|
|
5017
5070
|
"use strict";
|
|
5018
5071
|
init_esm_shims();
|
|
5019
5072
|
ClankerFeeLocker_abi = [
|
|
@@ -5022,6 +5075,8 @@ var init_ClankerFeeLocker = __esm({
|
|
|
5022
5075
|
stateMutability: "nonpayable",
|
|
5023
5076
|
type: "constructor"
|
|
5024
5077
|
},
|
|
5078
|
+
{ inputs: [], name: "ClaimAmountTooHigh", type: "error" },
|
|
5079
|
+
{ inputs: [], name: "InvalidRecipient", type: "error" },
|
|
5025
5080
|
{ inputs: [], name: "NoFeesToClaim", type: "error" },
|
|
5026
5081
|
{
|
|
5027
5082
|
inputs: [{ internalType: "address", name: "owner", type: "address" }],
|
|
@@ -5039,6 +5094,7 @@ var init_ClankerFeeLocker = __esm({
|
|
|
5039
5094
|
name: "SafeERC20FailedOperation",
|
|
5040
5095
|
type: "error"
|
|
5041
5096
|
},
|
|
5097
|
+
{ inputs: [], name: "TransferFailed", type: "error" },
|
|
5042
5098
|
{ inputs: [], name: "Unauthorized", type: "error" },
|
|
5043
5099
|
{
|
|
5044
5100
|
anonymous: false,
|
|
@@ -5195,8 +5251,84 @@ var init_availableFees = __esm({
|
|
|
5195
5251
|
}
|
|
5196
5252
|
});
|
|
5197
5253
|
|
|
5254
|
+
// src/utils/errors.ts
|
|
5255
|
+
import { BaseError, ContractFunctionRevertedError, InsufficientFundsError } from "viem";
|
|
5256
|
+
var ClankerError, ErrorMapping, understandError;
|
|
5257
|
+
var init_errors = __esm({
|
|
5258
|
+
"src/utils/errors.ts"() {
|
|
5259
|
+
"use strict";
|
|
5260
|
+
init_esm_shims();
|
|
5261
|
+
ClankerError = class _ClankerError extends Error {
|
|
5262
|
+
constructor(error, data) {
|
|
5263
|
+
super(data.label);
|
|
5264
|
+
this.error = error;
|
|
5265
|
+
this.data = data;
|
|
5266
|
+
}
|
|
5267
|
+
static unknown(e, name) {
|
|
5268
|
+
return new _ClankerError(e, {
|
|
5269
|
+
type: "unknown",
|
|
5270
|
+
label: "Something went wrong",
|
|
5271
|
+
rawName: name || "unknown"
|
|
5272
|
+
});
|
|
5273
|
+
}
|
|
5274
|
+
};
|
|
5275
|
+
ErrorMapping = {
|
|
5276
|
+
NoFeesToClaim: {
|
|
5277
|
+
type: "state",
|
|
5278
|
+
label: "No fees to claim",
|
|
5279
|
+
rawName: "NoFeesToClaim"
|
|
5280
|
+
}
|
|
5281
|
+
};
|
|
5282
|
+
understandError = (e) => {
|
|
5283
|
+
if (!(e instanceof Error)) return ClankerError.unknown(new Error(`${e}`));
|
|
5284
|
+
if (!(e instanceof BaseError)) return ClankerError.unknown(e);
|
|
5285
|
+
const revertError = e.walk((e2) => e2 instanceof ContractFunctionRevertedError);
|
|
5286
|
+
if (revertError instanceof ContractFunctionRevertedError) {
|
|
5287
|
+
const errorName = revertError.data?.errorName ?? "";
|
|
5288
|
+
const mapping = ErrorMapping[errorName];
|
|
5289
|
+
if (!mapping) return ClankerError.unknown(e, errorName);
|
|
5290
|
+
return new ClankerError(e, mapping);
|
|
5291
|
+
}
|
|
5292
|
+
const fundsError = e.walk((e2) => e2 instanceof InsufficientFundsError);
|
|
5293
|
+
if (fundsError instanceof InsufficientFundsError) {
|
|
5294
|
+
return new ClankerError(fundsError, {
|
|
5295
|
+
type: "caller",
|
|
5296
|
+
label: "Insufficient funds.",
|
|
5297
|
+
rawName: "InsufficientFundsError"
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5300
|
+
return ClankerError.unknown(e);
|
|
5301
|
+
};
|
|
5302
|
+
}
|
|
5303
|
+
});
|
|
5304
|
+
|
|
5305
|
+
// src/utils/write-clanker-contracts.ts
|
|
5306
|
+
import { simulateContract, writeContract } from "viem/actions";
|
|
5307
|
+
var writeClankerContract;
|
|
5308
|
+
var init_write_clanker_contracts = __esm({
|
|
5309
|
+
"src/utils/write-clanker-contracts.ts"() {
|
|
5310
|
+
"use strict";
|
|
5311
|
+
init_esm_shims();
|
|
5312
|
+
init_errors();
|
|
5313
|
+
writeClankerContract = async (client, wallet, tx, options) => {
|
|
5314
|
+
if (options?.simulate) {
|
|
5315
|
+
try {
|
|
5316
|
+
await simulateContract(client, tx);
|
|
5317
|
+
} catch (e) {
|
|
5318
|
+
return { txHash: void 0, error: understandError(e) };
|
|
5319
|
+
}
|
|
5320
|
+
}
|
|
5321
|
+
try {
|
|
5322
|
+
const txHash = await writeContract(wallet, tx);
|
|
5323
|
+
return { txHash, error: void 0 };
|
|
5324
|
+
} catch (e) {
|
|
5325
|
+
return { txHash: void 0, error: understandError(e) };
|
|
5326
|
+
}
|
|
5327
|
+
};
|
|
5328
|
+
}
|
|
5329
|
+
});
|
|
5330
|
+
|
|
5198
5331
|
// src/fees/claim.ts
|
|
5199
|
-
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
5200
5332
|
var claimRewards;
|
|
5201
5333
|
var init_claim = __esm({
|
|
5202
5334
|
"src/fees/claim.ts"() {
|
|
@@ -5204,18 +5336,19 @@ var init_claim = __esm({
|
|
|
5204
5336
|
init_esm_shims();
|
|
5205
5337
|
init_ClankerFeeLocker();
|
|
5206
5338
|
init_constants();
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
}
|
|
5218
|
-
|
|
5339
|
+
init_write_clanker_contracts();
|
|
5340
|
+
claimRewards = async (client, wallet, feeOwnerAddress, tokenAddress, options) => {
|
|
5341
|
+
return writeClankerContract(
|
|
5342
|
+
client,
|
|
5343
|
+
wallet,
|
|
5344
|
+
{
|
|
5345
|
+
address: CLANKER_FEE_LOCKER_V4,
|
|
5346
|
+
abi: ClankerFeeLocker_abi,
|
|
5347
|
+
functionName: "claim",
|
|
5348
|
+
args: [feeOwnerAddress, tokenAddress]
|
|
5349
|
+
},
|
|
5350
|
+
options
|
|
5351
|
+
);
|
|
5219
5352
|
};
|
|
5220
5353
|
}
|
|
5221
5354
|
});
|
|
@@ -5223,7 +5356,7 @@ var init_claim = __esm({
|
|
|
5223
5356
|
// src/utils/validation-schema.ts
|
|
5224
5357
|
import { isAddress as isAddress2, isHex } from "viem";
|
|
5225
5358
|
import { z } from "zod";
|
|
5226
|
-
var isHexRefinement, isAddressRefinement,
|
|
5359
|
+
var isHexRefinement, isAddressRefinement, tokenConfigSchema, vaultConfigSchema, poolConfigSchema, initialBuyConfigSchema, rewardsConfigSchema, deploymentConfigSchema;
|
|
5227
5360
|
var init_validation_schema = __esm({
|
|
5228
5361
|
"src/utils/validation-schema.ts"() {
|
|
5229
5362
|
"use strict";
|
|
@@ -5231,10 +5364,6 @@ var init_validation_schema = __esm({
|
|
|
5231
5364
|
init_validation();
|
|
5232
5365
|
isHexRefinement = (val) => isHex(val);
|
|
5233
5366
|
isAddressRefinement = (val) => isAddress2(val);
|
|
5234
|
-
clankerConfigSchema = z.object({
|
|
5235
|
-
publicClient: z.any().optional(),
|
|
5236
|
-
wallet: z.any().optional()
|
|
5237
|
-
});
|
|
5238
5367
|
tokenConfigSchema = z.object({
|
|
5239
5368
|
name: z.string().min(1, "Name is required"),
|
|
5240
5369
|
symbol: z.string().min(1, "Symbol is required"),
|
|
@@ -5361,9 +5490,6 @@ function validateConfig(config2) {
|
|
|
5361
5490
|
if (typeof config2 === "object" && config2 !== null && "pairedTokenPoolFee" in config2 && "pairedTokenSwapAmountOutMinimum" in config2) {
|
|
5362
5491
|
return initialBuyConfigSchema.safeParse(config2);
|
|
5363
5492
|
}
|
|
5364
|
-
if (typeof config2 === "object" && config2 !== null && "publicClient" in config2) {
|
|
5365
|
-
return clankerConfigSchema.safeParse(config2);
|
|
5366
|
-
}
|
|
5367
5493
|
return {
|
|
5368
5494
|
success: false,
|
|
5369
5495
|
error: {
|
|
@@ -5493,33 +5619,27 @@ var init_index = __esm({
|
|
|
5493
5619
|
init_v4();
|
|
5494
5620
|
init_availableFees();
|
|
5495
5621
|
init_claim();
|
|
5496
|
-
init_validation();
|
|
5497
5622
|
init_builders();
|
|
5498
5623
|
init_constants();
|
|
5499
5624
|
init_extensions();
|
|
5500
5625
|
init_vanityAddress();
|
|
5501
5626
|
init_types();
|
|
5627
|
+
init_clankers();
|
|
5502
5628
|
init_merkleTree();
|
|
5503
5629
|
init_validation();
|
|
5504
5630
|
Clanker = class {
|
|
5505
5631
|
wallet;
|
|
5506
5632
|
publicClient;
|
|
5633
|
+
simulate;
|
|
5507
5634
|
/**
|
|
5508
5635
|
* Creates a new instance of the Clanker SDK
|
|
5509
5636
|
* @param config - Optional configuration object containing wallet and public client
|
|
5510
5637
|
* @throws {Error} If the provided configuration is invalid
|
|
5511
5638
|
*/
|
|
5512
5639
|
constructor(config2) {
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
throw new Error(
|
|
5517
|
-
`Invalid Clanker configuration: ${JSON.stringify(validationResult.error?.format())}`
|
|
5518
|
-
);
|
|
5519
|
-
}
|
|
5520
|
-
this.wallet = config2.wallet;
|
|
5521
|
-
this.publicClient = config2.publicClient;
|
|
5522
|
-
}
|
|
5640
|
+
this.wallet = config2?.wallet;
|
|
5641
|
+
this.publicClient = config2?.publicClient;
|
|
5642
|
+
this.simulate = !!config2?.simulateBeforeWrite;
|
|
5523
5643
|
}
|
|
5524
5644
|
/**
|
|
5525
5645
|
* Collects rewards from a token
|
|
@@ -5527,8 +5647,12 @@ var init_index = __esm({
|
|
|
5527
5647
|
* @returns Promise resolving to the transaction hash
|
|
5528
5648
|
* @throws {Error} If wallet client or public client is not configured
|
|
5529
5649
|
*/
|
|
5530
|
-
claimRewards(feeOwnerAddress, tokenAddress) {
|
|
5531
|
-
|
|
5650
|
+
async claimRewards(feeOwnerAddress, tokenAddress) {
|
|
5651
|
+
if (!this.wallet) throw new Error("Wallet client required");
|
|
5652
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
5653
|
+
return claimRewards(this.publicClient, this.wallet, feeOwnerAddress, tokenAddress, {
|
|
5654
|
+
simulate: this.simulate
|
|
5655
|
+
});
|
|
5532
5656
|
}
|
|
5533
5657
|
/**
|
|
5534
5658
|
* Checks the available fees for a token
|
|
@@ -5537,22 +5661,12 @@ var init_index = __esm({
|
|
|
5537
5661
|
* @returns Promise resolving to the transaction hash
|
|
5538
5662
|
* @throws {Error} If wallet client or public client is not configured
|
|
5539
5663
|
*/
|
|
5540
|
-
async
|
|
5664
|
+
async availableRewards(feeOwnerAddress, tokenAddress) {
|
|
5541
5665
|
if (!this.publicClient) {
|
|
5542
5666
|
throw new Error("Public client required for checking available fees");
|
|
5543
5667
|
}
|
|
5544
5668
|
return availableFees(this.publicClient, feeOwnerAddress, tokenAddress);
|
|
5545
5669
|
}
|
|
5546
|
-
/**
|
|
5547
|
-
* Builds V4 token deployment data without actually deploying
|
|
5548
|
-
* @param cfg - Token configuration for V4 deployment
|
|
5549
|
-
* @returns Object containing transaction data, target address, and network info
|
|
5550
|
-
*/
|
|
5551
|
-
buildV4(cfg) {
|
|
5552
|
-
const chainId = this.publicClient?.chain?.id || 8453;
|
|
5553
|
-
const result = buildTokenV4(cfg, chainId);
|
|
5554
|
-
return result;
|
|
5555
|
-
}
|
|
5556
5670
|
/**
|
|
5557
5671
|
* Generates a vanity address for a V4 token deployment
|
|
5558
5672
|
* @param cfg - Token configuration for V4 deployment
|
|
@@ -5569,45 +5683,29 @@ var init_index = __esm({
|
|
|
5569
5683
|
* @returns Promise resolving to the address of the deployed token
|
|
5570
5684
|
* @throws {Error} If wallet client or public client is not configured
|
|
5571
5685
|
*/
|
|
5572
|
-
async
|
|
5686
|
+
async simulateDeployToken(cfg, account) {
|
|
5573
5687
|
const acc = account || this.wallet?.account;
|
|
5574
|
-
if (!acc)
|
|
5575
|
-
|
|
5576
|
-
}
|
|
5577
|
-
if (!this.publicClient) {
|
|
5578
|
-
throw new Error("Public client required for deployment");
|
|
5579
|
-
}
|
|
5688
|
+
if (!acc) throw new Error("Account or wallet client required for simulation");
|
|
5689
|
+
if (!this.publicClient) throw new Error("Public client required for deployment");
|
|
5580
5690
|
return simulateDeploy(cfg, acc, this.publicClient);
|
|
5581
5691
|
}
|
|
5582
5692
|
/**
|
|
5583
|
-
* Deploys a token
|
|
5584
|
-
* @param cfg - Token configuration for V4 deployment or pre-built deployment data
|
|
5585
|
-
* @returns Promise resolving to the address of the deployed token
|
|
5586
|
-
* @throws {Error} If wallet client or public client is not configured
|
|
5587
|
-
*/
|
|
5588
|
-
async deployTokenV4(cfg) {
|
|
5589
|
-
if (!this.wallet) {
|
|
5590
|
-
throw new Error("Wallet client required for deployment");
|
|
5591
|
-
}
|
|
5592
|
-
if (!this.publicClient) {
|
|
5593
|
-
throw new Error("Public client required for deployment");
|
|
5594
|
-
}
|
|
5595
|
-
return deployTokenV4(cfg, this.wallet, this.publicClient);
|
|
5596
|
-
}
|
|
5597
|
-
/**
|
|
5598
|
-
* Deploys a token using the V3 protocol
|
|
5693
|
+
* Deploys a token
|
|
5599
5694
|
* @param cfg - Token configuration for V3 deployment
|
|
5600
5695
|
* @returns Promise resolving to the address of the deployed token
|
|
5601
5696
|
* @throws {Error} If wallet client or public client is not configured
|
|
5602
5697
|
*/
|
|
5603
5698
|
async deployToken(cfg) {
|
|
5604
|
-
if (!this.wallet)
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5699
|
+
if (!this.wallet) throw new Error("Wallet client required for deployment");
|
|
5700
|
+
if (!this.publicClient) throw new Error("Public client required for deployment");
|
|
5701
|
+
switch (cfg.type) {
|
|
5702
|
+
case "v4":
|
|
5703
|
+
return deployTokenV4(cfg, this.wallet, this.publicClient);
|
|
5704
|
+
case "v3":
|
|
5705
|
+
return deployTokenV3(cfg, this.wallet, this.publicClient);
|
|
5706
|
+
default:
|
|
5707
|
+
throw new Error("Invalid config type");
|
|
5609
5708
|
}
|
|
5610
|
-
return deployTokenV3(cfg, this.wallet, this.publicClient);
|
|
5611
5709
|
}
|
|
5612
5710
|
};
|
|
5613
5711
|
}
|
|
@@ -5629,7 +5727,7 @@ import {
|
|
|
5629
5727
|
http
|
|
5630
5728
|
} from "viem";
|
|
5631
5729
|
import { privateKeyToAccount } from "viem/accounts";
|
|
5632
|
-
import { base as
|
|
5730
|
+
import { base as base4 } from "viem/chains";
|
|
5633
5731
|
async function createClanker() {
|
|
5634
5732
|
const PRIVATE_KEY = process.env.PRIVATE_KEY;
|
|
5635
5733
|
const FACTORY_ADDRESS = process.env.FACTORY_ADDRESS;
|
|
@@ -6010,12 +6108,12 @@ RPC_URL=your_custom_rpc_url (if not provided, will use default Base RPC)
|
|
|
6010
6108
|
try {
|
|
6011
6109
|
const transport = RPC_URL ? http(RPC_URL) : http();
|
|
6012
6110
|
const publicClient = createPublicClient({
|
|
6013
|
-
chain:
|
|
6111
|
+
chain: base4,
|
|
6014
6112
|
transport
|
|
6015
6113
|
});
|
|
6016
6114
|
const walletClient = createWalletClient({
|
|
6017
6115
|
account,
|
|
6018
|
-
chain:
|
|
6116
|
+
chain: base4,
|
|
6019
6117
|
transport
|
|
6020
6118
|
});
|
|
6021
6119
|
const clanker = new Clanker({
|
|
@@ -6025,6 +6123,7 @@ RPC_URL=your_custom_rpc_url (if not provided, will use default Base RPC)
|
|
|
6025
6123
|
console.log("\n\u{1F504} Preparing deployment configuration...");
|
|
6026
6124
|
const quoteToken = answers.pairedTokenChoice === "WETH" ? WETH_ADDRESS2 : answers.pairedTokenChoice === "USDC" ? USDC_ADDRESS : answers.customPairedToken;
|
|
6027
6125
|
const tokenConfig = {
|
|
6126
|
+
type: "v3",
|
|
6028
6127
|
name: answers.name,
|
|
6029
6128
|
symbol: answers.symbol,
|
|
6030
6129
|
image: answers.image,
|
|
@@ -6048,8 +6147,7 @@ RPC_URL=your_custom_rpc_url (if not provided, will use default Base RPC)
|
|
|
6048
6147
|
durationInDays: parseInt(answers.vaultConfig.durationInDays, 10)
|
|
6049
6148
|
} : void 0,
|
|
6050
6149
|
devBuy: answers.devBuy.ethAmount !== "0" ? {
|
|
6051
|
-
ethAmount: Number(answers.devBuy.ethAmount)
|
|
6052
|
-
maxSlippage: answers.devBuy.maxSlippage
|
|
6150
|
+
ethAmount: Number(answers.devBuy.ethAmount)
|
|
6053
6151
|
} : void 0,
|
|
6054
6152
|
rewardsConfig: {
|
|
6055
6153
|
creatorReward: answers.rewardsConfig.creatorReward === "CUSTOM" ? Number(answers.rewardsConfig.customCreatorReward) : Number(answers.rewardsConfig.creatorReward),
|